🟢 [L3] 颜色向后循环不 wrap #29
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
文件:
tui/app.rs:657-678分类: 状态机 / UI
问题:
saturating_sub(1).min(colors.len()-1)到 0 就停了,向左循环不 wrap 到最后一个颜色。建议修复: 使用
(p + colors.len() - 1) % colors.len()。已修复:
dfc016c根因:
cycle_color向后循环使用saturating_sub(1).min(colors.len()-1),到索引 0 时被钳位为 0,无法 wrap 到最后一个颜色。修复: 替换为
if p == 0 { colors.len() - 1 } else { p - 1 },显式处理边界 wrap。测试: 在
test_settings_cycle_color中新增 2 个断言覆盖 wrap 边界(red→Left→white, white→Right→red),全部 10 个 settings 测试通过。