optimize<DiffViewer>: clean all grid lines before layout diff content

This commit is contained in:
leo 2020-12-14 09:58:39 +08:00
parent a53d3f642d
commit d69db0289e

View file

@ -94,6 +94,9 @@ namespace SourceGit.UI {
foreach (var editor in editors) editorContainer.Children.Remove(editor); foreach (var editor in editors) editorContainer.Children.Remove(editor);
editors.Clear(); editors.Clear();
editorLines.Children.Clear();
editorLines.ColumnDefinitions.Clear();
Task.Run(() => { Task.Run(() => {
var args = $"{opts.ExtraArgs} "; var args = $"{opts.ExtraArgs} ";
if (opts.RevisionRange.Length > 0) args += $"{opts.RevisionRange[0]} "; if (opts.RevisionRange.Length > 0) args += $"{opts.RevisionRange[0]} ";
@ -190,12 +193,10 @@ namespace SourceGit.UI {
editorContainer.Children.Add(editor); editorContainer.Children.Add(editor);
editors.Add(editor); editors.Add(editor);
editorLines.Children.Clear(); editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) });
editorLines.ColumnDefinitions.Clear();
for (int i = 0; i < 2; i++) {
editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) }); editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) });
for (int i = 0; i < 2; i++) {
var split = new Rectangle(); var split = new Rectangle();
split.Width = 1; split.Width = 1;
split.Fill = FindResource("Brush.Border2") as Brush; split.Fill = FindResource("Brush.Border2") as Brush;
@ -269,8 +270,6 @@ namespace SourceGit.UI {
editors.Add(oldEditor); editors.Add(oldEditor);
editors.Add(newEditor); editors.Add(newEditor);
editorLines.Children.Clear();
editorLines.ColumnDefinitions.Clear();
editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) }); 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(1, GridUnitType.Star) });
editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) }); editorLines.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(lineNumberWidth) });