Skip to content

Commit e6170f8

Browse files
authored
enhance: diff view (#2436)
- Fix the issue that `Ignore Whitespace Changes` can't be turn off when there's only whitespace changes - Rename `_entireFileLine` to `_entireFileLines` - Move the `Ignore Whitespace Changes` toggle button next to the `Open in Merge Tool` button.
1 parent 7e2aabb commit e6170f8

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

src/ViewModels/DiffContext.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ public void OpenExternalMergeTool()
8585

8686
public void CheckSettings()
8787
{
88+
var pref = Preferences.Instance;
89+
8890
if (Content is TextDiffContext ctx)
8991
{
90-
var pref = Preferences.Instance;
91-
92-
if ((pref.UseFullTextDiff && _info.UnifiedLines != _entireFileLine) ||
93-
(!pref.UseFullTextDiff && _info.UnifiedLines == _entireFileLine) ||
92+
if ((pref.UseFullTextDiff && _info.UnifiedLines != _entireFileLines) ||
93+
(!pref.UseFullTextDiff && _info.UnifiedLines == _entireFileLines) ||
9494
(pref.IgnoreWhitespaceChangesInDiff != _info.IgnoreWhitespace))
9595
{
9696
LoadContent();
@@ -100,6 +100,11 @@ public void CheckSettings()
100100
if (ctx.IsSideBySide() != pref.UseSideBySideDiff)
101101
Content = ctx.SwitchMode();
102102
}
103+
else if (Content is Models.NoOrEOLChange)
104+
{
105+
if (pref.IgnoreWhitespaceChangesInDiff != _info.IgnoreWhitespace)
106+
LoadContent();
107+
}
103108
}
104109

105110
private void LoadContent()
@@ -114,7 +119,7 @@ private void LoadContent()
114119
Task.Run(async () =>
115120
{
116121
var pref = Preferences.Instance;
117-
var numLines = pref.UseFullTextDiff ? _entireFileLine : _unifiedLines;
122+
var numLines = pref.UseFullTextDiff ? _entireFileLines : _unifiedLines;
118123
var ignoreWhitespace = pref.IgnoreWhitespaceChangesInDiff;
119124
var ignoreCRAtEOL = pref.IgnoreCRAtEOLInDiff;
120125

@@ -326,7 +331,7 @@ public bool IsSame(Info other)
326331
}
327332
}
328333

329-
private readonly int _entireFileLine = 999999999;
334+
private readonly int _entireFileLines = 999999999;
330335
private readonly string _repo;
331336
private readonly Models.DiffOption _option = null;
332337
private string _fileModeChange = string.Empty;

src/Views/DiffView.axaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,6 @@
180180
<Path Width="12" Height="12" Data="{StaticResource Icons.WordWrap}" Margin="0,2,0,0"/>
181181
</ToggleButton>
182182

183-
<ToggleButton Classes="line_path"
184-
Width="28"
185-
IsChecked="{Binding Source={x:Static vm:Preferences.Instance}, Path=IgnoreWhitespaceChangesInDiff, Mode=TwoWay}"
186-
IsVisible="{Binding IsIgnoreWhitespaceVisible, Mode=OneWay}"
187-
ToolTip.Tip="{DynamicResource Text.Diff.IgnoreWhitespace}"
188-
PropertyChanged="OnToggleButtonPropertyChanged">
189-
<Path Width="14" Height="14" Stretch="Uniform" Data="{StaticResource Icons.Whitespace}"/>
190-
</ToggleButton>
191-
192183
<ToggleButton Classes="line_path"
193184
Width="28"
194185
IsChecked="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowHiddenSymbolsInDiffView, Mode=TwoWay}"
@@ -207,6 +198,15 @@
207198
<Path Width="12" Height="12" Data="{StaticResource Icons.Layout}" Margin="0,2,0,0"/>
208199
</ToggleButton>
209200

201+
<ToggleButton Classes="line_path"
202+
Width="28"
203+
IsChecked="{Binding Source={x:Static vm:Preferences.Instance}, Path=IgnoreWhitespaceChangesInDiff, Mode=TwoWay}"
204+
IsVisible="{Binding IsIgnoreWhitespaceVisible, Mode=OneWay}"
205+
ToolTip.Tip="{DynamicResource Text.Diff.IgnoreWhitespace}"
206+
PropertyChanged="OnToggleButtonPropertyChanged">
207+
<Path Width="14" Height="14" Stretch="Uniform" Data="{StaticResource Icons.Whitespace}"/>
208+
</ToggleButton>
209+
210210
<Button x:Name="BtnOpenExternalMergeTool"
211211
Classes="icon_button"
212212
Width="28"

0 commit comments

Comments
 (0)