debugger - move caret and scroll to stopped events

This commit is contained in:
Matt Parker
2026-01-21 01:50:37 +10:00
parent 2c65ed0818
commit ccee457dff
2 changed files with 10 additions and 9 deletions

View File

@@ -169,15 +169,16 @@ public partial class CodeEditorPanel : MarginContainer
{ {
Guard.Against.Null(Solution, nameof(Solution)); Guard.Against.Null(Solution, nameof(Solution));
var currentSharpIdeFile = await this.InvokeAsync<SharpIdeFile>(() => _tabContainer.GetChild<SharpIdeCodeEdit>(_tabContainer.CurrentTab).SharpIdeFile);
if (executionStopInfo.FilePath != currentSharpIdeFile?.Path)
{
var file = Solution.AllFiles[executionStopInfo.FilePath];
await GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelAsync(file, null).ConfigureAwait(false);
}
var lineInt = executionStopInfo.Line - 1; // Debugging is 1-indexed, Godot is 0-indexed var lineInt = executionStopInfo.Line - 1; // Debugging is 1-indexed, Godot is 0-indexed
Guard.Against.Negative(lineInt, nameof(lineInt)); Guard.Against.Negative(lineInt);
var file = Solution.AllFiles[executionStopInfo.FilePath];
// A line being darkened by the caret being on that line completely obscures the executing line color, so as a "temporary" workaround, move the caret to the previous line
// Ideally, like Rider, we would only yellow highlight the sequence point range, with the cursor line black being behind it
var fileLinePosition = new SharpIdeFileLinePosition(lineInt is 0 ? 0 : lineInt - 1, 0);
// Although the file may already be the selected tab, we need to also move the caret
await GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelAsync(file, fileLinePosition).ConfigureAwait(false);
if (_debuggerExecutionStopInfoByProject.TryGetValue(executionStopInfo.Project, out _)) throw new InvalidOperationException("Debugger is already stopped for this project."); if (_debuggerExecutionStopInfoByProject.TryGetValue(executionStopInfo.Project, out _)) throw new InvalidOperationException("Debugger is already stopped for this project.");
_debuggerExecutionStopInfoByProject[executionStopInfo.Project] = executionStopInfo; _debuggerExecutionStopInfoByProject[executionStopInfo.Project] = executionStopInfo;

View File

@@ -278,7 +278,7 @@ public partial class SharpIdeCodeEdit : CodeEdit
Callable.From(() => Callable.From(() =>
{ {
GrabFocus(); GrabFocus();
CenterViewportToCaret(); AdjustViewportToCaret();
}).CallDeferred(); }).CallDeferred();
} }