diff --git a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs index b38b730..f2f0ec8 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs @@ -169,15 +169,16 @@ public partial class CodeEditorPanel : MarginContainer { Guard.Against.Null(Solution, nameof(Solution)); - var currentSharpIdeFile = await this.InvokeAsync(() => _tabContainer.GetChild(_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 - 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."); _debuggerExecutionStopInfoByProject[executionStopInfo.Project] = executionStopInfo; diff --git a/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs b/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs index ecb06c2..d7ad9ea 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit.cs @@ -278,7 +278,7 @@ public partial class SharpIdeCodeEdit : CodeEdit Callable.From(() => { GrabFocus(); - CenterViewportToCaret(); + AdjustViewportToCaret(); }).CallDeferred(); }