From 898599afc9faf685958048d2823f6a50701cbac5 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 27 Oct 2021 16:17:54 +0800 Subject: [PATCH] optimize: using Run instead of TextBlock to improve performance --- src/Views/Controls/HighlightableTextBlock.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Views/Controls/HighlightableTextBlock.cs b/src/Views/Controls/HighlightableTextBlock.cs index f244a58d..849d3978 100644 --- a/src/Views/Controls/HighlightableTextBlock.cs +++ b/src/Views/Controls/HighlightableTextBlock.cs @@ -1,4 +1,4 @@ -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Media; @@ -69,9 +69,8 @@ namespace SourceGit.Views.Controls { txt.Inlines.Add(new Run(txt.Data.Content.Substring(started, highlight.Start - started))); } - txt.Inlines.Add(new TextBlock() { + txt.Inlines.Add(new Run() { Background = highlightBrush, - LineHeight = txt.LineHeight, Text = txt.Data.Content.Substring(highlight.Start, highlight.Count), });