🟡 [M1] update_for_append 不更新 visual_height_index #11

Closed
opened 2026-06-03 13:53:56 +08:00 by dailz · 1 comment
Owner

文件: core/io/progressive_reader.rs:659
分类: 索引一致性

问题: update_for_append() 更新逻辑行索引但不更新 visual_height_index,导致追加后视觉行滚动/高度信息过期。

建议修复: 追加时 invalidate visual_height_index,或为追加行计算高度并调用 VisualHeightIndex::extend_from_heights()

**文件**: `core/io/progressive_reader.rs:659` **分类**: 索引一致性 **问题**: `update_for_append()` 更新逻辑行索引但不更新 `visual_height_index`,导致追加后视觉行滚动/高度信息过期。 **建议修复**: 追加时 invalidate `visual_height_index`,或为追加行计算高度并调用 `VisualHeightIndex::extend_from_heights()`。
dailz added the severity/mediumarea/iobug labels 2026-06-03 13:53:56 +08:00
Author
Owner

修复方案

根因: 文件不以 \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

## 修复方案 **根因**: 文件不以 `\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
dailz closed this issue 2026-06-07 09:46:51 +08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dailz/logViewer#11