mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibLine: Disable editing events while searching
This also makes the editor clean as many lines as the searching took, for instance, in the case of <C-r><C-c>ls<tab>, two lines should be cleaned, not just one. Fixes #3413.
This commit is contained in:
parent
e8131f503d
commit
da56e208ef
Notes:
sideshowbarker
2024-07-19 02:51:23 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/da56e208ef6 Pull-request: https://github.com/SerenityOS/serenity/pull/3415 Issue: https://github.com/SerenityOS/serenity/issues/3413
1 changed files with 9 additions and 1 deletions
|
@ -302,11 +302,19 @@ void Editor::enter_search()
|
|||
fflush(stderr);
|
||||
|
||||
auto search_prompt = "\x1b[32msearch:\x1b[0m ";
|
||||
|
||||
// While the search editor is active, we do not want editing events.
|
||||
m_is_editing = false;
|
||||
|
||||
auto search_string_result = m_search_editor->get_line(search_prompt);
|
||||
|
||||
// Grab where the search origin last was, anything up to this point will be cleared.
|
||||
auto search_end_row = m_search_editor->m_origin_row;
|
||||
|
||||
remove_child(*m_search_editor);
|
||||
m_search_editor = nullptr;
|
||||
m_is_searching = false;
|
||||
m_is_editing = true;
|
||||
m_search_offset = 0;
|
||||
|
||||
// Re-enable the notifier after discarding the search editor.
|
||||
|
@ -325,7 +333,7 @@ void Editor::enter_search()
|
|||
reposition_cursor();
|
||||
auto search_metrics = actual_rendered_string_metrics(search_string);
|
||||
auto metrics = actual_rendered_string_metrics(search_prompt);
|
||||
VT::clear_lines(0, metrics.lines_with_addition(search_metrics, m_num_columns));
|
||||
VT::clear_lines(0, metrics.lines_with_addition(search_metrics, m_num_columns) + search_end_row - m_origin_row - 1);
|
||||
|
||||
reposition_cursor();
|
||||
|
||||
|
|
Loading…
Reference in a new issue