Skip to content

[6032] 修复渐进式排版跳转至文末后在末尾按回车导致文档排版与光标混乱 - #4785

Merged
da-liii merged 2 commits into
mainfrom
da/6242/fix
Nov 16, 2026
Merged

da-liii merged 2 commits into
mainfrom
da/6242/fix

Conversation

@da-liii

@da-liii da-liii commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

问题描述

长文档(如 6242.stem)在大纲侧边栏跳转至文末并下移光标至最后一行后,按下回车键会导致:

  1. 视口剧烈跳变并偏离文末,第 35 页上半部分出现大面积空白;
  2. 页数异常跳增(35 -> 37),末页完全空白;
  3. 光标状态退化为 start,撤销回车后视口直接跳回第 1 页。

根因分析

  1. 点击大纲跳转至文末后,max_typeset_child == n_old。文末回车触发 bridge_document_rep::notify_insert(n = n_old + 1)并调用 progressive_reset(),但 max_typeset_child 未同步递增,导致下一轮 typesetter_rep::typeset() 计算 chunk_end = min(n, max_typeset_child) = n_old < n,将新插入且光标所在的末尾节点遗漏在首轮分块之外,落入 progressive_pending = true。
  2. typesetter.cpp 中先因 if (env->complete) 清空了 env->local_aux,随后才因 chunk_end < n 将 env->complete 设为 false,导致辅助引用表被清空却跳过 determine_page_references,引发分页与光标混乱。

修复内容

  • src/Typeset/Bridge/bridge_document.cpp:顶层根文档 notify_insert / notify_remove 时同步更新 max_typeset_child,确保文末插入节点在首轮重排即被覆盖;
  • src/Typeset/Bridge/typesetter.cpp:调整 progressive_enabled && chunk_end < n 修正 env->complete = false 的时序至清空 local_aux 之前;
  • tests/Typeset/progressive_typeset_test.cpp:新增 test_append_at_end_after_full_typeset 回归单元测试。

验证结果

  • xmake b progressive_typeset_test && xmake r progressive_typeset_test:7 passed, 0 failed;
  • python3 ~/git/dev-agent/tests/mogan/python/6242.py --verify:端到端真机验收通过。

@da-liii da-liii changed the title [6242] 修复渐进式排版跳转至文末后在末尾按回车导致文档排版与光标混乱 [6032] 修复渐进式排版跳转至文末后在末尾按回车导致文档排版与光标混乱 Nov 16, 2026
@da-liii
da-liii merged commit 3d29e49 into main Nov 16, 2026
6 checks passed
@da-liii
da-liii deleted the da/6242/fix branch November 16, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant