From e113030dceb516438db57a16e0b429a5bf994517 Mon Sep 17 00:00:00 2001 From: ema Date: Fri, 27 Jun 2025 22:49:28 +0800 Subject: [PATCH] Skip primary for comment lines in properties files --- .../Dark/PropertiesHighlightingDefinition.cs | 17 +++++++++++------ .../Light/PropertiesHighlightingDefinition.cs | 19 ++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Dark/PropertiesHighlightingDefinition.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Dark/PropertiesHighlightingDefinition.cs index 4eed277..dd98e26 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Dark/PropertiesHighlightingDefinition.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Dark/PropertiesHighlightingDefinition.cs @@ -66,14 +66,19 @@ public class PropertiesHighlightingDefinition : DarkHighlightingDefinition protected override void ColorizeLine(DocumentLine line) { var text = CurrentContext.Document.GetText(line); - int idx = text.IndexOf('='); - if (idx > 0) + + if (!text.TrimStart().StartsWith("#")) { - ChangeLinePart( - line.Offset, - line.Offset + idx, + int idx = text.IndexOf('='); + + if (idx > 0) + { + ChangeLinePart( + line.Offset, + line.Offset + idx, el => el.TextRunProperties.SetForegroundBrush("#3F9CD6".ToBrush()) - ); + ); + } } } } diff --git a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Light/PropertiesHighlightingDefinition.cs b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Light/PropertiesHighlightingDefinition.cs index 38afc09..e5c2630 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Light/PropertiesHighlightingDefinition.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Light/PropertiesHighlightingDefinition.cs @@ -67,14 +67,19 @@ public class PropertiesHighlightingDefinition : LightHighlightingDefinition protected override void ColorizeLine(DocumentLine line) { var text = CurrentContext.Document.GetText(line); - int idx = text.IndexOf('='); - if (idx > 0) + + if (!text.TrimStart().StartsWith("#")) { - ChangeLinePart( - line.Offset, - line.Offset + idx, - el => el.TextRunProperties.SetForegroundBrush(Colors.Blue.ToBrush()) - ); + int idx = text.IndexOf('='); + + if (idx > 0) + { + ChangeLinePart( + line.Offset, + line.Offset + idx, + el => el.TextRunProperties.SetForegroundBrush(Colors.Blue.ToBrush()) + ); + } } } }