From 7bc455c4f7c0f3e4e1ce9303c6b426afb9da84f7 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Thu, 7 Sep 2023 12:31:51 +0800 Subject: [PATCH] Properly detect whether the tab being closed is the last tab of a file --- ui/uinotification.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ui/uinotification.cpp b/ui/uinotification.cpp index a8525c33..3b99b144 100644 --- a/ui/uinotification.cpp +++ b/ui/uinotification.cpp @@ -108,25 +108,18 @@ static void DestroyControllers(const std::vector& 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)