set line background on breakpoint

This commit is contained in:
Matt Parker
2025-08-25 21:38:47 +10:00
parent ef46c94b30
commit eac1f59e30
3 changed files with 9 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
extends Node2D
extends Control
# Declare an empty dictionary object
var game = {}
@@ -12,7 +12,7 @@ func _ready():
"energy": 67
}
if game.empty():
if game.is_empty():
# Add data to the game dictionary
game["player"] = player
game["score"] = 0

View File

@@ -184,6 +184,7 @@ highlight_current_line = true
symbol_lookup_on_click = true
symbol_tooltip_on_hover = true
gutters_draw_breakpoints_gutter = true
gutters_draw_executing_lines = true
gutters_draw_line_numbers = true
code_completion_enabled = true
auto_brace_completion_enabled = true

View File

@@ -54,19 +54,20 @@ public partial class SharpIdeCodeEdit : CodeEdit
{
var lineInt = (int)line;
var breakpointAdded = IsLineBreakpointed(lineInt);
lineInt++; // Godot is 0-indexed, Debugging is 1-indexed
Guard.Against.Negative(lineInt, nameof(lineInt));
var lineForDebugger = lineInt + 1; // Godot is 0-indexed, Debugging is 1-indexed
var breakpoints = Singletons.RunService.Breakpoints.GetOrAdd(_currentFile, []);
if (breakpointAdded)
{
breakpoints.Add(new Breakpoint { Line = lineInt } );
breakpoints.Add(new Breakpoint { Line = lineForDebugger } );
SetLineBackgroundColor(lineInt, new Color("3a2323"));
}
else
{
var breakpoint = breakpoints.Single(b => b.Line == lineInt);
var breakpoint = breakpoints.Single(b => b.Line == lineForDebugger);
breakpoints.Remove(breakpoint);
SetLineBackgroundColor(lineInt, Colors.Transparent);
}
GD.Print($"Breakpoint {(breakpointAdded ? "added" : "removed")} at line {lineInt}");
GD.Print($"Breakpoint {(breakpointAdded ? "added" : "removed")} at line {lineForDebugger}");
}
private void OnSymbolLookup(string symbol, long line, long column)