Skip to content

Commit

Permalink
Properly detect whether the tab being closed is the last tab of a file
Browse files Browse the repository at this point in the history
  • Loading branch information
xusheng6 committed Sep 7, 2023
1 parent e152ccb commit 7bc455c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions ui/uinotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,18 @@ static void DestroyControllers(const std::vector<BinaryViewRef>& datas)

bool NotificationListener::OnBeforeCloseFile(UIContext* context, FileContext* file, ViewFrame* frame)
{
auto currentTab = context->getCurrentTab();
auto mainWindow = context->mainWindow();
auto tabs = context->getTabs();
bool tabRemaining = false;
size_t count = 0;
for (auto tab : tabs)
{
if (tab == currentTab)
continue;

auto viewFrame = context->getViewFrameForTab(tab);
if (viewFrame && (viewFrame->getFileContext() == file))
{
tabRemaining = true;
break;
}
count++;
}

// This is the last tab of the file being closed. Check whether the debugger is connected
if (!tabRemaining)
if (count == 1)
{
auto viewFrame = context->getCurrentViewFrame();
if (!viewFrame)
Expand Down

0 comments on commit 7bc455c

Please sign in to comment.