display icons in completions

This commit is contained in:
Matt Parker
2025-10-27 19:49:08 +10:00
parent 077cceac43
commit 9ce00b97a1
4 changed files with 52 additions and 26 deletions

View File

@@ -452,7 +452,8 @@ public partial class SharpIdeCodeEdit : CodeEdit
SymbolKind.Field => CodeCompletionKind.Member,
_ => CodeCompletionKind.PlainText
};
AddCodeCompletionOption(godotCompletionType, completionItem.DisplayText, completionItem.DisplayText, value: new RefCountedContainer<CompletionItem>(completionItem));
var icon = GetIconForSymbolKind(symbolKind);
AddCodeCompletionOption(godotCompletionType, completionItem.DisplayText, completionItem.DisplayText, icon: icon, value: new RefCountedContainer<CompletionItem>(completionItem));
}
// partially working - displays menu only when caret is what CodeEdit determines as valid
UpdateCodeCompletionOptions(true);

View File

@@ -0,0 +1,24 @@
using Godot;
using Microsoft.CodeAnalysis;
namespace SharpIDE.Godot.Features.CodeEditor;
public partial class SharpIdeCodeEdit
{
private readonly Texture2D _csharpMethodIcon = ResourceLoader.Load<Texture2D>("uid://b17p18ijhvsep");
private readonly Texture2D _csharpClassIcon = ResourceLoader.Load<Texture2D>("uid://b027uufaewitj");
private Texture2D? GetIconForSymbolKind(SymbolKind? symbolKind)
{
var texture = symbolKind switch
{
SymbolKind.Method => _csharpMethodIcon,
SymbolKind.NamedType => _csharpClassIcon,
//SymbolKind.Local => ,
//SymbolKind.Property => ,
//SymbolKind.Field => ,
_ => null
};
return texture;
}
}

View File

@@ -0,0 +1 @@
uid://daa1p18jx6lgd

View File

@@ -23,9 +23,9 @@
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:zoom="0.36468749"
inkscape:cx="-246.78664"
inkscape:cy="-157.66924"
inkscape:zoom="0.72937499"
inkscape:cx="268.72323"
inkscape:cy="572.40789"
inkscape:window-width="2560"
inkscape:window-height="1369"
inkscape:window-x="-8"
@@ -37,36 +37,36 @@
transform="matrix(1.0007541,0,0,0.96334492,-0.19807395,9.6729914)">
<path
style="fill:#403424;fill-opacity:1;stroke:#cea755;stroke-width:16.0783;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 184.70795,151.59145 187.36566,0"
style="fill:#403424;fill-opacity:1;stroke:#cea755;stroke-width:18.2675;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="M 176.72005,205.08565 H 389.59663"
id="path1"
sodipodi:nodetypes="cc" /><path
style="fill:none;fill-opacity:1;stroke:#cea755;stroke-width:20.0634;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 270.75724,158.53018 v 143.18643 l 101.31637,-1.47512"
style="fill:none;fill-opacity:1;stroke:#cea755;stroke-width:22.7951;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="m 274.48545,212.96912 v 162.68209 l 115.11118,-1.67596"
id="path2"
sodipodi:nodetypes="ccc" /><rect
style="fill:#403424;fill-opacity:1;stroke:#cea755;stroke-width:26.7609;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
style="fill:#403424;fill-opacity:1;stroke:#cea755;stroke-width:30.4046;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="rect1"
width="212.32658"
height="90.832863"
x="-70.075668"
y="152.38043"
ry="0.052403569"
width="241.23607"
height="103.20028"
x="-126.29682"
y="172.61281"
ry="0.059538618"
transform="matrix(0.70232098,-0.71186041,0.68460871,0.72891077,0,0)" /><rect
style="fill:#403424;fill-opacity:1;stroke:#cea755;stroke-width:20.0694;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
style="fill:#403424;fill-opacity:1;stroke:#cea755;stroke-width:22.802;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="rect1-8"
width="124.5406"
height="71.029877"
x="93.227089"
y="368.03781"
ry="0.040978782"
width="141.49753"
height="80.701004"
x="59.23584"
y="417.30453"
ry="0.04655828"
transform="matrix(0.69729101,-0.71678815,0.69231756,0.72159295,0,0)" /><rect
style="fill:#403424;fill-opacity:1;stroke:#cea755;stroke-width:20.0694;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
style="fill:#403424;fill-opacity:1;stroke:#cea755;stroke-width:22.802;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
id="rect1-8-1"
width="124.5406"
height="71.029877"
x="0.070390612"
y="480.65121"
ry="0.040978782"
width="141.49753"
height="80.701004"
x="-46.604679"
y="545.25085"
ry="0.04655828"
transform="matrix(0.69729101,-0.71678815,0.69231756,0.72159295,0,0)" /></g>
</svg>

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB