Repository navigation
[6038] 修复全量排版完成后再次触发 typeset() 导致全文重复排版的缺陷 - #4799
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.
问题描述
打开长文档(如
xiyouji.stem)并等待全文排版完成后,执行「插入 → 自动 → 目录」生成目录,点击目录中的「第一百回」跳转并向下滚动时,第一百回之后会再次出现「西游记」标题、目录与全文内容,总页数翻倍。根因分析
is_final = (chunk_end >= n))时,typesetter_rep::typeset()将最终分块页面追加进frozen_page_boxes,并把progressive_cur_child设为n,清空doc_l。progressive_reset()而直接再次调用typesetter_rep::typeset(),由于progressive_cur_child == n != 0,if (progressive_cur_child == 0)分支被跳过,而chunk_start/chunk_end与frozen_page_boxes仍保留上一轮全量状态,pager_rep将新排出的全文页面拼接到已有frozen_page_boxes之后,导致页数翻倍、全文重复。br->status置0,bridge_rep::typeset()在无脏标记时会走缓存分支,仅吐出上一轮最后一个分块的br->l。修复内容
src/Typeset/Bridge/typesetter.cpp:typesetter_rep::typeset()的progressive_enabled分支中增加else if (progressive_cur_child >= n):调用progressive_reset()清空frozen_page_boxes、frozen_border_boxes与doc_l,并置chunk_start = 0、chunk_end = n、br->status = 0。nr_pages < last_page_count兜底全量重排分支同步置br->status = 0。tests/Typeset/progressive_typeset_test.cpp:test_retypeset_after_full_typeset_without_reset回归用例,验证全量排版完成后不经progressive_reset()直接再次触发typeset()时总页数不翻倍且标题仅出现 1 次。验证情况
xmake b progressive_typeset_test && xmake r progressive_typeset_test:10 passed, 0 failed。gf fmt --changed-since=main --check:通过(0 files updated)。python3 tests/mogan/python/6038.py --verify:通过(第一百回之后未再出现重复标题)。