From 5f159bc95ed1f52f2bda35fdc897b763d38f1304 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Mon, 10 Mar 2025 15:03:07 +0000 Subject: [PATCH] go_to_line: Fix goto line + mouse click jumps to previous scroll position (#26362) Closes #20658 Now, when the "Go to Line" palette is open: - Clicking on the editor will dismiss the palette without changing the scroll position. (PR change) - Pressing Enter will jump to the line number entered in the palette. (Unchanged) - Pressing Escape will jump back to the previous cursor location. (Unchanged) Release Notes: - Fixed an issue where clicking the editor with the mouse while the "Go to Line" palette is open would cause it to jump to the previous scroll position. --- crates/go_to_line/src/go_to_line.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/go_to_line/src/go_to_line.rs b/crates/go_to_line/src/go_to_line.rs index 7b9ee6780e..8a6294ab88 100644 --- a/crates/go_to_line/src/go_to_line.rs +++ b/crates/go_to_line/src/go_to_line.rs @@ -152,7 +152,10 @@ impl GoToLine { cx: &mut Context, ) { match event { - editor::EditorEvent::Blurred => cx.emit(DismissEvent), + editor::EditorEvent::Blurred => { + self.prev_scroll_position.take(); + cx.emit(DismissEvent) + } editor::EditorEvent::BufferEdited { .. } => self.highlight_current_line(cx), _ => {} }