diff --git a/Source/Editor/GUI/ItemsListContextMenu.cs b/Source/Editor/GUI/ItemsListContextMenu.cs index 4084715fe..78fbcd779 100644 --- a/Source/Editor/GUI/ItemsListContextMenu.cs +++ b/Source/Editor/GUI/ItemsListContextMenu.cs @@ -23,9 +23,6 @@ namespace FlaxEditor.GUI [HideInEditor] public class Item : Control { - private bool _isStartsWithMatch; - private bool _isFullMatch; - /// /// The is mouse down flag. /// @@ -46,11 +43,6 @@ namespace FlaxEditor.GUI /// public string Category; - /// - /// A computed score for the context menu order - /// - public float SortScore; - /// /// Occurs when items gets clicked by the user. /// @@ -69,69 +61,44 @@ namespace FlaxEditor.GUI { } - /// - /// Updates the - /// - public void UpdateScore() - { - SortScore = 0; - - if(!Visible) - return; - - if (_highlights is { Count: > 0 }) - SortScore += 1; - if (_isStartsWithMatch) - SortScore += 2; - if (_isFullMatch) - SortScore += 5; - } - /// /// Updates the filter. /// /// The filter text. public void UpdateFilter(string filterText) { - _isStartsWithMatch = _isFullMatch = false; - if (string.IsNullOrWhiteSpace(filterText)) { // Clear filter _highlights?.Clear(); Visible = true; - return; } - - if (QueryFilterHelper.Match(filterText, Name, out var ranges)) + else { - // Update highlights - if (_highlights == null) - _highlights = new List(ranges.Length); - else - _highlights.Clear(); - var style = Style.Current; - var font = style.FontSmall; - for (int i = 0; i < ranges.Length; i++) + if (QueryFilterHelper.Match(filterText, Name, out var ranges)) { - var start = font.GetCharPosition(Name, ranges[i].StartIndex); - var end = font.GetCharPosition(Name, ranges[i].EndIndex); - _highlights.Add(new Rectangle(start.X + 2, 0, end.X - start.X, Height)); - - if (ranges[i].StartIndex <= 0) + // Update highlights + if (_highlights == null) + _highlights = new List(ranges.Length); + else + _highlights.Clear(); + var style = Style.Current; + var font = style.FontSmall; + for (int i = 0; i < ranges.Length; i++) { - _isStartsWithMatch = true; - if (ranges[i].Length == Name.Length) - _isFullMatch = true; + var start = font.GetCharPosition(Name, ranges[i].StartIndex); + var end = font.GetCharPosition(Name, ranges[i].EndIndex); + _highlights.Add(new Rectangle(start.X + 2, 0, end.X - start.X, Height)); } + Visible = true; + } + else + { + // Hide + _highlights?.Clear(); + Visible = false; } - Visible = true; - return; } - - // Hide - _highlights?.Clear(); - Visible = false; } /// @@ -211,14 +178,7 @@ namespace FlaxEditor.GUI public override int Compare(Control other) { if (other is Item otherItem) - { - int order = -1 * SortScore.CompareTo(otherItem.SortScore); - if (order == 0) - { - order = string.Compare(Name, otherItem.Name, StringComparison.Ordinal); - } - return order; - } + return string.Compare(Name, otherItem.Name, StringComparison.Ordinal); return base.Compare(other); } } @@ -289,10 +249,7 @@ namespace FlaxEditor.GUI for (int i = 0; i < items.Count; i++) { if (items[i] is Item item) - { item.UpdateFilter(_searchBox.Text); - item.UpdateScore(); - } } if (_categoryPanels != null) { @@ -305,7 +262,6 @@ namespace FlaxEditor.GUI if (category.Children[j] is Item item2) { item2.UpdateFilter(_searchBox.Text); - item2.UpdateScore(); anyVisible |= item2.Visible; } } @@ -317,8 +273,6 @@ namespace FlaxEditor.GUI } } - SortItems(); - UnlockChildrenRecursive(); PerformLayout(true); _searchBox.Focus();