optimize<HighlightableTextBlock>: using Run instead of TextBlock to improve performance

This commit is contained in:
leo 2021-10-27 16:17:54 +08:00
parent 460f8715da
commit 898599afc9

View file

@ -1,4 +1,4 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media; 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 Run(txt.Data.Content.Substring(started, highlight.Start - started)));
} }
txt.Inlines.Add(new TextBlock() { txt.Inlines.Add(new Run() {
Background = highlightBrush, Background = highlightBrush,
LineHeight = txt.LineHeight,
Text = txt.Data.Content.Substring(highlight.Start, highlight.Count), Text = txt.Data.Content.Substring(highlight.Start, highlight.Count),
}); });