Skip to content

Commit 7e2aabb

Browse files
committed
enhance: Ignore Whitespace Changes button is only visible for text diff
Signed-off-by: leo <longshuang@msn.cn>
1 parent f5c869f commit 7e2aabb

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/ViewModels/DiffContext.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public bool IsTextDiff
2525
private set => SetProperty(ref _isTextDiff, value);
2626
}
2727

28+
public bool IsIgnoreWhitespaceVisible
29+
{
30+
get => _isIgnoreWhitespaceVisible;
31+
private set => SetProperty(ref _isIgnoreWhitespaceVisible, value);
32+
}
33+
2834
public object Content
2935
{
3036
get => _content;
@@ -45,6 +51,7 @@ public DiffContext(string repo, Models.DiffOption option, DiffContext previous =
4551
if (previous != null)
4652
{
4753
_isTextDiff = previous._isTextDiff;
54+
_isIgnoreWhitespaceVisible = previous._isIgnoreWhitespaceVisible;
4855
_content = previous._content;
4956
_fileModeChange = previous._fileModeChange;
5057
_unifiedLines = previous._unifiedLines;
@@ -236,6 +243,7 @@ private void LoadContent()
236243
if (rs is Models.TextDiff cur)
237244
{
238245
IsTextDiff = true;
246+
IsIgnoreWhitespaceVisible = true;
239247

240248
if (Preferences.Instance.UseSideBySideDiff)
241249
Content = new TwoSideTextDiff(_option, cur, _content as TextDiffContext);
@@ -245,6 +253,7 @@ private void LoadContent()
245253
else
246254
{
247255
IsTextDiff = false;
256+
IsIgnoreWhitespaceVisible = (rs is Models.NoOrEOLChange);
248257
Content = rs;
249258
}
250259
});
@@ -323,6 +332,7 @@ public bool IsSame(Info other)
323332
private string _fileModeChange = string.Empty;
324333
private int _unifiedLines = 4;
325334
private bool _isTextDiff = false;
335+
private bool _isIgnoreWhitespaceVisible = true;
326336
private object _content = null;
327337
private Info _info = null;
328338
}

src/Views/DiffView.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@
183183
<ToggleButton Classes="line_path"
184184
Width="28"
185185
IsChecked="{Binding Source={x:Static vm:Preferences.Instance}, Path=IgnoreWhitespaceChangesInDiff, Mode=TwoWay}"
186+
IsVisible="{Binding IsIgnoreWhitespaceVisible, Mode=OneWay}"
186187
ToolTip.Tip="{DynamicResource Text.Diff.IgnoreWhitespace}"
187188
PropertyChanged="OnToggleButtonPropertyChanged">
188189
<Path Width="14" Height="14" Stretch="Uniform" Data="{StaticResource Icons.Whitespace}"/>

0 commit comments

Comments
 (0)