summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-09-07 00:26:28 +0430
committerAndreas Kling <kling@serenityos.org>2020-09-07 11:42:56 +0200
commitda56e208ef611f95d95685a564a1ec39dde87aaf (patch)
tree3ba265bc76eea7970b3934f29484b80d1b7d2d31
parente8131f503d5f1f2026ea067c27a37850b7831c43 (diff)
downloadserenity-da56e208ef611f95d95685a564a1ec39dde87aaf.zip
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.
-rw-r--r--Libraries/LibLine/InternalFunctions.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/Libraries/LibLine/InternalFunctions.cpp b/Libraries/LibLine/InternalFunctions.cpp
index f949ef2053..5802492f28 100644
--- a/Libraries/LibLine/InternalFunctions.cpp
+++ b/Libraries/LibLine/InternalFunctions.cpp
@@ -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();