mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Don't toggle "ignore whitespace" in the staging and patch building panels
The option doesn't have any affect in these views, so we don't need to toggle it here. But the problem was the HandleFocus call at the end: this would activate the wrong view, so we need to avoid it here. Show an error if the user tries to turn the option on, to let them know that it doesn't work here.
This commit is contained in:
committed by
Jesse Duffield
parent
a2778f01c6
commit
7d4bfb6621
@ -1,7 +1,9 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type ToggleWhitespaceAction struct {
|
||||
@ -9,6 +11,18 @@ type ToggleWhitespaceAction struct {
|
||||
}
|
||||
|
||||
func (self *ToggleWhitespaceAction) Call() error {
|
||||
contextsThatDontSupportIgnoringWhitespace := []types.ContextKey{
|
||||
context.STAGING_MAIN_CONTEXT_KEY,
|
||||
context.STAGING_SECONDARY_CONTEXT_KEY,
|
||||
context.PATCH_BUILDING_MAIN_CONTEXT_KEY,
|
||||
}
|
||||
|
||||
if lo.Contains(contextsThatDontSupportIgnoringWhitespace, self.c.CurrentContext().GetKey()) {
|
||||
// Ignoring whitespace is not supported in these views. Let the user
|
||||
// know that it's not going to work in case they try to turn it on.
|
||||
return self.c.ErrorMsg(self.c.Tr.IgnoreWhitespaceNotSupportedHere)
|
||||
}
|
||||
|
||||
self.c.State().SetIgnoreWhitespaceInDiffView(!self.c.State().GetIgnoreWhitespaceInDiffView())
|
||||
|
||||
toastMessage := self.c.Tr.ShowingWhitespaceInDiffView
|
||||
|
Reference in New Issue
Block a user