Repository navigation
[6039] 修复渐进式排版跨分块重置 env 导致节编号与公式编号归 1 的缺陷 - #4800
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
打开长文档
6039.stem后点击左侧大纲中的Non-homogeneous problem跳转时,文档区域的节编号和公式编号错误显示为1和(1);按Ctrl+Shift+R触发全量刷新后才恢复为正确的6与(5)。根因
点击大纲跳转到未排版章节会触发
progressive_fast_forward_until并调用edit_typeset_rep::typeset_sub()。其中typeset_prepare()每次都会通过write_default_env()/patch_env(pre)/style_init_env()将env重置为初始状态,而bridge_document_rep::my_typeset()在渐进式排版下仅遍历[chunk_start, chunk_end),跳过了[0, chunk_start)的前置章节,导致section-nr、equation-nr等计数器未从前置章节累积。修复方案
src/Typeset/Bridge/impl_typesetter.hpp/src/Typeset/Bridge/typesetter.cpp:在typesetter_rep中增加progressive_env快照;当分块结束且chunk_end < n时通过env->read_env(progressive_env)保存当前环境;当后续分块从chunk_start > 0启动时在br->typeset()前通过env->write_env(progressive_env)与env->update()恢复环境状态与计数器,并在progressive_reset()与非渐进分支中清空快照。tests/Typeset/progressive_typeset_test.cpp:新增单元测试test_progressive_preserves_env_counters_across_chunks。验证
xmake b progressive_typeset_test && xmake r progressive_typeset_test:11/11 通过xmake b stem&python3 ~/git/dev-agent/tests/mogan/python/6039.py --verify:通过(变化像素 sec=0, eq=0)