Quellcode durchsuchen

LibLine: Take the prompt into account when adjusting for a scrolled view

Otherwise we'd end up putting the prompt *after* the previous prompt
instead of *over* it when showing suggestions that span more lines than
are available without scrolling.
Ali Mohammad Pur vor 3 Jahren
Ursprung
Commit
86e1d1e73d

+ 6 - 8
Userland/Libraries/LibLine/Editor.cpp

@@ -1121,17 +1121,15 @@ void Editor::handle_read_event()
                 break;
             }
 
-            if (m_times_tab_pressed > 1) {
-                if (m_suggestion_manager.count() > 0) {
-                    if (m_suggestion_display->cleanup())
-                        reposition_cursor(stderr_stream);
+            if (m_times_tab_pressed > 1 && m_suggestion_manager.count() > 0) {
+                if (m_suggestion_display->cleanup())
+                    reposition_cursor(stderr_stream);
 
-                    m_suggestion_display->set_initial_prompt_lines(m_prompt_lines_at_suggestion_initiation);
+                m_suggestion_display->set_initial_prompt_lines(m_prompt_lines_at_suggestion_initiation);
 
-                    m_suggestion_display->display(m_suggestion_manager);
+                m_suggestion_display->display(m_suggestion_manager);
 
-                    m_origin_row = m_suggestion_display->origin_row();
-                }
+                m_origin_row = m_suggestion_display->origin_row();
             }
 
             if (m_times_tab_pressed > 2) {

+ 3 - 0
Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp

@@ -126,6 +126,9 @@ void XtermSuggestionDisplay::display(const SuggestionManager& manager)
 
     m_lines_used_for_last_suggestions = lines_used;
 
+    // The last line of the prompt is the same line as the first line of the buffer, so we need to subtract one here.
+    lines_used += m_prompt_lines_at_suggestion_initiation - 1;
+
     // If we filled the screen, move back the origin.
     if (m_origin_row + lines_used >= m_num_lines) {
         m_origin_row = m_num_lines - lines_used;