From 61c7b4bbc41f30e561cfb855b40e01afc3ba1da5 Mon Sep 17 00:00:00 2001
From: Ian Bush <bush@ill.fr>
Date: Fri, 27 Jul 2018 15:23:25 +0200
Subject: [PATCH] Refs #22993 Set the tab being closed to be the current one

This avoids a bug when saving which sets the file name for the wrong tab, and makes it clearer what you are being asked to save.
---
 .../widgets/codeeditor/multifileinterpreter.py         | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py b/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py
index 4651b156fb6..5ccc4f94068 100644
--- a/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py
+++ b/qt/python/mantidqt/widgets/codeeditor/multifileinterpreter.py
@@ -70,9 +70,9 @@ class MultiPythonFileInterpreter(QWidget):
         interpreter.sig_editor_modified.connect(self.mark_current_tab_modified)
         interpreter.sig_filename_modified.connect(self.on_filename_modified)
 
-        tab_title, tab_toolip = _tab_title_and_toolip(filename)
+        tab_title, tab_tooltip = _tab_title_and_toolip(filename)
         tab_idx = self._tabs.addTab(interpreter, tab_title)
-        self._tabs.setTabToolTip(tab_idx, tab_toolip)
+        self._tabs.setTabToolTip(tab_idx, tab_tooltip)
         self._tabs.setCurrentIndex(tab_idx)
         return tab_idx
 
@@ -99,8 +99,10 @@ class MultiPythonFileInterpreter(QWidget):
         """
         if idx >= self.editor_count:
             return True
-        editor = self.editor_at(idx)
-        if editor.confirm_close():
+        # Make the current tab active so that it is clear what you
+        # are being prompted to save
+        self._tabs.setCurrentIndex(idx)
+        if self.current_editor().confirm_close():
             self._tabs.removeTab(idx)
         else:
             return False
-- 
GitLab