Browse Source

LibLine: Be less lazy when moving prompt origin row

Fixes the issue where adding multiple lines in one refresh cycle would
break cursor positioning.
AnotherTest 4 years ago
parent
commit
5e6b9cbc91
1 changed files with 7 additions and 7 deletions
  1. 7 7
      Libraries/LibLine/Editor.cpp

+ 7 - 7
Libraries/LibLine/Editor.cpp

@@ -1036,13 +1036,6 @@ void Editor::refresh_display()
         }
         m_was_resized = false;
     }
-    // Do not call hook on pure cursor movement.
-    if (m_cached_prompt_valid && !m_refresh_needed && m_pending_chars.size() == 0) {
-        // Probably just moving around.
-        reposition_cursor();
-        m_cached_buffer_metrics = actual_rendered_string_metrics(buffer_view());
-        return;
-    }
     // We might be at the last line, and have more than one line;
     // Refreshing the display will cause the terminal to scroll,
     // so note that fact and bring origin up.
@@ -1053,6 +1046,13 @@ void Editor::refresh_display()
         else
             m_origin_row = m_num_lines - current_num_lines + 1;
     }
+    // Do not call hook on pure cursor movement.
+    if (m_cached_prompt_valid && !m_refresh_needed && m_pending_chars.size() == 0) {
+        // Probably just moving around.
+        reposition_cursor();
+        m_cached_buffer_metrics = actual_rendered_string_metrics(buffer_view());
+        return;
+    }
 
     if (on_display_refresh)
         on_display_refresh(*this);