Skip to content

Commit

Permalink
Properly count the open tabs across multiple windows
Browse files Browse the repository at this point in the history
  • Loading branch information
xusheng6 committed Feb 20, 2024
1 parent 67ded6c commit ee1d1c5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ui/uinotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ void NotificationListener::OnAfterSaveFile(UIContext* context, FileContext* file
bool NotificationListener::OnBeforeCloseFile(UIContext* context, FileContext* file, ViewFrame* frame)
{
auto mainWindow = context->mainWindow();
auto tabs = context->getTabs();

size_t count = 0;
for (auto tab : tabs)
for (const auto& ctx: UIContext::allContexts())
{
auto viewFrame = context->getViewFrameForTab(tab);
if (viewFrame && (viewFrame->getFileContext() == file))
count++;
auto tabs = ctx->getTabs();
for (auto tab : tabs)
{
auto viewFrame = ctx->getViewFrameForTab(tab);
if (viewFrame && (viewFrame->getFileContext() == file))
count++;
}
}

// If this is not the last tab of the file being closed, return
Expand Down

0 comments on commit ee1d1c5

Please sign in to comment.