From 16a91f8e3c0aa7276118213da77a8bdf3b676d6c Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 28 Nov 2025 19:03:07 +0100 Subject: [PATCH] Fix regression interpreting prompt y on multiline commandlines Fixes a772470b76e (Multi-line autosuggestions, 2025-05-18) Fixes #12121 --- CHANGELOG.rst | 1 + src/screen.rs | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 49022524f..5267bf755 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -25,6 +25,7 @@ Regression fixes: ----------------- - (from 4.1.0) Crash on invalid colors variables (:issue:`12078`). - (from 4.2.0) Incorrect emoji width computation on macOS. +- (from 4.2.0) Mouse clicks and :kbd:`ctrl-l` edge cases in multiline commandlines (:issue:`12121`). fish 4.2.1 (released November 13, 2025) ======================================= diff --git a/src/screen.rs b/src/screen.rs index d9ba50bf4..4254fd9bf 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -564,12 +564,10 @@ pub fn reset_line(&mut self, repaint_prompt: bool /* = false */) { } pub fn push_to_scrollback(&mut self) { - let Some(viewport_cursor_y) = self.viewport_y else { + let Some(lines_to_scroll) = self.viewport_y else { return; }; FLOG!(reader, "Pushing to scrollback"); - let lines_to_scroll = self.command_line_y_given_cursor_y(viewport_cursor_y); - self.set_position_in_viewport("scrollback-push", Some(0)); if lines_to_scroll == 0 { return; } @@ -578,6 +576,7 @@ pub fn push_to_scrollback(&mut self) { out.write_command(ScrollContentUp(lines_to_scroll)); // Reposition cursor. out.write_command(CursorMove(CardinalDirection::Up, lines_to_scroll)); + self.set_position_in_viewport("scrollback-push", Some(0)); } pub fn set_position_in_viewport(&mut self, whence: &str, viewport_y: Option) { @@ -631,17 +630,16 @@ pub fn offset_in_cmdline_given_cursor( let Some(viewport_y) = self.viewport_y else { return CharOffset::None; }; - let viewport_prompt_y = self.command_line_y_given_cursor_y(viewport_y); let y = viewport_position .y - .checked_sub(viewport_prompt_y) + .checked_sub(viewport_y) .unwrap_or_else(|| { FLOG!( reader, "Given y", viewport_position.y, "exceeds the prompt's y", - viewport_prompt_y, + viewport_y, "inferred from reported cursor position", ); 0