🟡 [M15] Ready 无 VisualHeightIndex 时走 Loading 滚动路径 #25

Closed
opened 2026-06-03 13:53:57 +08:00 by dailz · 2 comments
Owner

文件: tui/app.rs:331-457
分类: 滚动 / 状态机

问题: Ready 状态没有 VHI 时(resize/JSON toggle 后)使用 Loading 的滚动逻辑,混合逻辑偏移和视觉偏移,光标/视口不一致。

建议修复: 区分 ReadyWithoutIndexLoading,Ready 期间使用保守的逻辑行滚动。

**文件**: `tui/app.rs:331-457` **分类**: 滚动 / 状态机 **问题**: Ready 状态没有 VHI 时(resize/JSON toggle 后)使用 Loading 的滚动逻辑,混合逻辑偏移和视觉偏移,光标/视口不一致。 **建议修复**: 区分 `ReadyWithoutIndex` 和 `Loading`,Ready 期间使用保守的逻辑行滚动。
dailz added the bugseverity/mediumarea/tui labels 2026-06-03 13:53:57 +08:00
Author
Owner

@-

@-
Author
Owner

修复方案

根因: Ready 状态下 VHI 被异步 invalidate 后(Tab toggle / resize / file append / Loading→Ready),v_offset 仍保留视觉行偏移值,但所有函数开始将其当作逻辑行偏移处理,导致视口跳跃和光标漂移。VHI 异步重建完成后也未将 v_offset 从逻辑行重新校准回视觉行。

修复 (a43ef67):

  1. 新增 rebase_offset_for_invalidate(): 在 VHI 失效前将 v_offset 从视觉行转换为逻辑行 + 子行偏移,保留精确的视口内行位置
  2. 6 个 invalidation 调用点前插入 rebase 调用: Tab toggle、ensure_visual_height_index、file append/Reloaded、reload_ready_reader、Loading→Ready transition
  3. VHI 重建完成后从视口顶部校准: poll_background_indexer 中 VHI 就绪后,将 v_offset 从逻辑行映射回视觉行,并 clamp 子行偏移到新行高

回归测试: 6 个新测试覆盖 rebase 转换、Tab toggle 不变量、VHI 重建校准、子行 clamp、Loading→Ready 转换。全部 352 测试通过。

## 修复方案 **根因**: Ready 状态下 VHI 被异步 invalidate 后(Tab toggle / resize / file append / Loading→Ready),`v_offset` 仍保留视觉行偏移值,但所有函数开始将其当作逻辑行偏移处理,导致视口跳跃和光标漂移。VHI 异步重建完成后也未将 `v_offset` 从逻辑行重新校准回视觉行。 **修复** (`a43ef67`): 1. **新增 `rebase_offset_for_invalidate()`**: 在 VHI 失效前将 `v_offset` 从视觉行转换为逻辑行 + 子行偏移,保留精确的视口内行位置 2. **6 个 invalidation 调用点前插入 rebase 调用**: Tab toggle、ensure_visual_height_index、file append/Reloaded、reload_ready_reader、Loading→Ready transition 3. **VHI 重建完成后从视口顶部校准**: `poll_background_indexer` 中 VHI 就绪后,将 `v_offset` 从逻辑行映射回视觉行,并 clamp 子行偏移到新行高 **回归测试**: 6 个新测试覆盖 rebase 转换、Tab toggle 不变量、VHI 重建校准、子行 clamp、Loading→Ready 转换。全部 352 测试通过。
dailz closed this issue 2026-06-11 09:50:36 +08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dailz/logViewer#25