Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/controls/tabbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ void Tabbar::updateTab(int index, const QString &filePath, const QString &tabNam
qCDebug(appLog) << "Updating tab index:" << index
<< "file:" << QFileInfo(filePath).fileName()
<< "new name:" << tabName;

if (index < 0 || index >= m_tabPaths.count()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Save-as paths become inconsistent

When a wrapper remains registered under its old path but that path is absent from the tab bar, updateTab() returns without changing the tab, while Window::updateSaveAsFileName() and Window::updateSabeAsFileNameTemp() continue changing the wrapper path and map key, leaving the tab on the old path and its wrapper on the new one.

Have updateTab() report failure and make both save-as callers avoid rekeying the wrapper unless the tab update succeeds.

Also at src/controls/tabbar.cpp:320.

Prompt for AI agents
In `src/controls/tabbar.cpp` at line 318:

**Save-as paths become inconsistent**

When a wrapper remains registered under its old path but that path is absent from the tab bar, `updateTab()` returns without changing the tab, while `Window::updateSaveAsFileName()` and `Window::updateSabeAsFileNameTemp()` continue changing the wrapper path and map key, leaving the tab on the old path and its wrapper on the new one.

Have `updateTab()` report failure and make both save-as callers avoid rekeying the wrapper unless the tab update succeeds.

Also at `src/controls/tabbar.cpp:320`.

qCWarning(appLog) << "Invalid index for updateTab:" << index;
return;
}

// 适配助记符 '&' 后设置文本
setTabText(index, tabName);
m_tabPaths[index] = filePath;
Expand Down Expand Up @@ -984,6 +990,12 @@ void Tabbar::handleTabReleased(int index)
void Tabbar::handleTabIsRemoved(int index)
{
qCDebug(appLog) << "Enter handleTabIsRemoved, index:" << index;

if (index < 0 || index >= m_tabPaths.count()) {
qCWarning(appLog) << "Invalid index for handleTabIsRemoved:" << index;
return;
}

const QString filePath = m_tabPaths.at(index);
Window *window = static_cast<Window *>(this->window());
m_tabPaths.removeAt(index);
Expand Down
Loading