Repository navigation
fix: center search result line in read-only markdown view - #692
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideSearch next/previous now centers the matched line by enabling jumpToLine’s keepLineAtCenter behavior, which updates the scrollbar and triggers read-only Markdown render-page synchronization without changing other jumpToLine callers. Sequence diagram for centered search synchronizationsequenceDiagram
participant User
participant TextEdit
participant ScrollBar
participant MarkdownView
User->>TextEdit: searchKeywordSeletion(keyword, cursor, findNext)
TextEdit->>TextEdit: jumpToLine(line, true)
TextEdit->>TextEdit: keepCurrentLineAtCenter()
TextEdit->>ScrollBar: setValue(value)
ScrollBar-->>MarkdownView: valueChanged(value)
MarkdownView->>MarkdownView: synchronize rendered-page scroll
TextEdit->>TextEdit: setTextCursor(match)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
744f7ff to
076d9fd
Compare
1. Root cause: in read-only markdown view search next/prev called jumpToLine with keepLineAtCenter=false, so the hidden TextEdit only scrolled minimally and kept the match at the bottom edge of its own viewport, while render-page sync only aligns the top visible block; since the 800px rendered column is taller per source line, the match fell below the rendered fold (reliably reproducible when maximized) 2. Fix: pass keepLineAtCenter=true in searchKeywordSeletion so keepCurrentLineAtCenter centers the anchor line; the explicit scrollbar setValue also drives valueChanged render-page scroll sync 3. Test: add EditWrapper UT cases (maximized/normal window) asserting the renderer receives scrollToLine near the matched line; all 107 editor_wrapper UT cases pass Log: fix search result not visible in read-only markdown view Influence: 1. Test search next/prev in read-only markdown view, verify match is centered on screen, especially with a maximized window 2. Test search next/prev in edit mode, verify no regression 3. Verify render-page scroll sync follows editor scrollbar fix: 修复只读Markdown视图下查找结果不在当前屏显示 1. 根因:只读Markdown视图下查找下一个/上一个调用jumpToLine时传入 keepLineAtCenter=false,隐藏的TextEdit仅做最小滚动、匹配项停在 其视口底边缘,而渲染页滚动同步仅按顶部可见行对齐;800px定宽 渲染列每源码行渲染高度更大,匹配项落到渲染视口折叠线下 (窗口最大化时必现) 2. 方案:searchKeywordSeletion中jumpToLine的keepLineAtCenter改为 true,keepCurrentLineAtCenter将锚点行居中,显式scrollbar setValue同时驱动valueChanged渲染页滚动同步 3. 测试:新增EditWrapper单测(最大化/普通窗口两场景),断言渲染器 收到的scrollToLine行号贴近匹配行;editor_wrapper 107例全部通过 Log: 修复只读Markdown视图下查找结果不在当前屏显示的问题 Influence: 1. 在只读Markdown视图下测试查找下一个/上一个,验证匹配内容居中 显示,重点验证窗口最大化场景 2. 在编辑模式下测试查找功能,验证无回归 3. 验证渲染页滚动与编辑器滚动条同步 PMS: BUG-380705
076d9fd to
2440706
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议在观测点 2 后补充下界断言 EXPECT_GE(dist, -3),确保渲染页不会过度滚动超过匹配行,使测试同时覆盖欠滚动和过滚动两种回归场景'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 建议在测试中补充下界断言,增强测试鲁棒性: // 观测点 1:渲染页确实收到滚动指令 EXPECT_GE(renderer->scrollCalls, 1); // 观测点 2(修复语义):同步行号与匹配行相距不超过半屏 + 少量余量 EXPECT_LE(dist, visibleLines / 2 + 3); // 观测点 3:渲染页未滚动超过匹配行(防止过度滚动) EXPECT_GE(dist, -3);本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
fix: center search result line in read-only markdown view
jumpToLine with keepLineAtCenter=false, so the hidden TextEdit only
scrolled minimally and kept the match at the bottom edge of its own
viewport, while render-page sync only aligns the top visible block;
since the 800px rendered column is taller per source line, the match
fell below the rendered fold (reliably reproducible when maximized)
keepCurrentLineAtCenter centers the anchor line; the explicit
scrollbar setValue also drives valueChanged render-page scroll sync
a session never registers the keyword (m_keywordForSearchAll stays
empty), so handleFindKeyword took the clear branch and never pushed
highlightSearch to the rendered page - the match scrolled into view
but carried no highlight (Enter works because it registers)
and always calls highlightKeywordInView, matching the Enter path
scrollToLine lands within half a screen of the match; Window UT
asserts click-first pushes highlightSearch to the renderer
Log: fix search result not visible in read-only markdown view
Influence:
highlighted and centered, clicking Next first without pressing Enter
fix: 修复只读Markdown视图下查找结果不在当前屏显示
传入keepLineAtCenter=false,隐藏的TextEdit仅做最小滚动、匹配项停在
其视口底边缘,而渲染页滚动同步仅按顶部可见行对齐;800px定宽渲染列
每源码行渲染高度更大,匹配项落到渲染视口折叠线下(最大化时必现)
true,keepCurrentLineAtCenter将锚点行居中,显式scrollbar setValue
同时驱动valueChanged渲染页滚动同步
注册查找词),m_keywordForSearchAll为空使handleFindKeyword走清空
分支,渲染页收不到highlightSearch推送——匹配滚入视口却无任何高亮
(回车路径会注册查找词,故先回车后点击一切正常)
highlightKeywordInView,与回车路径行为对齐
scrollToLine落点距匹配行不超半屏;Window单测断言点击先行也会向
渲染页推送highlightSearch
Log: 修复只读Markdown视图下查找结果不在当前屏显示的问题
Influence:
内容带高亮且居中显示,重点验证窗口最大化场景
PMS: BUG-380705