summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-08-12 22:34:01 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-22 23:41:53 +0200
commit8d3304f853f96dadf7005be831705b8f3eff23d1 (patch)
tree953b3b2336ad40adbb949b0c27f7ffd6a1680896 /Userland
parent90396f5b08f48ed9e0c0d47492dc7a2a1d66bb9a (diff)
downloadserenity-8d3304f853f96dadf7005be831705b8f3eff23d1.zip
HackStudio: Update every editor with matching filename on 'Save as...'
Prior this change, if user had more than two copies of one file opened in a split view, then only the active editor was renamed, when the others had the same file contents changed. This change will set a new file name for every file. The is_null() check is for uncreated files, as they shouldn't be treated as the same single file.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
index c53a95f920..387afd0fb0 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
@@ -653,7 +653,14 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
}
String const relative_file_path = LexicalPath::relative_path(save_path.value(), m_project->root_path());
- current_editor_wrapper().set_filename(relative_file_path);
+ if (current_editor_wrapper().filename().is_null()) {
+ current_editor_wrapper().set_filename(relative_file_path);
+ } else {
+ for (auto& editor_wrapper : m_all_editor_wrappers) {
+ if (editor_wrapper.filename() == old_filename)
+ editor_wrapper.set_filename(relative_file_path);
+ }
+ }
current_editor_wrapper().save();
auto new_project_file = m_project->get_file(relative_file_path);