Debugger: Fix breakpoint serialization (#27825)
This PR fixes two bugs that cause unexpected behavior with breakpoints. The first bug made it impossible to delete the last breakpoint in a file in the workspace's database. This caused deleted breakpoints to remain in the database and added to new projects. The second bug was an edge case in the breakpoint context menu where disabling/enabling a breakpoint would sometimes set a new breakpoint on top of the old breakpoint. Release Notes: - N/A
This commit is contained in:
+15
-12
@@ -6249,7 +6249,7 @@ impl Editor {
|
||||
/// It's also used to set the color of line numbers with breakpoints to the breakpoint color.
|
||||
/// TODO debugger: Use this function to color toggle symbols that house nested breakpoints
|
||||
fn active_breakpoints(
|
||||
&mut self,
|
||||
&self,
|
||||
range: Range<DisplayRow>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
@@ -6320,24 +6320,26 @@ impl Editor {
|
||||
|
||||
let breakpoint = self
|
||||
.breakpoint_at_row(row, window, cx)
|
||||
.map(|(_, bp)| Arc::from(bp));
|
||||
.map(|(anchor, bp)| (anchor, Arc::from(bp)));
|
||||
|
||||
let log_breakpoint_msg = if breakpoint.as_ref().is_some_and(|bp| bp.message.is_some()) {
|
||||
let log_breakpoint_msg = if breakpoint.as_ref().is_some_and(|bp| bp.1.message.is_some()) {
|
||||
"Edit Log Breakpoint"
|
||||
} else {
|
||||
"Set Log Breakpoint"
|
||||
};
|
||||
|
||||
let condition_breakpoint_msg =
|
||||
if breakpoint.as_ref().is_some_and(|bp| bp.condition.is_some()) {
|
||||
"Edit Condition Breakpoint"
|
||||
} else {
|
||||
"Set Condition Breakpoint"
|
||||
};
|
||||
let condition_breakpoint_msg = if breakpoint
|
||||
.as_ref()
|
||||
.is_some_and(|bp| bp.1.condition.is_some())
|
||||
{
|
||||
"Edit Condition Breakpoint"
|
||||
} else {
|
||||
"Set Condition Breakpoint"
|
||||
};
|
||||
|
||||
let hit_condition_breakpoint_msg = if breakpoint
|
||||
.as_ref()
|
||||
.is_some_and(|bp| bp.hit_condition.is_some())
|
||||
.is_some_and(|bp| bp.1.hit_condition.is_some())
|
||||
{
|
||||
"Edit Hit Condition Breakpoint"
|
||||
} else {
|
||||
@@ -6350,12 +6352,13 @@ impl Editor {
|
||||
"Set Breakpoint"
|
||||
};
|
||||
|
||||
let toggle_state_msg = breakpoint.as_ref().map_or(None, |bp| match bp.state {
|
||||
let toggle_state_msg = breakpoint.as_ref().map_or(None, |bp| match bp.1.state {
|
||||
BreakpointState::Enabled => Some("Disable"),
|
||||
BreakpointState::Disabled => Some("Enable"),
|
||||
});
|
||||
|
||||
let breakpoint = breakpoint.unwrap_or_else(|| Arc::new(Breakpoint::new_standard()));
|
||||
let (anchor, breakpoint) =
|
||||
breakpoint.unwrap_or_else(|| (anchor, Arc::new(Breakpoint::new_standard())));
|
||||
|
||||
ui::ContextMenu::build(window, cx, |menu, _, _cx| {
|
||||
menu.on_blur_subscription(Subscription::new(|| {}))
|
||||
|
||||
Reference in New Issue
Block a user