HackStudio: Jump to file location when choosing a Locator suggestion

A couple of tweaks here to make it work better:
- Call `set_cursor_and_focus_line()` to make the Editor scroll to the
  symbol's location.
- Remove focus from the Locator's text box so your cursor jumps to the
  Editor instead of staying in the Locator.
This commit is contained in:
Sam Atkins 2024-01-19 12:56:05 +00:00 committed by Sam Atkins
parent 9322f0d110
commit d30f13a88d
2 changed files with 3 additions and 2 deletions

View file

@ -318,7 +318,7 @@ bool HackStudioWidget::open_file(ByteString const& full_filename, size_t line, s
if (editor_wrapper_or_none.has_value()) {
set_current_editor_wrapper(editor_wrapper_or_none.release_value());
current_editor().set_cursor(line, column);
current_editor().set_cursor_and_focus_line(line, column);
return true;
} else if (active_file().is_empty() && !current_editor().document().is_modified() && !full_filename.is_empty()) {
// Replace "Untitled" blank file since it hasn't been modified
@ -384,7 +384,7 @@ bool HackStudioWidget::open_file(ByteString const& full_filename, size_t line, s
current_editor().on_cursor_change = [this] { on_cursor_change(); };
current_editor().on_change = [this] { update_window_title(); };
current_editor_wrapper().on_change = [this] { update_gml_preview(); };
current_editor().set_cursor(line, column);
current_editor().set_cursor_and_focus_line(line, column);
update_gml_preview();
return true;

View file

@ -184,6 +184,7 @@ void Locator::open()
void Locator::close()
{
m_popup_window->hide();
m_textbox->set_focus(false);
}
void Locator::update_suggestions()