diff --git a/AVALONIA_MIGRATION_CHECKLIST.md b/AVALONIA_MIGRATION_CHECKLIST.md index 7a15ba7cb..3c5cf4b6f 100644 --- a/AVALONIA_MIGRATION_CHECKLIST.md +++ b/AVALONIA_MIGRATION_CHECKLIST.md @@ -281,7 +281,7 @@ | Converter | Status | Description | |-----------|--------|-------------| -| HighlightTextConverter | :yellow_circle: Stub | Returns plain text, needs highlighting | +| HighlightTextConverter | :white_check_mark: Done | Bold gold highlighting for matched characters | | QuerySuggestionBoxConverter | :yellow_circle: Stub | Not implemented | | BoolToVisibilityConverter | :white_check_mark: Done | Boolean to visibility | | TextConverter | :x: Missing | Text transformations | diff --git a/Flow.Launcher.Avalonia/Converters/CommonConverters.cs b/Flow.Launcher.Avalonia/Converters/CommonConverters.cs index f0eccbccf..8592f37c7 100644 --- a/Flow.Launcher.Avalonia/Converters/CommonConverters.cs +++ b/Flow.Launcher.Avalonia/Converters/CommonConverters.cs @@ -57,7 +57,18 @@ public class HighlightTextConverter : IMultiValueConverter { var run = new Run(text); if (isHighlight) + { run.FontWeight = FontWeight.Bold; + // Try to get from resources, fallback to gold + if (Application.Current != null && Application.Current.TryGetResource("HighlightForegroundBrush", null, out var brush) && brush is IBrush b) + { + run.Foreground = b; + } + else + { + run.Foreground = new SolidColorBrush(Colors.Gold); + } + } return run; } } diff --git a/Flow.Launcher.Avalonia/Helper/TextBlockHelper.cs b/Flow.Launcher.Avalonia/Helper/TextBlockHelper.cs index 32ba97d6e..1fe9fe054 100644 --- a/Flow.Launcher.Avalonia/Helper/TextBlockHelper.cs +++ b/Flow.Launcher.Avalonia/Helper/TextBlockHelper.cs @@ -42,7 +42,8 @@ public static class TextBlockHelper { var newRun = new Run(run.Text) { - FontWeight = run.FontWeight + FontWeight = run.FontWeight, + Foreground = run.Foreground }; textBlock.Inlines?.Add(newRun); } diff --git a/Flow.Launcher.Avalonia/Themes/Resources.axaml b/Flow.Launcher.Avalonia/Themes/Resources.axaml index 29afcff9e..f6194dfe9 100644 --- a/Flow.Launcher.Avalonia/Themes/Resources.axaml +++ b/Flow.Launcher.Avalonia/Themes/Resources.axaml @@ -11,6 +11,7 @@ #999999 #333333 #30FFFFFF + #FFD700 @@ -19,5 +20,6 @@ + diff --git a/Flow.Launcher.Avalonia/ViewModel/ResultsViewModel.cs b/Flow.Launcher.Avalonia/ViewModel/ResultsViewModel.cs index 32bd7a16c..6467cb267 100644 --- a/Flow.Launcher.Avalonia/ViewModel/ResultsViewModel.cs +++ b/Flow.Launcher.Avalonia/ViewModel/ResultsViewModel.cs @@ -62,6 +62,21 @@ public partial class ResultsViewModel : ObservableObject, IDisposable r.Settings = _settings; } + // Update highlight data and score for items that will be kept by EditDiff. + // This is necessary because EditDiff reuses existing ResultViewModel instances + // based on Title+SubTitle equality, but highlight indices are query-specific. + // For example, "Chrome" highlighted for "chr" [0,1,2] vs "chrome" [0,1,2,3,4,5]. + var existingItems = _sourceList.Items.ToDictionary(r => (r.Title, r.SubTitle)); + foreach (var newItem in resultsList) + { + if (existingItems.TryGetValue((newItem.Title, newItem.SubTitle), out var existing)) + { + existing.TitleHighlightData = newItem.TitleHighlightData; + existing.SubTitleHighlightData = newItem.SubTitleHighlightData; + existing.Score = newItem.Score; + } + } + // EditDiff calculates minimal changes needed - items with same Title+SubTitle are kept _sourceList.EditDiff(resultsList, ResultViewModelComparer.Instance);