Repository navigation
fix: render all selections after undo/redo in column edit - #705
Draft
pppanghu77 wants to merge 1 commit into
Draft
pppanghu77 wants to merge 1 commit into
pppanghu77 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pppanghu77 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 |
pppanghu77
marked this pull request as draft
October 29, 2026 19:39
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes column-edit undo/redo rendering by explicitly pushing the restored multi-line selection list to the editor after selection state restoration, preventing only the last line from appearing highlighted. Sequence diagram for column-edit undo/redo selection renderingsequenceDiagram
participant Command as DeleteBackAltCommand
participant Editor as DTextEdit
participant Qt as QPlainTextEdit
Command->>Editor: restoreColumnEditSelection(m_columnEditSelections)
Command->>Editor: setTextCursor(m_columnEditSelections.last().cursor)
Command->>Editor: renderAllSelections()
Editor->>Qt: setExtraSelections(m_altModSelections)
Qt-->>Editor: Render all restored line highlights
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Root cause: undo()/redo() in DeleteBackAltCommand, DeleteTextUndoCommand and InsertTextUndoCommand call restoreColumnEditSelection() which only updates the member variable m_altModSelections but never pushes it to QPlainTextEdit::setExtraSelections() 2. Fix: add m_edit->renderAllSelections() after restoreColumnEditSelection() in all affected undo()/redo() methods so all column-edit highlight lines are rendered 3. Impact: only affects column-edit undo/redo highlight rendering, normal Alt-drag selection path already calls renderAllSelections() unchanged Log: fix incomplete column edit selection highlight after undo/redo Influence: 1. Test column-edit multi-line cut then undo, verify all lines highlighted 2. Test column-edit multi-line delete then undo, verify all lines highlighted 3. Test undo then redo in column edit, verify all lines highlighted 4. Verify normal column-edit selection highlight has no regression fix: 修复列编辑撤销/重做后选中高亮不完全 1. 根因:DeleteBackAltCommand、DeleteTextUndoCommand 和 InsertTextUndoCommand 的 undo()/redo() 调用 restoreColumnEditSelection() 仅更新成员变量 m_altModSelections, 未调用 renderAllSelections() 推送到 QPlainTextEdit 渲染层 2. 方案:在所有受影响的 undo()/redo() 的 restoreColumnEditSelection() 后增加 m_edit->renderAllSelections() 调用,使全部列编辑选中行正确渲染 3. 影响:仅影响列编辑撤销/重做的高亮渲染,正常 Alt+拖拽选中路径 已调用 renderAllSelections(),行为不变 Log: 修复列编辑撤销重做后选中高亮不完全的问题 Influence: 1. 测试列编辑多行剪切后撤销,验证所有行高亮恢复 2. 测试列编辑多行删除后撤销,验证所有行高亮恢复 3. 测试撤销后重做,验证所有行高亮恢复 4. 验证正常列编辑选中高亮无回归 PMS: BUG-241613
pppanghu77
force-pushed
the
agent/agent/3f28a708a413
branch
from
October 29, 2026 20:55
08cd146 to
b795235
Compare
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.
Root Cause Analysis
In deepin-editor's column-edit mode (Alt+drag), after cutting or deleting multi-line text and then undoing, only the last line's selection highlight is restored while other lines lose their highlight. The root cause is that
DeleteBackAltCommand::undo()andredo()(src/editor/deletebackcommond.cpp) callrestoreColumnEditSelection()which only updates the member variablem_altModSelectionswithout callingrenderAllSelections()to push selections toQPlainTextEdit::setExtraSelections(). The subsequentsetTextCursor(last().cursor)only renders the last line's cursor selection. The normal Alt+drag path (dtextedit.cppmouseMoveEvent) correctly callsrenderAllSelections()after building the selection list.Fix Approach
Add
m_edit->renderAllSelections()afterrestoreColumnEditSelection()in bothDeleteBackAltCommand::undo()andredo(), so thatm_altModSelectionsis pushed to Qt's rendering layer viasetExtraSelections(). This aligns the undo/redo path with the normal selection path.Change Safety Assessment
Code Safety
889fa1969(PMS 273663) which addedrestoreColumnEditSelection()but omitted the render call — this fix supplements that omission without reverting the historical fixrenderAllSelections()is an existing public method already called by the normal Alt+drag path; no signature changes, no public member changes, 0 external references affectedBusiness Impact Scope
Verification Suggestion
Test column-edit multi-line selection → cut/delete → undo → verify all lines highlighted; then redo → verify all lines highlighted. Also verify normal column-edit selection highlight has no regression.
根因分析
在 deepin-editor 列编辑模式(Alt+拖拽)下,剪切或删除多行文本后撤销,仅最后一行的选中高亮恢复,其余行高亮消失。根因是
DeleteBackAltCommand::undo()和redo()(src/editor/deletebackcommond.cpp)调用restoreColumnEditSelection()仅更新成员变量m_altModSelections,未调用renderAllSelections()将选中列表推送到QPlainTextEdit::setExtraSelections()渲染层。随后的setTextCursor(last().cursor)仅渲染最后一行光标的选中区域。正常 Alt+拖拽路径(dtextedit.cppmouseMoveEvent)会正确调用renderAllSelections()。修复方案
在
DeleteBackAltCommand::undo()和redo()的restoreColumnEditSelection()调用之后增加m_edit->renderAllSelections()调用,使m_altModSelections通过setExtraSelections()推送到 Qt 渲染层,与正常选中路径保持一致。改动安全评估
代码安全评估
889fa1969(PMS 273663)引入,该提交添加了restoreColumnEditSelection()但遗漏了渲染调用——本次修复补充该遗漏,不撤销历史修复renderAllSelections()是已有公共方法,正常 Alt+拖拽路径已调用;无签名变更、无公开成员变更、0 条外部引用受影响业务影响范围
验证建议
测试列编辑多行选中 → 剪切/删除 → 撤销 → 验证所有行高亮恢复;再重做 → 验证所有行高亮恢复。同时验证正常列编辑选中高亮无回归。
Summary by Sourcery
Bug Fixes: