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