From 38cdfdd147ad7f5bc34fe885b4e90c1b240f5f83 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Thu, 30 Oct 2025 00:36:27 +1000 Subject: [PATCH] improve navigation history via editor tab selection/closure --- .../Features/CodeEditor/CodeEditorPanel.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs index d489b8c..e3414f8 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs @@ -57,13 +57,23 @@ public partial class CodeEditorPanel : MarginContainer private void OnTabClicked(long tab) { - var sharpIdeFile = _tabContainer.GetChild((int)tab).SharpIdeFile; - GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(sharpIdeFile, null); + var sharpIdeCodeEdit = _tabContainer.GetChild((int)tab); + var sharpIdeFile = sharpIdeCodeEdit.SharpIdeFile; + var caretLinePosition = new SharpIdeFileLinePosition(sharpIdeCodeEdit.GetCaretLine(), sharpIdeCodeEdit.GetCaretColumn()); + GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(sharpIdeFile, caretLinePosition); } private void OnTabClosePressed(long tabIndex) { var tab = _tabContainer.GetChild((int)tabIndex); + var previousSibling = _tabContainer.GetChildOrNull((int)tabIndex - 1); + if (previousSibling is not null) + { + var sharpIdeFile = previousSibling.SharpIdeFile; + var caretLinePosition = new SharpIdeFileLinePosition(previousSibling.GetCaretLine(), previousSibling.GetCaretColumn()); + // This isn't actually necessary - closing a tab automatically selects the previous tab, however we need to do it to select the file in sln explorer, record navigation event etc + GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(sharpIdeFile, caretLinePosition); + } _tabContainer.RemoveChild(tab); tab.QueueFree(); }