From ed5ebfaee7f912f054e9dc51e308a008885e1754 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 15 Dec 2020 13:44:32 +0800 Subject: [PATCH] fix: clear all editor grid lines before redraw --- src/UI/DiffViewer.xaml.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/UI/DiffViewer.xaml.cs b/src/UI/DiffViewer.xaml.cs index aa04b18c..30eaec63 100644 --- a/src/UI/DiffViewer.xaml.cs +++ b/src/UI/DiffViewer.xaml.cs @@ -91,7 +91,8 @@ namespace SourceGit.UI { sizeChange.Visibility = Visibility.Collapsed; noChange.Visibility = Visibility.Collapsed; - foreach (var editor in editors) editorContainer.Children.Remove(editor); + editorContainer.Children.Clear(); + editorLines.Children.Clear(); editors.Clear(); editorLines.Children.Clear(); @@ -193,6 +194,7 @@ namespace SourceGit.UI { editorContainer.Children.Add(editor); editors.Add(editor); + editorLines.ColumnDefinitions.Clear(); editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) }); editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) }); @@ -270,6 +272,7 @@ namespace SourceGit.UI { editors.Add(oldEditor); editors.Add(newEditor); + editorLines.ColumnDefinitions.Clear(); editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) }); editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) }); @@ -608,7 +611,10 @@ namespace SourceGit.UI { /// /// private void ChangeDiffMode(object sender, RoutedEventArgs e) { - foreach (var editor in editors) editorContainer.Children.Remove(editor); + if (!IsLoaded) return; + + editorContainer.Children.Clear(); + editorLines.Children.Clear(); editors.Clear(); SetTextChange();