Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed an issue with editor document synchronization #900

Merged
merged 1 commit into from
Sep 4, 2024
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
18 changes: 16 additions & 2 deletions src/plugins/codeeditor/gui/workspacewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,22 @@ void WorkspaceWidgetPrivate::handleOpenFile(const QString &workspace, const QStr
if (stackWidget->currentIndex() != 0)
stackWidget->setCurrentIndex(0);

if (auto tabWidget = currentTabWidget())
tabWidget->openFile(fileName);
// find the editor if the `fileName` is already opened
TextEditor *editor { nullptr };
for (auto tabWidget : qAsConst(tabWidgetList)) {
editor = tabWidget->findEditor(fileName);
if (editor)
break;
}

if (auto tabWidget = currentTabWidget()) {
if (editor) {
auto document = editor->document();
tabWidget->openFile(fileName, &document);
} else {
tabWidget->openFile(fileName);
}
}
}

void WorkspaceWidgetPrivate::handleCloseFile(const QString &fileName)
Expand Down
Loading