diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index 6dd836bf..ce13e655 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -19,11 +19,15 @@ namespace SourceGit.ViewModels public bool IgnoreWhitespace { - get => _ignoreWhitespace; + get => Preferences.Instance.IgnoreWhitespaceChangesInDiff; set { - if (SetProperty(ref _ignoreWhitespace, value)) + if (value != Preferences.Instance.IgnoreWhitespaceChangesInDiff) + { + Preferences.Instance.IgnoreWhitespaceChangesInDiff = value; + OnPropertyChanged(); LoadDiffContent(); + } } } @@ -62,7 +66,6 @@ namespace SourceGit.ViewModels _content = previous._content; _fileModeChange = previous._fileModeChange; _unifiedLines = previous._unifiedLines; - _ignoreWhitespace = previous._ignoreWhitespace; _info = previous._info; } @@ -114,8 +117,9 @@ namespace SourceGit.ViewModels // There is no way to tell a git-diff to use "ALL lines of context", // so instead we set a very high number for the "lines of context" parameter. var numLines = Preferences.Instance.UseFullTextDiff ? 999999999 : _unifiedLines; - var latest = new Commands.Diff(_repo, _option, numLines, _ignoreWhitespace).Result(); - var info = new Info(_option, numLines, _ignoreWhitespace, latest); + var ignoreWS = Preferences.Instance.IgnoreWhitespaceChangesInDiff; + var latest = new Commands.Diff(_repo, _option, numLines, ignoreWS).Result(); + var info = new Info(_option, numLines, ignoreWS, latest); if (_info != null && info.IsSame(_info)) return; @@ -287,7 +291,6 @@ namespace SourceGit.ViewModels private string _fileModeChange = string.Empty; private int _unifiedLines = 4; private bool _isTextDiff = false; - private bool _ignoreWhitespace = false; private object _content = null; private Info _info = null; } diff --git a/src/ViewModels/Preferences.cs b/src/ViewModels/Preferences.cs index fb310e51..a1830d07 100644 --- a/src/ViewModels/Preferences.cs +++ b/src/ViewModels/Preferences.cs @@ -212,6 +212,12 @@ namespace SourceGit.ViewModels set => SetProperty(ref _useSyntaxHighlighting, value); } + public bool IgnoreWhitespaceChangesInDiff + { + get => _ignoreWhitespaceChangesInDiff; + set => SetProperty(ref _ignoreWhitespaceChangesInDiff, value); + } + public bool EnableDiffViewWordWrap { get => _enableDiffViewWordWrap; @@ -658,6 +664,7 @@ namespace SourceGit.ViewModels private bool _useTwoColumnsLayoutInHistories = false; private bool _displayTimeAsPeriodInHistories = false; private bool _useSideBySideDiff = false; + private bool _ignoreWhitespaceChangesInDiff = false; private bool _useSyntaxHighlighting = false; private bool _enableDiffViewWordWrap = false; private bool _showHiddenSymbolsInDiffView = false; diff --git a/src/Views/CommitMessageTextBox.axaml b/src/Views/CommitMessageTextBox.axaml index e5d63eca..1bd2ce31 100644 --- a/src/Views/CommitMessageTextBox.axaml +++ b/src/Views/CommitMessageTextBox.axaml @@ -66,10 +66,9 @@ CornerRadius="0,0,4,4"> - +