1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-24 08:52:21 +02:00

always show whitespace in diffs when entering line-by-line staging

This commit is contained in:
Davyd McColl 2021-06-11 15:19:15 +02:00 committed by Jesse Duffield
parent 92cc6e883d
commit 130480555f
2 changed files with 13 additions and 1 deletions

View File

@ -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)

View File

@ -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 {