display file icon in tab

This commit is contained in:
Matt Parker
2025-11-29 13:40:53 +10:00
parent e912a93ba8
commit 934f0bcdde

View File

@@ -8,6 +8,7 @@ using SharpIDE.Application.Features.Run;
using SharpIDE.Application.Features.SolutionDiscovery;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
using SharpIDE.Godot.Features.IdeSettings;
using SharpIDE.Godot.Features.SolutionExplorer;
namespace SharpIDE.Godot.Features.CodeEditor;
@@ -98,7 +99,7 @@ public partial class CodeEditorPanel : MarginContainer
{
_tabContainer.AddChild(newTab);
var newTabIndex = _tabContainer.GetTabCount() - 1;
_tabContainer.SetTabIcon(newTabIndex, CsFileTexture);
_tabContainer.SetIconsForFileExtension(file, newTabIndex);
_tabContainer.SetTabTitle(newTabIndex, file.Name);
_tabContainer.SetTabTooltip(newTabIndex, file.Path);
_tabContainer.CurrentTab = newTabIndex;
@@ -155,4 +156,19 @@ public partial class CodeEditorPanel : MarginContainer
await _runService.SendDebuggerStepOver(threadId);
});
}
}
file static class TabContainerExtensions
{
extension(TabContainer tabContainer)
{
public void SetIconsForFileExtension(SharpIdeFile file, int newTabIndex)
{
var (icon, overlayIcon) = FileIconHelper.GetIconForFileExtension(file.Extension);
tabContainer.SetTabIcon(newTabIndex, icon);
// Unfortunately TabContainer doesn't have a SetTabIconOverlay method
//tabContainer.SetIconOverlay(0, overlayIcon);
}
}
}