From 83f0a367330c6236d7c06caffb67134d6e0f963d Mon Sep 17 00:00:00 2001 From: Tim Vermeulen Date: Sun, 12 Oct 2025 20:08:24 +0200 Subject: [PATCH] editor: Fix behavior of clickable line numbers navigation in multibuffer (#39447) Repro: - Open a multibuffer - Click on a line number to jump to the corresponding file - Click the back button - Click the forward button, nothing happens - Click the forward button again, now it works Double clicking the code to jump to the file (with `"double_click_in_multibuffer": "open"`) doesn't exhibit this bug, so I just changed the logic when clicking on a line number in a multibuffer to match that behavior. https://github.com/user-attachments/assets/31c0d64d-fdb8-44d6-b0f3-a337ca53de30 Release Notes: - Fixed bug that could cause navigation to break when clicking on a line number in a multibuffer --- crates/editor/src/element.rs | 57 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 92fd96d54e2ca2d1c352433ce81da99cd78878cd..df966d4b8611630d6415030ecb623298f56e421e 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -739,6 +739,35 @@ impl EditorElement { } } + if !is_singleton { + let display_row = (ScrollPixelOffset::from( + (event.position - gutter_hitbox.bounds.origin).y / position_map.line_height, + ) + position_map.scroll_position.y) as u32; + let multi_buffer_row = position_map + .snapshot + .display_point_to_point(DisplayPoint::new(DisplayRow(display_row), 0), Bias::Right) + .row; + if line_numbers + .get(&MultiBufferRow(multi_buffer_row)) + .and_then(|line_number| line_number.hitbox.as_ref()) + .is_some_and(|hitbox| hitbox.contains(&event.position)) + { + let line_offset_from_top = display_row - position_map.scroll_position.y as u32; + + editor.open_excerpts_common( + Some(JumpData::MultiBufferRow { + row: MultiBufferRow(multi_buffer_row), + line_offset_from_top, + }), + modifiers.alt, + window, + cx, + ); + cx.stop_propagation(); + return; + } + } + let position = point_for_position.previous_valid; if let Some(mode) = Editor::columnar_selection_mode(&modifiers, cx) { editor.select( @@ -776,34 +805,6 @@ impl EditorElement { ); } cx.stop_propagation(); - - if !is_singleton { - let display_row = (ScrollPixelOffset::from( - (event.position - gutter_hitbox.bounds.origin).y / position_map.line_height, - ) + position_map.scroll_position.y) as u32; - let multi_buffer_row = position_map - .snapshot - .display_point_to_point(DisplayPoint::new(DisplayRow(display_row), 0), Bias::Right) - .row; - if line_numbers - .get(&MultiBufferRow(multi_buffer_row)) - .and_then(|line_number| line_number.hitbox.as_ref()) - .is_some_and(|hitbox| hitbox.contains(&event.position)) - { - let line_offset_from_top = display_row - position_map.scroll_position.y as u32; - - editor.open_excerpts_common( - Some(JumpData::MultiBufferRow { - row: MultiBufferRow(multi_buffer_row), - line_offset_from_top, - }), - modifiers.alt, - window, - cx, - ); - cx.stop_propagation(); - } - } } fn mouse_right_down(