diff --git a/GitDiffMargin/GitDiffMargin.csproj b/GitDiffMargin/GitDiffMargin.csproj
index 7f90ea8..3c9c68c 100644
--- a/GitDiffMargin/GitDiffMargin.csproj
+++ b/GitDiffMargin/GitDiffMargin.csproj
@@ -275,6 +275,10 @@
LICENSE.md
true
+
+
+ source.extension.vsixmanifest
+
Designer
diff --git a/GitDiffMargin/GitDiffMargin.vsct b/GitDiffMargin/GitDiffMargin.vsct
index 25c61dc..75a0024 100644
--- a/GitDiffMargin/GitDiffMargin.vsct
+++ b/GitDiffMargin/GitDiffMargin.vsct
@@ -80,6 +80,17 @@
Copy Old Text
+
+
@@ -88,6 +99,7 @@
+
@@ -100,6 +112,7 @@
+
@@ -110,5 +123,6 @@
+
-
+
\ No newline at end of file
diff --git a/GitDiffMargin/GitDiffMarginCommand.cs b/GitDiffMargin/GitDiffMarginCommand.cs
index 0d89fae..9c895de 100644
--- a/GitDiffMargin/GitDiffMarginCommand.cs
+++ b/GitDiffMargin/GitDiffMarginCommand.cs
@@ -10,6 +10,7 @@ public enum GitDiffMarginCommand
RollbackChange = 2,
ShowDiff = 3,
CopyOldText = 4,
+ IgnoreWhiteSpaces = 5,
GitDiffToolbar = 100,
diff --git a/GitDiffMargin/GitDiffMarginCommandHandler.cs b/GitDiffMargin/GitDiffMarginCommandHandler.cs
index aacd5dd..25fb882 100644
--- a/GitDiffMargin/GitDiffMarginCommandHandler.cs
+++ b/GitDiffMargin/GitDiffMarginCommandHandler.cs
@@ -98,6 +98,19 @@ protected override OLECMDF QueryCommandStatus(ref Guid commandGroup, uint comman
// these aren't actually commands, but IDs of the command bars and groups
break;
+ case GitDiffMarginCommand.IgnoreWhiteSpaces:
+ {
+ EditorDiffMarginViewModel viewModel;
+ if (!TryGetMarginViewModel(out viewModel) || !viewModel.HasDiffs)
+ return 0;
+
+ if (viewModel.IgnoreWhiteSpaces)
+ return OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_LATCHED;
+ else
+ return OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED;
+ }
+ break;
+
default:
break;
}
@@ -166,6 +179,14 @@ protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLE
// these aren't actually commands, but IDs of the command bars and groups
break;
+ case GitDiffMarginCommand.IgnoreWhiteSpaces:
+ {
+ ICommand command = viewModel.ToggleIgnoreWhiteSpacesCommand;
+ command.Execute(null);
+ return true;
+ }
+ break;
+
default:
break;
}
diff --git a/GitDiffMargin/Resources/Ignore_whitespaces.png b/GitDiffMargin/Resources/Ignore_whitespaces.png
new file mode 100644
index 0000000..a1a18bd
Binary files /dev/null and b/GitDiffMargin/Resources/Ignore_whitespaces.png differ
diff --git a/GitDiffMargin/ViewModel/DiffMarginViewModelBase.cs b/GitDiffMargin/ViewModel/DiffMarginViewModelBase.cs
index 3f53261..39331eb 100644
--- a/GitDiffMargin/ViewModel/DiffMarginViewModelBase.cs
+++ b/GitDiffMargin/ViewModel/DiffMarginViewModelBase.cs
@@ -24,6 +24,8 @@ protected DiffMarginViewModelBase(IMarginCore marginCore)
MarginCore.HunksChanged += HandleHunksChanged;
}
+ public bool HasDiffs { get; private set; }
+
public ObservableCollection DiffViewModels { get; private set; }
public void RefreshDiffViewModelPositions()
@@ -38,7 +40,16 @@ protected virtual void HandleHunksChanged(object sender, HunksChangedEventArgs e
{
DiffViewModels.Clear();
- foreach (var diffViewModel in e.Hunks.Select(CreateDiffViewModel))
+ HasDiffs = e.Hunks.Any();
+
+ var hunks = e.Hunks;
+
+ if (MarginCore.IgnoreWhiteSpaces)
+ {
+ hunks = hunks.Where(hunk => !hunk.IsWhiteSpaceChange);
+ }
+
+ foreach (var diffViewModel in hunks.Select(CreateDiffViewModel))
{
DiffViewModels.Add(diffViewModel);
}
diff --git a/GitDiffMargin/ViewModel/EditorDiffMarginViewModel.cs b/GitDiffMargin/ViewModel/EditorDiffMarginViewModel.cs
index 05486bb..09730a4 100644
--- a/GitDiffMargin/ViewModel/EditorDiffMarginViewModel.cs
+++ b/GitDiffMargin/ViewModel/EditorDiffMarginViewModel.cs
@@ -15,6 +15,7 @@ internal class EditorDiffMarginViewModel : DiffMarginViewModelBase
private readonly Action _updateDiffDimensions;
private RelayCommand _previousChangeCommand;
private RelayCommand _nextChangeCommand;
+ private RelayCommand _toggleIgnoreWhiteSpacesCommand;
internal EditorDiffMarginViewModel(IMarginCore marginCore, Action updateDiffDimensions) :
base(marginCore)
@@ -25,6 +26,8 @@ internal EditorDiffMarginViewModel(IMarginCore marginCore, Action MarginCore.IgnoreWhiteSpaces;
+
public RelayCommand PreviousChangeCommand
{
get { return _previousChangeCommand ?? (_previousChangeCommand = new RelayCommand(PreviousChange, PreviousChangeCanExecute)); }
@@ -35,6 +38,11 @@ public RelayCommand NextChangeCommand
get { return _nextChangeCommand ?? (_nextChangeCommand = new RelayCommand(NextChange, NextChangeCanExecute)); }
}
+ public RelayCommand ToggleIgnoreWhiteSpacesCommand
+ {
+ get { return _toggleIgnoreWhiteSpacesCommand ?? (_toggleIgnoreWhiteSpacesCommand = new RelayCommand(ToggleIgnoreWhiteSpaces, CanExecuteToggleIgnoreWhiteSpaces)); }
+ }
+
private bool PreviousChangeCanExecute(DiffViewModel currentEditorDiffViewModel)
{
return DiffViewModels.IndexOf(currentEditorDiffViewModel) > 0;
@@ -55,6 +63,16 @@ private void NextChange(DiffViewModel currentEditorDiffViewModel)
MoveToChange(currentEditorDiffViewModel, +1);
}
+ private void ToggleIgnoreWhiteSpaces()
+ {
+ MarginCore.ToggleIgnoreWhiteSpace();
+ }
+
+ private bool CanExecuteToggleIgnoreWhiteSpaces()
+ {
+ return true;
+ }
+
public void MoveToChange(DiffViewModel currentDiffViewModel, int indexModifier)
{
var diffViewModelIndex = DiffViewModels.IndexOf(currentDiffViewModel) + indexModifier;