From caf301f3f5e6d6bec71622b9d6c7c68e195bbfef Mon Sep 17 00:00:00 2001 From: ema Date: Sun, 29 Jun 2025 06:36:05 +0800 Subject: [PATCH] Refactor property key highlighting logic --- .../Dark/PropertiesHighlightingDefinition.cs | 20 ++++++++----------- .../Light/PropertiesHighlightingDefinition.cs | 20 ++++++++----------- 2 files changed, 16 insertions(+), 24 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 dd98e26..c5bafe1 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Dark/PropertiesHighlightingDefinition.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Dark/PropertiesHighlightingDefinition.cs @@ -67,19 +67,15 @@ public class PropertiesHighlightingDefinition : DarkHighlightingDefinition { var text = CurrentContext.Document.GetText(line); - if (!text.TrimStart().StartsWith("#")) - { - int idx = text.IndexOf('='); + if (text.TrimStart().StartsWith("#")) + return; - if (idx > 0) - { - ChangeLinePart( - line.Offset, - line.Offset + idx, - el => el.TextRunProperties.SetForegroundBrush("#3F9CD6".ToBrush()) - ); - } - } + int idx = text.IndexOf('='); + + if (idx <= 0) + return; + + 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 e5c2630..d98f951 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Light/PropertiesHighlightingDefinition.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.TextViewer/Themes/HighlightingDefinitions/Light/PropertiesHighlightingDefinition.cs @@ -68,19 +68,15 @@ public class PropertiesHighlightingDefinition : LightHighlightingDefinition { var text = CurrentContext.Document.GetText(line); - if (!text.TrimStart().StartsWith("#")) - { - int idx = text.IndexOf('='); + if (text.TrimStart().StartsWith("#")) + return; - if (idx > 0) - { - ChangeLinePart( - line.Offset, - line.Offset + idx, - el => el.TextRunProperties.SetForegroundBrush(Colors.Blue.ToBrush()) - ); - } - } + int idx = text.IndexOf('='); + + if (idx <= 0) + return; + + ChangeLinePart(line.Offset, line.Offset + idx, el => el.TextRunProperties.SetForegroundBrush(Colors.Blue.ToBrush())); } } }