summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDavyd McColl <davydm@gmail.com>2021-06-11 15:19:15 +0200
committerJesse Duffield <jessedduffield@gmail.com>2021-07-01 17:13:14 +1000
commit130480555f1242a7b866f32a5ef1cb2f9a2504a4 (patch)
tree44337bda1b8b11864effc26438a4574ec3a49519 /pkg
parent92cc6e883d720389cc0e0814cc15767ee949a456 (diff)
:sparkles: always show whitespace in diffs when entering line-by-line staging
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/staging_panel.go4
-rw-r--r--pkg/gui/whitespace-toggle.go10
2 files changed, 13 insertions, 1 deletions
diff --git a/pkg/gui/staging_panel.go b/pkg/gui/staging_panel.go
index 916361fc1..f30aadd6a 100644
--- a/pkg/gui/staging_panel.go
+++ b/pkg/gui/staging_panel.go
@@ -33,6 +33,10 @@ func (gui *Gui) refreshStagingPanel(forceSecondaryFocused bool, selectedLineIdx
gui.Views.Secondary.Title = gui.Tr.StagedChanges
}
+ // if we were ignoring whitespace, stop doing that so that
+ // line-by-line diffs work as expected
+ gui.setIgnoreWhitespaceFlag(false)
+
// note for custom diffs, we'll need to send a flag here saying not to use the custom diff
diff := gui.GitCommand.WorktreeFileDiff(file, true, secondaryFocused, gui.State.IgnoreWhitespaceInDiffView)
secondaryDiff := gui.GitCommand.WorktreeFileDiff(file, true, !secondaryFocused, gui.State.IgnoreWhitespaceInDiffView)
diff --git a/pkg/gui/whitespace-toggle.go b/pkg/gui/whitespace-toggle.go
index e7df9d879..697770a94 100644
--- a/pkg/gui/whitespace-toggle.go
+++ b/pkg/gui/whitespace-toggle.go
@@ -1,7 +1,15 @@
package gui
func (gui *Gui) toggleWhitespaceInDiffView() error {
- gui.State.IgnoreWhitespaceInDiffView = !gui.State.IgnoreWhitespaceInDiffView
+ return gui.setIgnoreWhitespaceFlag(!gui.State.IgnoreWhitespaceInDiffView)
+}
+
+func (gui *Gui) setIgnoreWhitespaceFlag(shouldIgnoreWhitespace bool) error {
+ if gui.State.IgnoreWhitespaceInDiffView == shouldIgnoreWhitespace {
+ return nil
+ }
+
+ gui.State.IgnoreWhitespaceInDiffView = shouldIgnoreWhitespace
toastMessage := gui.Tr.ShowingWhitespaceInDiffView
if gui.State.IgnoreWhitespaceInDiffView {