Skip to content

Commit 81d2f18

Browse files
committed
handle no selected file from AppState
1 parent 3039559 commit 81d2f18

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/SharpIDE.Godot/IdeRoot.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ await this.InvokeDeferredAsync(async () =>
186186
_navigationHistoryService.StartRecording();
187187
// Select the selected tab
188188
var selectedFile = filesToOpen.SingleOrDefault(f => f.isSelected);
189+
// If no tab was selected, select the last one (if any) - occurs e.g. when the user last had a decompiled file open, which we currently don't persist to disk, meaning that all other file will have isSelected false
190+
if (selectedFile.file is null)
191+
{
192+
var firstTab = filesToOpen.LastOrDefault();
193+
if (firstTab.file is not null) selectedFile = firstTab;
194+
}
189195
if (selectedFile.file is not null) await GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelAsync(selectedFile.file, selectedFile.linePosition);
190196
});
191197

0 commit comments

Comments
 (0)