Commit 9ed3a728 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Set tab for an existing file as active in script window.

The behaviour is then consistent whether the file was already open
or not as the currently active tab is the requested file.
Refs #15682
parent 70939a72
......@@ -765,14 +765,18 @@ bool ScriptingWindow::shouldEnableAbort() const {
}
/**
* Opens a script providing a copy is not already open
* @param newTabName The name of the newTab to open
* Opens a script providing a copy is not already open. On exit the
* active tab will be the one containing the given script.
* @param filename The name of the newTab to open
*/
void ScriptingWindow::openUnique(const QString &newTabName) {
void ScriptingWindow::openUnique(const QString &filename) {
auto openFiles = m_manager->fileNamesToQStringList();
auto position = openFiles.contains(newTabName);
if (!position) {
m_manager->newTab(openFiles.size(), newTabName);
auto position = openFiles.indexOf(filename);
if (position < 0) {
m_manager->newTab(openFiles.size(), filename);
} else {
// make it the current tab
m_manager->setCurrentIndex(position);
}
}
......
......@@ -56,7 +56,7 @@ public:
/// Set whether to accept/reject close events
void acceptCloseEvent(const bool value);
/// Opens a script providing a copy is not already open
void openUnique(const QString &);
void openUnique(const QString &filename);
signals:
/// Show the scripting language dialog
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment