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.
This commit is contained in:
Smit Barmase 2025-03-10 15:03:07 +00:00 committed by GitHub
parent a4462577bf
commit 5f159bc95e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -152,7 +152,10 @@ impl GoToLine {
cx: &mut Context<Self>,
) {
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),
_ => {}
}