optimize<Diff>: improve update layout performance

This commit is contained in:
leo 2020-11-25 20:51:33 +08:00
parent 12b4783d6e
commit e5913b6ff6
2 changed files with 149 additions and 190 deletions

View file

@ -6,29 +6,27 @@
xmlns:sourcegit="clr-namespace:SourceGit" xmlns:sourcegit="clr-namespace:SourceGit"
mc:Ignorable="d" mc:Ignorable="d"
FontFamily="Consolas"> FontFamily="Consolas">
<Border BorderThickness="1" BorderBrush="{StaticResource Brush.Border2}"> <UserControl.Resources>
<Grid x:Name="area" SizeChanged="OnSizeChanged"> <Style x:Key="Style.DataGridRow.TextChange" TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
<Grid.RowDefinitions> <EventSetter Event="RequestBringIntoView" Handler="OnLineRequestBringIntoView"/>
<RowDefinition Height="26"/> </Style>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.Resources>
<Style x:Key="Style.DataGridText.LineNumber" TargetType="{x:Type TextBlock}"> <Style x:Key="Style.DataGridText.LineNumber" TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="Consolas"/> <Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="Foreground" Value="{StaticResource Brush.FG}"/> <Setter Property="Foreground" Value="{StaticResource Brush.FG}"/>
<Setter Property="HorizontalAlignment" Value="Right"/> <Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Padding" Value="8,0"/> <Setter Property="Padding" Value="8,0"/>
<Setter Property="FontSize" Value="12"/>
</Style> </Style>
</UserControl.Resources>
<Style x:Key="Style.DataGridText.Block" TargetType="{x:Type TextBlock}"> <Border BorderThickness="1" BorderBrush="{StaticResource Brush.Border2}">
<Setter Property="FontFamily" Value="Consolas"/> <Grid>
<Setter Property="Foreground" Value="{StaticResource Brush.FG}"/> <Grid.RowDefinitions>
<Setter Property="VerticalAlignment" Value="Center"/> <RowDefinition Height="26"/>
<Setter Property="Padding" Value="0"/> <RowDefinition Height="*"/>
</Style> </Grid.RowDefinitions>
</Grid.Resources>
<Border Grid.Row="0" BorderBrush="{StaticResource Brush.Border2}" BorderThickness="0,0,0,1"> <Border Grid.Row="0" BorderBrush="{StaticResource Brush.Border2}" BorderThickness="0,0,0,1">
<Grid Margin="8,4"> <Grid Margin="8,4">
@ -69,105 +67,12 @@
</Grid> </Grid>
</Border> </Border>
<Grid Grid.Row="1" x:Name="textChangeTwoSides"> <Grid Grid.Row="1" x:Name="editorContainer" SizeChanged="OnSizeChanged">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<DataGrid
Grid.Column="0"
x:Name="textChangeOldSide"
GridLinesVisibility="Vertical"
VerticalGridLinesBrush="{StaticResource Brush.Border2}"
FrozenColumnCount="1"
ScrollViewer.ScrollChanged="OnTwoSidesScroll"
ContextMenuOpening="OnTextChangeContextMenuOpening">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
<EventSetter Event="RequestBringIntoView" Handler="OnLineRequestBringIntoView"/>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" IsReadOnly="True" Binding="{Binding OldLine}" ElementStyle="{StaticResource Style.DataGridText.LineNumber}"/>
<DataGridTemplateColumn Width="Auto" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Border Background="{Binding BG}" BorderThickness="0"/>
<TextBlock Text="{Binding Content}" Background="Transparent" Foreground="{Binding FG}" FontFamily="Consolas" FontSize="12" FontStyle="{Binding Style}" Margin="0" Padding="0"/>
</Grid> </Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<DataGrid
Grid.Column="1"
x:Name="textChangeNewSide"
GridLinesVisibility="Vertical"
VerticalGridLinesBrush="{StaticResource Brush.Border2}"
FrozenColumnCount="1"
ScrollViewer.ScrollChanged="OnTwoSidesScroll"
ContextMenuOpening="OnTextChangeContextMenuOpening">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
<EventSetter Event="RequestBringIntoView" Handler="OnLineRequestBringIntoView"/>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" IsReadOnly="True" Binding="{Binding NewLine}" ElementStyle="{StaticResource Style.DataGridText.LineNumber}"/>
<DataGridTemplateColumn Width="Auto" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Border Background="{Binding BG}" BorderThickness="0"/>
<TextBlock Text="{Binding Content}" Background="Transparent" Foreground="{Binding FG}" FontFamily="Consolas" FontSize="12" FontStyle="{Binding Style}" Margin="0" Padding="0"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
<DataGrid
Grid.Row="1"
x:Name="textChangeOneSide"
GridLinesVisibility="Vertical"
VerticalGridLinesBrush="{StaticResource Brush.Border2}"
FrozenColumnCount="2"
ContextMenuOpening="OnTextChangeContextMenuOpening">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
<EventSetter Event="RequestBringIntoView" Handler="OnLineRequestBringIntoView"/>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" IsReadOnly="True" Binding="{Binding OldLine}" ElementStyle="{StaticResource Style.DataGridText.LineNumber}"/>
<DataGridTextColumn Width="Auto" IsReadOnly="True" Binding="{Binding NewLine}" ElementStyle="{StaticResource Style.DataGridText.LineNumber}"/>
<DataGridTemplateColumn Width="Auto" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Border Background="{Binding BG}" BorderThickness="0"/>
<TextBlock Text="{Binding Content}" Background="Transparent" Foreground="{Binding FG}" FontFamily="Consolas" FontSize="12" FontStyle="{Binding Style}" Margin="0" Padding="0"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<Border x:Name="sizeChange" Grid.Row="1" ClipToBounds="True" Background="{StaticResource Brush.BG3}" Visibility="Collapsed"> <Border x:Name="sizeChange" Grid.Row="1" ClipToBounds="True" Background="{StaticResource Brush.BG3}" Visibility="Collapsed">
<StackPanel Orientation="Vertical" VerticalAlignment="Center"> <StackPanel Orientation="Vertical" VerticalAlignment="Center">

View file

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Threading; using System.Windows.Threading;
@ -18,6 +20,7 @@ namespace SourceGit.UI {
private Brush bgAdded = new SolidColorBrush(Color.FromArgb(60, 0, 255, 0)); private Brush bgAdded = new SolidColorBrush(Color.FromArgb(60, 0, 255, 0));
private Brush bgDeleted = new SolidColorBrush(Color.FromArgb(60, 255, 0, 0)); private Brush bgDeleted = new SolidColorBrush(Color.FromArgb(60, 255, 0, 0));
private Brush bgNormal = Brushes.Transparent; private Brush bgNormal = Brushes.Transparent;
private List<DataGrid> editors = new List<DataGrid>();
/// <summary> /// <summary>
/// Diff options. /// Diff options.
@ -69,11 +72,12 @@ namespace SourceGit.UI {
loading.Visibility = Visibility.Visible; loading.Visibility = Visibility.Visible;
mask.Visibility = Visibility.Collapsed; mask.Visibility = Visibility.Collapsed;
textChangeOneSide.Visibility = Visibility.Collapsed;
textChangeTwoSides.Visibility = Visibility.Collapsed;
sizeChange.Visibility = Visibility.Collapsed; sizeChange.Visibility = Visibility.Collapsed;
noChange.Visibility = Visibility.Collapsed; noChange.Visibility = Visibility.Collapsed;
foreach (var editor in editors) editorContainer.Children.Remove(editor);
editors.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]} ";
@ -132,6 +136,8 @@ namespace SourceGit.UI {
var fgCommon = FindResource("Brush.FG") as Brush; var fgCommon = FindResource("Brush.FG") as Brush;
var fgIndicator = FindResource("Brush.FG2") as Brush; var fgIndicator = FindResource("Brush.FG2") as Brush;
var lastOldLine = "";
var lastNewLine = "";
if (App.Preference.UIUseOneSideDiff) { if (App.Preference.UIUseOneSideDiff) {
var blocks = new List<ChangeBlock>(); var blocks = new List<ChangeBlock>();
@ -146,18 +152,31 @@ namespace SourceGit.UI {
block.OldLine = line.OldLine; block.OldLine = line.OldLine;
block.NewLine = line.NewLine; block.NewLine = line.NewLine;
if (line.OldLine.Length > 0) lastOldLine = line.OldLine;
if (line.NewLine.Length > 0) lastNewLine = line.NewLine;
blocks.Add(block); blocks.Add(block);
} }
Dispatcher.Invoke(() => { Dispatcher.Invoke(() => {
loading.Visibility = Visibility.Collapsed; loading.Visibility = Visibility.Collapsed;
textChangeOptions.Visibility = Visibility.Visible; textChangeOptions.Visibility = Visibility.Visible;
textChangeOneSide.Visibility = Visibility.Visible;
textChangeTwoSides.Visibility = Visibility.Collapsed;
ResetDataGrid(textChangeOneSide); var formatted = new FormattedText(
textChangeOneSide.ItemsSource = blocks; lastOldLine + lastNewLine,
OnSizeChanged(null, null); CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(FontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
12.0,
fgCommon);
var minWidth = editorContainer.ActualWidth - formatted.Width - 16 - 12;
var editor = CreateTextEditor(new string[] { "OldLine", "NewLine" });
editor.Columns[2].MinWidth = minWidth;
editor.ItemsSource = blocks;
editor.SetValue(Grid.ColumnSpanProperty, 2);
editorContainer.Children.Add(editor);
editors.Add(editor);
}); });
} else { } else {
var oldSideBlocks = new List<ChangeBlock>(); var oldSideBlocks = new List<ChangeBlock>();
@ -173,6 +192,9 @@ namespace SourceGit.UI {
block.OldLine = line.OldLine; block.OldLine = line.OldLine;
block.NewLine = line.NewLine; block.NewLine = line.NewLine;
if (line.OldLine.Length > 0) lastOldLine = line.OldLine;
if (line.NewLine.Length > 0) lastNewLine = line.NewLine;
switch (line.Mode) { switch (line.Mode) {
case Git.Diff.LineMode.Added: case Git.Diff.LineMode.Added:
newSideBlocks.Add(block); newSideBlocks.Add(block);
@ -210,16 +232,38 @@ namespace SourceGit.UI {
Dispatcher.Invoke(() => { Dispatcher.Invoke(() => {
loading.Visibility = Visibility.Collapsed; loading.Visibility = Visibility.Collapsed;
textChangeOptions.Visibility = Visibility.Visible; textChangeOptions.Visibility = Visibility.Visible;
textChangeOneSide.Visibility = Visibility.Collapsed;
textChangeTwoSides.Visibility = Visibility.Visible;
ResetDataGrid(textChangeOldSide); var number = lastOldLine;
ResetDataGrid(textChangeNewSide); if (lastOldLine.Length > lastNewLine.Length) number = lastNewLine;
textChangeOldSide.ItemsSource = oldSideBlocks; var formatted = new FormattedText(
textChangeNewSide.ItemsSource = newSideBlocks; number,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(FontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
12.0,
fgCommon);
OnSizeChanged(null, null); var minWidth = editorContainer.ActualWidth / 2 - formatted.Width - 16 - 12;
var oldEditor = CreateTextEditor(new string[] { "OldLine" });
oldEditor.SetValue(Grid.ColumnProperty, 0);
oldEditor.ContextMenuOpening += OnTextChangeContextMenuOpening;
oldEditor.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnTwoSidesScroll));
oldEditor.Columns[1].MinWidth = minWidth;
oldEditor.ItemsSource = oldSideBlocks;
var newEditor = CreateTextEditor(new string[] { "NewLine" });
newEditor.SetValue(Grid.ColumnProperty, 1);
newEditor.ContextMenuOpening += OnTextChangeContextMenuOpening;
newEditor.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnTwoSidesScroll));
newEditor.Columns[1].MinWidth = minWidth;
newEditor.ItemsSource = newSideBlocks;
editorContainer.Children.Add(oldEditor);
editorContainer.Children.Add(newEditor);
editors.Add(oldEditor);
editors.Add(newEditor);
}); });
} }
} }
@ -310,14 +354,47 @@ namespace SourceGit.UI {
return child; return child;
} }
private void ResetDataGrid(DataGrid dg) { private DataGrid CreateTextEditor(string[] lineNumbers) {
dg.ItemsSource = null; var grid = new DataGrid();
dg.Items.Clear(); grid.SetValue(Grid.RowProperty, 1);
grid.GridLinesVisibility = DataGridGridLinesVisibility.Vertical;
grid.VerticalGridLinesBrush = FindResource("Brush.Border2") as Brush;
grid.FrozenColumnCount = lineNumbers.Length;
grid.ContextMenuOpening += OnTextChangeContextMenuOpening;
grid.RowStyle = FindResource("Style.DataGridRow.TextChange") as Style;
foreach (var col in dg.Columns) { foreach (var number in lineNumbers) {
col.MinWidth = 0; var colLineNumber = new DataGridTextColumn();
col.Width = 0; colLineNumber.Width = DataGridLength.Auto;
colLineNumber.IsReadOnly = true;
colLineNumber.Binding = new Binding(number);
colLineNumber.ElementStyle = FindResource("Style.DataGridText.LineNumber") as Style;
grid.Columns.Add(colLineNumber);
} }
var borderContent = new FrameworkElementFactory(typeof(Border));
borderContent.SetBinding(Border.BackgroundProperty, new Binding("BG"));
var textContent = new FrameworkElementFactory(typeof(TextBlock));
textContent.SetBinding(TextBlock.TextProperty, new Binding("Content"));
textContent.SetBinding(TextBlock.ForegroundProperty, new Binding("FG"));
textContent.SetBinding(TextBlock.FontStyleProperty, new Binding("Style"));
textContent.SetValue(TextBlock.BackgroundProperty, Brushes.Transparent);
textContent.SetValue(TextBlock.FontSizeProperty, 12.0);
textContent.SetValue(TextBlock.MarginProperty, new Thickness(0));
textContent.SetValue(TextBlock.PaddingProperty, new Thickness(0));
var visualTree = new FrameworkElementFactory(typeof(Grid));
visualTree.AppendChild(borderContent);
visualTree.AppendChild(textContent);
var colContent = new DataGridTemplateColumn();
colContent.CellTemplate = new DataTemplate();
colContent.CellTemplate.VisualTree = visualTree;
colContent.Width = DataGridLength.SizeToCells;
grid.Columns.Add(colContent);
return grid;
} }
#endregion #endregion
@ -329,52 +406,35 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void OnSizeChanged(object sender, SizeChangedEventArgs e) { private void OnSizeChanged(object sender, SizeChangedEventArgs e) {
var total = area.ActualWidth; if (editors.Count == 0) return;
var total = editorContainer.ActualWidth;
if (App.Preference.UIUseOneSideDiff) { if (App.Preference.UIUseOneSideDiff) {
textChangeOneSide.Columns[0].Width = DataGridLength.Auto; var editor = editors[0];
textChangeOneSide.Columns[1].Width = DataGridLength.Auto; var minWidth = total - editor.NonFrozenColumnsViewportHorizontalOffset;
textChangeOneSide.Columns[2].MinWidth = 1; var scroller = GetVisualChild<ScrollViewer>(editor);
textChangeOneSide.Columns[2].Width = 1; if (scroller != null && scroller.ComputedVerticalScrollBarVisibility == Visibility.Visible) minWidth -= 8;
textChangeOneSide.UpdateLayout(); editor.Columns[2].MinWidth = minWidth;
editor.Columns[2].Width = DataGridLength.SizeToCells;
var offset = textChangeOneSide.NonFrozenColumnsViewportHorizontalOffset; editor.UpdateLayout();
var minWidth = total - offset;
var scroller = GetVisualChild<ScrollViewer>(textChangeOneSide);
if (scroller.ComputedVerticalScrollBarVisibility == Visibility.Visible) minWidth -= 8;
textChangeOneSide.Columns[2].MinWidth = minWidth;
textChangeOneSide.Columns[2].Width = DataGridLength.Auto;
textChangeOneSide.UpdateLayout();
} else { } else {
textChangeOldSide.Columns[0].Width = DataGridLength.Auto; var offOld = editors[0].NonFrozenColumnsViewportHorizontalOffset;
textChangeOldSide.Columns[1].MinWidth = 1; var offNew = editors[1].NonFrozenColumnsViewportHorizontalOffset;
textChangeOldSide.Columns[1].Width = 1;
textChangeOldSide.UpdateLayout();
textChangeNewSide.Columns[0].Width = DataGridLength.Auto; var minWidth = total / 2 - Math.Min(offOld, offNew);
textChangeNewSide.Columns[1].MinWidth = 1; var scroller = GetVisualChild<ScrollViewer>(editors[0]);
textChangeNewSide.Columns[1].Width = 1; if (scroller != null && scroller.ComputedVerticalScrollBarVisibility == Visibility.Visible) minWidth -= 8;
textChangeNewSide.UpdateLayout(); editors[0].Columns[1].MinWidth = minWidth;
editors[0].Columns[1].Width = DataGridLength.SizeToCells;
var oldOffset = textChangeOldSide.NonFrozenColumnsViewportHorizontalOffset; editors[1].Columns[1].MinWidth = minWidth;
var newOffset = textChangeNewSide.NonFrozenColumnsViewportHorizontalOffset; editors[1].Columns[1].Width = DataGridLength.SizeToCells;
var minWidth = total - Math.Min(oldOffset, newOffset); editors[0].UpdateLayout();
editors[1].UpdateLayout();
var scroller = GetVisualChild<ScrollViewer>(textChangeNewSide);
if (scroller.ComputedVerticalScrollBarVisibility == Visibility.Visible) minWidth -= 8;
textChangeOldSide.Columns[1].MinWidth = minWidth;
textChangeOldSide.Columns[1].Width = DataGridLength.Auto;
textChangeOldSide.UpdateLayout();
textChangeNewSide.Columns[1].MinWidth = minWidth;
textChangeNewSide.Columns[1].Width = DataGridLength.Auto;
textChangeNewSide.UpdateLayout();
} }
} }
/// <summary> /// <summary>
/// Prevent default auto-scrolling when click row in DataGrid. /// Prevent default auto-scrolling when click row in DataGrid.
/// </summary> /// </summary>
@ -390,24 +450,15 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void OnTwoSidesScroll(object sender, ScrollChangedEventArgs e) { private void OnTwoSidesScroll(object sender, ScrollChangedEventArgs e) {
var oldSideScroller = GetVisualChild<ScrollViewer>(textChangeOldSide);
var newSideScroller = GetVisualChild<ScrollViewer>(textChangeNewSide);
if (e.VerticalChange != 0) { if (e.VerticalChange != 0) {
if (oldSideScroller.VerticalOffset != e.VerticalOffset) { foreach (var editor in editors) {
oldSideScroller.ScrollToVerticalOffset(e.VerticalOffset); var scroller = GetVisualChild<ScrollViewer>(editor);
} if (scroller.VerticalOffset != e.VerticalOffset) scroller.ScrollToVerticalOffset(e.VerticalOffset);
if (newSideScroller.VerticalOffset != e.VerticalOffset) {
newSideScroller.ScrollToVerticalOffset(e.VerticalOffset);
} }
} else { } else {
if (oldSideScroller.HorizontalOffset != e.HorizontalOffset) { foreach (var editor in editors) {
oldSideScroller.ScrollToHorizontalOffset(e.HorizontalOffset); var scroller = GetVisualChild<ScrollViewer>(editor);
} if (scroller.HorizontalOffset != e.HorizontalOffset) scroller.ScrollToHorizontalOffset(e.HorizontalOffset);
if (newSideScroller.HorizontalOffset != e.HorizontalOffset) {
newSideScroller.ScrollToHorizontalOffset(e.HorizontalOffset);
} }
} }
} }
@ -418,9 +469,9 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Go2Next(object sender, RoutedEventArgs e) { private void Go2Next(object sender, RoutedEventArgs e) {
var grid = textChangeOneSide; if (editors.Count == 0) return;
if (!App.Preference.UIUseOneSideDiff) grid = textChangeNewSide;
var grid = editors[0];
var scroller = GetVisualChild<ScrollViewer>(grid); var scroller = GetVisualChild<ScrollViewer>(grid);
var firstVisible = (int)scroller.VerticalOffset; var firstVisible = (int)scroller.VerticalOffset;
var firstModeEnded = false; var firstModeEnded = false;
@ -444,9 +495,9 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Go2Prev(object sender, RoutedEventArgs e) { private void Go2Prev(object sender, RoutedEventArgs e) {
var grid = textChangeOneSide; if (editors.Count == 0) return;
if (!App.Preference.UIUseOneSideDiff) grid = textChangeNewSide;
var grid = editors[0];
var scroller = GetVisualChild<ScrollViewer>(grid); var scroller = GetVisualChild<ScrollViewer>(grid);
var firstVisible = (int)scroller.VerticalOffset; var firstVisible = (int)scroller.VerticalOffset;
var firstModeEnded = false; var firstModeEnded = false;
@ -470,6 +521,9 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void ChangeDiffMode(object sender, RoutedEventArgs e) { private void ChangeDiffMode(object sender, RoutedEventArgs e) {
foreach (var editor in editors) editorContainer.Children.Remove(editor);
editors.Clear();
SetTextChange(); SetTextChange();
} }