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(); }