From 8cc7c5d3d905270308e58ce0da2bfa0db979a5ee Mon Sep 17 00:00:00 2001 From: Nils Hausfeld Date: Thu, 26 Oct 2023 21:47:32 +0200 Subject: [PATCH] - Highlights get cleared now when there is no match - Highlights now give points, since it means there is a substring match - Cleanup --- .../Surface/ContextMenu/VisjectCMItem.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs b/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs index 41821c2aa..c6288f327 100644 --- a/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs +++ b/Source/Editor/Surface/ContextMenu/VisjectCMItem.cs @@ -80,6 +80,8 @@ namespace FlaxEditor.Surface.ContextMenu SortScore += 1; if (Data != null) SortScore += 1; + if (_highlights is { Count: > 0 }) + SortScore += 1; if (_isStartsWithMatch) SortScore += 2; if (_isFullMatch) @@ -185,9 +187,9 @@ namespace FlaxEditor.Surface.ContextMenu Visible = true; return; } - + GetTextRectangle(out var textRect); - + // Check archetype title if (QueryFilterHelper.Match(filterText, _archetype.Title, out var ranges)) { @@ -214,7 +216,7 @@ namespace FlaxEditor.Surface.ContextMenu Visible = true; return; } - + // Check archetype synonyms if (_archetype.AlternativeTitles!= null && _archetype.AlternativeTitles.Any(altTitle => QueryFilterHelper.Match(filterText, altTitle, out ranges))) { @@ -238,7 +240,7 @@ namespace FlaxEditor.Surface.ContextMenu Visible = true; return; } - + // Check archetype data (if it exists) if (NodeArchetype.TryParseText != null && NodeArchetype.TryParseText(filterText, out var data)) { @@ -257,13 +259,12 @@ namespace FlaxEditor.Surface.ContextMenu Data = data; return; } - - if (groupHeaderMatches) - return; - - // Hide + _highlights?.Clear(); - Visible = false; + + // Hide + if (!groupHeaderMatches) + Visible = false; } /// @@ -296,7 +297,7 @@ namespace FlaxEditor.Surface.ContextMenu } // Draw name - Render2D.DrawText(style.FontSmall, _archetype.Title + "(" + SortScore + ")", textRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center); + Render2D.DrawText(style.FontSmall, _archetype.Title, textRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center); if (_archetype.SubTitle != null) { var titleLength = style.FontSmall.MeasureText(_archetype.Title).X;