From e03edc2a768aa03a85c82d92441cd9134b145879 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 19 Mar 2025 18:40:31 +0100 Subject: [PATCH] debugger: Do not allow setting breakpoints in buffers without file storage (#27094) Closes #ISSUE Release Notes: - N/A --- crates/editor/src/editor.rs | 3 +++ crates/editor/src/element.rs | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 786d6c60d74101cce638de7d6cf962135dcc82a1..90f82ba45887a456517b7e5ff4be48afcb390645 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -6052,6 +6052,9 @@ impl Editor { continue; }; + if buffer.read(cx).file().is_none() { + continue; + } let breakpoints = breakpoint_store.read(cx).breakpoints( &buffer, Some(info.range.context.start..info.range.context.end), diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 5947b48ba9ac89544ee16d7e156f3ff09fef6962..c1fe9182dee4201522fc06c198d53dad2f9cd879 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -890,15 +890,24 @@ impl EditorElement { let modifiers = event.modifiers; let gutter_hovered = gutter_hitbox.is_hovered(window); editor.set_gutter_hovered(gutter_hovered, cx); + editor.gutter_breakpoint_indicator = None; if gutter_hovered { - editor.gutter_breakpoint_indicator = Some( - position_map - .point_for_position(event.position) - .previous_valid, - ); - } else { - editor.gutter_breakpoint_indicator = None; + let new_point = position_map + .point_for_position(event.position) + .previous_valid; + let buffer_anchor = position_map + .snapshot + .display_point_to_anchor(new_point, Bias::Left); + + if position_map + .snapshot + .buffer_snapshot + .buffer_for_excerpt(buffer_anchor.excerpt_id) + .is_some_and(|buffer| buffer.file().is_some()) + { + editor.gutter_breakpoint_indicator = Some(new_point); + } } cx.notify();