diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index bf715e6e9b..603a32e5bf 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -236,7 +236,7 @@ Vector HackStudioWidget::selected_file_paths() const return files; } -bool HackStudioWidget::open_file(const String& full_filename) +bool HackStudioWidget::open_file(const String& full_filename, size_t line, size_t column) { String filename = full_filename; if (full_filename.starts_with(project().root_path())) { @@ -298,6 +298,7 @@ bool HackStudioWidget::open_file(const String& full_filename) current_editor().on_cursor_change = [this] { update_statusbar(); }; current_editor_wrapper().on_change = [this] { update_gml_preview(); }; + current_editor().set_cursor(line, column); update_gml_preview(); return true; diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index b690676e5e..c58e96cf35 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -34,7 +34,8 @@ class HackStudioWidget : public GUI::Widget { public: virtual ~HackStudioWidget() override; - bool open_file(const String& filename); + + bool open_file(String const& filename, size_t line = 0, size_t column = 0); void close_file_in_all_editors(String const& filename); void update_actions(); diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index e08df5dd02..1dd3b21636 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -132,8 +132,7 @@ void open_file(const String& filename) void open_file(const String& filename, size_t line, size_t column) { - s_hack_studio_widget->open_file(filename); - s_hack_studio_widget->current_editor_wrapper().editor().set_cursor({ line, column }); + s_hack_studio_widget->open_file(filename, line, column); } RefPtr current_editor_wrapper()