mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
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.
This commit is contained in:
parent
2ac385f4db
commit
d8b54b7dd0
1 changed files with 12 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue