1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-05 15:15:49 +02:00

♻️ temporarily bypass ignore whitespace for diff view instead of turning the toggle off completely

This commit is contained in:
Davyd McColl 2021-06-14 10:49:36 +02:00 committed by Jesse Duffield
parent 3dc3174d85
commit 35f1ccdb1b
2 changed files with 3 additions and 15 deletions

View File

@ -33,13 +33,9 @@ func (gui *Gui) refreshStagingPanel(forceSecondaryFocused bool, selectedLineIdx
gui.Views.Secondary.Title = gui.Tr.StagedChanges 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 // 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) diff := gui.GitCommand.WorktreeFileDiff(file, true, secondaryFocused, false)
secondaryDiff := gui.GitCommand.WorktreeFileDiff(file, true, !secondaryFocused, gui.State.IgnoreWhitespaceInDiffView) secondaryDiff := gui.GitCommand.WorktreeFileDiff(file, true, !secondaryFocused, false)
// if we have e.g. a deleted file with nothing else to the diff will have only // if we have e.g. a deleted file with nothing else to the diff will have only
// 4-5 lines in which case we'll swap panels // 4-5 lines in which case we'll swap panels

View File

@ -1,15 +1,7 @@
package gui package gui
func (gui *Gui) toggleWhitespaceInDiffView() error { func (gui *Gui) toggleWhitespaceInDiffView() error {
return gui.setIgnoreWhitespaceFlag(!gui.State.IgnoreWhitespaceInDiffView) gui.State.IgnoreWhitespaceInDiffView = !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 toastMessage := gui.Tr.ShowingWhitespaceInDiffView
if gui.State.IgnoreWhitespaceInDiffView { if gui.State.IgnoreWhitespaceInDiffView {