Skip to content

Commit 161d24f

Browse files
committed
Fix issue where ignore-whitespace can't be toggled, also move toggle-button to avoid it jumping around
(Additionally, renamed nearby variable from _entireFileLine to _entireFileLines, for clarity and consistency with variable _unifiedLines.)
1 parent 7e2aabb commit 161d24f

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

src/ViewModels/DiffContext.cs

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

8686
public void CheckSettings()
8787
{
88-
if (Content is TextDiffContext ctx)
89-
{
90-
var pref = Preferences.Instance;
88+
var pref = Preferences.Instance;
9189

92-
if ((pref.UseFullTextDiff && _info.UnifiedLines != _entireFileLine) ||
93-
(!pref.UseFullTextDiff && _info.UnifiedLines == _entireFileLine) ||
90+
if (_info != null)
91+
{
92+
if ((pref.UseFullTextDiff && _info.UnifiedLines != _entireFileLines) ||
93+
(!pref.UseFullTextDiff && _info.UnifiedLines == _entireFileLines) ||
9494
(pref.IgnoreWhitespaceChangesInDiff != _info.IgnoreWhitespace))
9595
{
9696
LoadContent();
9797
return;
9898
}
99+
}
99100

101+
if (Content is TextDiffContext ctx)
102+
{
100103
if (ctx.IsSideBySide() != pref.UseSideBySideDiff)
101-
Content = ctx.SwitchMode();
104+
Content = ctx.SwitchMode();
102105
}
103106
}
104-
107+
105108
private void LoadContent()
106109
{
107110
if (_option.Path.EndsWith('/'))
@@ -114,7 +117,7 @@ private void LoadContent()
114117
Task.Run(async () =>
115118
{
116119
var pref = Preferences.Instance;
117-
var numLines = pref.UseFullTextDiff ? _entireFileLine : _unifiedLines;
120+
var numLines = pref.UseFullTextDiff ? _entireFileLines : _unifiedLines;
118121
var ignoreWhitespace = pref.IgnoreWhitespaceChangesInDiff;
119122
var ignoreCRAtEOL = pref.IgnoreCRAtEOLInDiff;
120123

@@ -326,7 +329,7 @@ public bool IsSame(Info other)
326329
}
327330
}
328331

329-
private readonly int _entireFileLine = 999999999;
332+
private readonly int _entireFileLines = 999999999;
330333
private readonly string _repo;
331334
private readonly Models.DiffOption _option = null;
332335
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)