debugger: Fix bug where deleting a breakpoint could delete multiple breakpoints (#28562)
This PR fixes a bug when deleting a breakpoint with a (log, conditional, hit condition) message by removing the message. All breakpoints that contain that type of message were also deleted. Release Notes: - N/A
This commit is contained in:
parent
353ae2335b
commit
d4736a5427
2 changed files with 41 additions and 13 deletions
|
@ -8960,10 +8960,16 @@ impl Editor {
|
||||||
.map(|selection| {
|
.map(|selection| {
|
||||||
let cursor_position: Point = selection.head().to_point(&snapshot.buffer_snapshot);
|
let cursor_position: Point = selection.head().to_point(&snapshot.buffer_snapshot);
|
||||||
|
|
||||||
let breakpoint_position = snapshot
|
let breakpoint_position = self
|
||||||
.display_snapshot
|
.breakpoint_at_row(cursor_position.row, window, cx)
|
||||||
.buffer_snapshot
|
.map(|bp| bp.0)
|
||||||
.anchor_after(Point::new(cursor_position.row, 0));
|
.unwrap_or_else(|| {
|
||||||
|
snapshot
|
||||||
|
.display_snapshot
|
||||||
|
.buffer_snapshot
|
||||||
|
.anchor_after(Point::new(cursor_position.row, 0))
|
||||||
|
});
|
||||||
|
|
||||||
let breakpoint = self
|
let breakpoint = self
|
||||||
.breakpoint_at_anchor(breakpoint_position, &snapshot, cx)
|
.breakpoint_at_anchor(breakpoint_position, &snapshot, cx)
|
||||||
.map(|(anchor, breakpoint)| (anchor, Some(breakpoint)));
|
.map(|(anchor, breakpoint)| (anchor, Some(breakpoint)));
|
||||||
|
|
|
@ -6,6 +6,7 @@ use breakpoints_in_file::BreakpointsInFile;
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
use dap::client::SessionId;
|
use dap::client::SessionId;
|
||||||
use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, Subscription, Task};
|
use gpui::{App, AppContext, AsyncApp, Context, Entity, EventEmitter, Subscription, Task};
|
||||||
|
use itertools::Itertools;
|
||||||
use language::{Buffer, BufferSnapshot, proto::serialize_anchor as serialize_text_anchor};
|
use language::{Buffer, BufferSnapshot, proto::serialize_anchor as serialize_text_anchor};
|
||||||
use rpc::{
|
use rpc::{
|
||||||
AnyProtoClient, TypedEnvelope,
|
AnyProtoClient, TypedEnvelope,
|
||||||
|
@ -289,9 +290,16 @@ impl BreakpointStore {
|
||||||
breakpoint_set.breakpoints.push(breakpoint.clone());
|
breakpoint_set.breakpoints.push(breakpoint.clone());
|
||||||
}
|
}
|
||||||
} else if breakpoint.1.message.is_some() {
|
} else if breakpoint.1.message.is_some() {
|
||||||
breakpoint_set.breakpoints.retain(|(other_pos, other)| {
|
if let Some(position) = breakpoint_set
|
||||||
&breakpoint.0 != other_pos && other.message.is_none()
|
.breakpoints
|
||||||
})
|
.iter()
|
||||||
|
.find_position(|(pos, bp)| &breakpoint.0 == pos && bp == &breakpoint.1)
|
||||||
|
.map(|res| res.0)
|
||||||
|
{
|
||||||
|
breakpoint_set.breakpoints.remove(position);
|
||||||
|
} else {
|
||||||
|
log::error!("Failed to find position of breakpoint to delete")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BreakpointEditAction::EditHitCondition(hit_condition) => {
|
BreakpointEditAction::EditHitCondition(hit_condition) => {
|
||||||
|
@ -316,9 +324,16 @@ impl BreakpointStore {
|
||||||
breakpoint_set.breakpoints.push(breakpoint.clone());
|
breakpoint_set.breakpoints.push(breakpoint.clone());
|
||||||
}
|
}
|
||||||
} else if breakpoint.1.hit_condition.is_some() {
|
} else if breakpoint.1.hit_condition.is_some() {
|
||||||
breakpoint_set.breakpoints.retain(|(other_pos, other)| {
|
if let Some(position) = breakpoint_set
|
||||||
&breakpoint.0 != other_pos && other.hit_condition.is_none()
|
.breakpoints
|
||||||
})
|
.iter()
|
||||||
|
.find_position(|(pos, bp)| &breakpoint.0 == pos && bp == &breakpoint.1)
|
||||||
|
.map(|res| res.0)
|
||||||
|
{
|
||||||
|
breakpoint_set.breakpoints.remove(position);
|
||||||
|
} else {
|
||||||
|
log::error!("Failed to find position of breakpoint to delete")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BreakpointEditAction::EditCondition(condition) => {
|
BreakpointEditAction::EditCondition(condition) => {
|
||||||
|
@ -343,9 +358,16 @@ impl BreakpointStore {
|
||||||
breakpoint_set.breakpoints.push(breakpoint.clone());
|
breakpoint_set.breakpoints.push(breakpoint.clone());
|
||||||
}
|
}
|
||||||
} else if breakpoint.1.condition.is_some() {
|
} else if breakpoint.1.condition.is_some() {
|
||||||
breakpoint_set.breakpoints.retain(|(other_pos, other)| {
|
if let Some(position) = breakpoint_set
|
||||||
&breakpoint.0 != other_pos && other.condition.is_none()
|
.breakpoints
|
||||||
})
|
.iter()
|
||||||
|
.find_position(|(pos, bp)| &breakpoint.0 == pos && bp == &breakpoint.1)
|
||||||
|
.map(|res| res.0)
|
||||||
|
{
|
||||||
|
breakpoint_set.breakpoints.remove(position);
|
||||||
|
} else {
|
||||||
|
log::error!("Failed to find position of breakpoint to delete")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue