🟡 [M1] update_for_append 不更新 visual_height_index #11
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?
文件:
core/io/progressive_reader.rs:659分类: 索引一致性
问题:
update_for_append()更新逻辑行索引但不更新visual_height_index,导致追加后视觉行滚动/高度信息过期。建议修复: 追加时 invalidate
visual_height_index,或为追加行计算高度并调用VisualHeightIndex::extend_from_heights()。修复方案
根因: 文件不以
\n结尾时,追加内容会续写最后一行导致其 visual height 变化,但handle_file_appended只为新增逻辑行计算高度,遗漏了旧行最后一行的高度更新。修复: 新增
VisualHeightIndex::replace_last_line_height()O(1) 方法,在增量扩展前重算旧行最后一行高度并修正 prefix_sums。改动:
crates/core/src/io/progressive_reader.rs: 新增replace_last_line_height+ 7 个单元测试crates/tui/src/app.rs:handle_file_appended增量路径中追加replace_last_line_height调用 + 2 个集成回归测试验证: core 190/190 + tui 94/94 全部通过,含直接复现 bug 的回归测试。
提交:
d4679a7