diff --git a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs index fc55fc7..6962ff9 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs @@ -74,17 +74,19 @@ public partial class CodeEditorPanel : MarginContainer _tabContainer.SetTabTitle(newTabIndex, file.Name); _tabContainer.SetTabTooltip(newTabIndex, file.Path); _tabContainer.CurrentTab = newTabIndex; - }); - file.IsDirty.Skip(1).SubscribeOnThreadPool().SubscribeAwait(async (isDirty, ct) => - { - //GD.Print($"File dirty state changed: {file.Path} is now {(isDirty ? "dirty" : "clean")}"); - await this.InvokeAsync(() => + + file.IsDirty.Skip(1).SubscribeOnThreadPool().SubscribeAwait(async (isDirty, ct) => { - var tabIndex = newTab.GetIndex(); - var title = file.Name + (isDirty ? " (*)" : ""); - _tabContainer.SetTabTitle(tabIndex, title); - }); + //GD.Print($"File dirty state changed: {file.Path} is now {(isDirty ? "dirty" : "clean")}"); + await this.InvokeAsync(() => + { + var tabIndex = newTab.GetIndex(); + var title = file.Name + (isDirty ? " (*)" : ""); + _tabContainer.SetTabTitle(tabIndex, title); + }); + }).AddTo(newTab); // needs to be on ui thread }); + await newTab.SetSharpIdeFile(file); if (fileLinePosition is not null) await this.InvokeAsync(() => newTab.SetFileLinePosition(fileLinePosition.Value)); }