Fix bug where breakpoints were unable to be toggled on the first line

This commit is contained in:
Anthony Eid
2024-09-12 11:04:27 -04:00
parent ed6da4a7f6
commit 571d99cecf
2 changed files with 17 additions and 2 deletions

View File

@@ -6228,6 +6228,15 @@ impl Editor {
pub fn toggle_breakpoint(&mut self, _: &ToggleBreakpoint, cx: &mut ViewContext<Self>) {
let cursor_position: Point = self.selections.newest(cx).head();
// Bias is set to right when placing a breakpoint on the first row
// to avoid having the breakpoint's anchor be anchor::MIN & having
// it's buffer_id be None
let bias = if cursor_position.row == 0 {
Bias::Right
} else {
Bias::Left
};
// We Set the column position to zero so this function interacts correctly
// between calls by clicking on the gutter & using an action to toggle a
// breakpoint. Otherwise, toggling a breakpoint through an action wouldn't
@@ -6236,7 +6245,7 @@ impl Editor {
.snapshot(cx)
.display_snapshot
.buffer_snapshot
.anchor_before(Point::new(cursor_position.row, 0))
.anchor_at(Point::new(cursor_position.row, 0), bias)
.text_anchor;
self.toggle_breakpoint_at_anchor(breakpoint_position, cx);

View File

@@ -1610,9 +1610,15 @@ impl EditorElement {
return None;
}
let bias = if point.is_zero() {
Bias::Right
} else {
Bias::Left
};
let position = snapshot
.display_snapshot
.display_point_to_anchor(*point, Bias::Left)
.display_point_to_anchor(*point, bias)
.text_anchor;
let button = editor.render_breakpoint(position, point.row(), cx);