diff options
author | Marco Cutecchia <marco.cutecchia@outlook.it> | 2022-09-12 22:32:27 +0200 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-10-06 11:53:23 +0100 |
commit | d8b54b7dd0e186cebf849352e2888694ab8891d9 (patch) | |
tree | 5977fcb46564285077c83755a6ee6339e12b28cc /Userland/DevTools/HackStudio | |
parent | 2ac385f4db1bebb9314d5e45011621b5774cec62 (diff) | |
download | serenity-d8b54b7dd0e186cebf849352e2888694ab8891d9.zip |
HackStudio: Open files in dedicated tabs
Previously when trying to open a file from the tree view the file
would open in the currently selected tab, substituting the file
we were previously reading.
This change makes it so that clicking on a file from the tree view
opens it in a new tab, or selects the tab containing that file if
it's already open in the selected editor group.
Diffstat (limited to 'Userland/DevTools/HackStudio')
-rw-r--r-- | Userland/DevTools/HackStudio/HackStudioWidget.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 30bb875ef3..99a2bc3e67 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -311,6 +311,17 @@ bool HackStudioWidget::open_file(String const& full_filename, size_t line, size_ if (Core::File::is_directory(filename) || !Core::File::exists(filename)) return false; + auto editor_wrapper_or_none = m_all_editor_wrappers.first_matching([&](auto& wrapper) { + return wrapper->filename() == filename; + }); + + if (editor_wrapper_or_none.has_value()) { + set_current_editor_wrapper(editor_wrapper_or_none.release_value()); + return true; + } else { + add_new_editor(*m_current_editor_tab_widget); + } + if (!active_file().is_empty()) { // Since the file is previously open, it should always be in m_open_files. VERIFY(m_open_files.find(active_file()) != m_open_files.end()); @@ -1175,6 +1186,7 @@ void HackStudioWidget::set_current_editor_wrapper(RefPtr<EditorWrapper> editor_w update_current_editor_title(); update_tree_view(); set_current_editor_tab_widget(static_cast<GUI::TabWidget*>(m_current_editor_wrapper->parent())); + m_current_editor_tab_widget->set_active_widget(editor_wrapper); update_statusbar(); } |