Repository navigation
Conversation
1. Root cause: recoverFile() skips deleted focus tab via continue, remaining tabs added via addPendingTab() which blocks signals and calls setCurrentIndex(0) without emitting currentChanged 2. Fix: in fallback branch after activeTab(0), explicitly check if first tab is pending and call loadPendingTab() to trigger loading 3. Impact: only affects fallback path when focus tab file is missing, no behavior change for normal tab recovery flow Log: Fix unable to edit when focus tab file is deleted or moved Influence: 1. Test opening 2 files, delete focus file A, restart editor, verify file B is editable 2. Test opening 3+ files, delete focus file, restart, verify all remaining files are editable 3. Test normal multi-file restart, verify all tabs recover correctly fix: 焦点标签页文件被删除后加载待加载标签页 1. 根因:recoverFile() 通过 continue 跳过已删除的焦点标签页, 剩余标签页经 addPendingTab() 添加时阻塞信号且调用 setCurrentIndex(0) 不发射 currentChanged 信号 2. 方案:在兜底分支 activeTab(0) 之后,显式检查首个标签页是否 为待加载状态,若是则调用 loadPendingTab() 触发加载 3. 影响:仅影响焦点标签页文件缺失时的兜底路径,对正常标签页 恢复流程无行为变化 Log: 修复焦点标签页文件被删除或移动后无法编辑的问题 Influence: 1. 测试打开 2 个文件,删除焦点文件 A,重启编辑器,验证 B 文件可编辑 2. 测试打开 3+ 个文件,删除焦点文件,重启编辑器,验证所有剩余文件可编辑 3. 测试正常多文件重启,验证所有标签页正常恢复 PMS: BUG-376141
pengfeixx
marked this pull request as draft
November 2, 2026 16:26
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes startup tab recovery for the case where the focused file was deleted or moved by directly loading the first pending tab after fallback activation, avoiding reliance on a suppressed or unchanged currentChanged signal. Sequence diagram for fallback tab recovery after focus file deletionsequenceDiagram
participant StartManager
participant Window
participant Tabbar
participant PendingTab
participant EditWrapper
StartManager->>Window: activeTab(0)
Window->>Tabbar: fileAt(0)
Tabbar-->>Window: firstFile
Window->>PendingTab: isPendingTab(firstFile)
PendingTab-->>Window: true
Window->>PendingTab: loadPendingTab(firstFile)
PendingTab->>EditWrapper: create EditWrapper
EditWrapper-->>PendingTab: loaded
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
pengfeixx
marked this pull request as ready for review
November 3, 2026 05:47
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例本报告由 AI 代码审查工具自动生成 |
lzwind
approved these changes
Nov 3, 2026
|
[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 |
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
When the editor restarts and
recoverFile()restores tabs, if the focus tab's file has been deleted or moved, it is skipped viacontinue. The remaining non-focus tabs are added viaaddPendingTab(), which blocks signals and callssetCurrentIndex(0). When only one pending tab remains (the 2-file scenario),currentIndexis already 0, so the fallbackactiveTab(0)→setCurrentIndex(0)does not emitcurrentChanged. As a result,handleCurrentChanged()never fires,loadPendingTab()is never triggered, and the tab stays in pending state with noEditWrapper— the user cannot edit.Key evidence:
src/startmanager.cpp:509-512(fallback branch),src/widgets/window.cpp:3328-3340(addPendingTabblocks signals),src/widgets/window.cpp:677-682(activeTabcallssetCurrentIndex).Fix
In the fallback branch of
recoverFile(), afteractiveTab(0), explicitly check if the first tab is a pending tab and callloadPendingTab()to trigger loading. This ensures theEditWrapperis created even whencurrentChangedwas not emitted.Change Safety Assessment
Code Safety
isPendingTab()andloadPendingTab()which have internal existence checks and failure handling; no signature changesBusiness Impact Scope
Affected module: tab recovery on editor startup. When the focus tab's file is deleted/moved externally, the remaining tabs now load correctly. No impact on normal tab recovery flow.
Verification Suggestion
Test the original bug scenario: open 2 files, delete/move focus file A, restart editor, verify file B is editable. Also verify normal multi-file restart has no regression.
根因分析
编辑器重启时
recoverFile()恢复标签页,若焦点标签页文件已被删除或移动,则通过continue跳过。剩余非焦点标签页通过addPendingTab()添加,该方法阻塞信号并调用setCurrentIndex(0)。当仅剩 1 个待加载标签页(2 文件场景)时,currentIndex已为 0,兜底代码activeTab(0)→setCurrentIndex(0)不发射currentChanged信号,导致handleCurrentChanged()永不被调用,loadPendingTab()永不触发,编辑区域无EditWrapper,用户无法编辑。关键证据:
src/startmanager.cpp:509-512(兜底分支)、src/widgets/window.cpp:3328-3340(addPendingTab阻塞信号)、src/widgets/window.cpp:677-682(activeTab调用setCurrentIndex)。修复方案
在
recoverFile()兜底分支activeTab(0)之后,显式检查首个标签页是否为待加载状态,若是则调用loadPendingTab()触发加载,确保即使currentChanged未发射也能创建EditWrapper。改动安全评估
代码安全评估
isPendingTab()和loadPendingTab(),二者内部有文件存在性检查和失败处理;无签名变更业务影响范围
受影响模块:编辑器启动时标签页恢复。当焦点标签页文件被外部删除/移动后,剩余标签页现在能正确加载。对正常标签页恢复流程无影响。
验证建议
测试原 bug 场景:打开 2 个文件,删除/移动焦点文件 A,重启编辑器,验证 B 文件可编辑。同时验证正常多文件重启无回归。
Summary by Sourcery
Bug Fixes: