diff --git a/pkg/gui/controllers/toggle_whitespace_action.go b/pkg/gui/controllers/toggle_whitespace_action.go index 56eb023f3..746d18bdf 100644 --- a/pkg/gui/controllers/toggle_whitespace_action.go +++ b/pkg/gui/controllers/toggle_whitespace_action.go @@ -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 diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 5e34022d3..c1d0b6c0c 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -483,6 +483,7 @@ type TranslationSet struct { ToggleWhitespaceInDiffView string IgnoringWhitespaceInDiffView string ShowingWhitespaceInDiffView string + IgnoreWhitespaceNotSupportedHere string IncreaseContextInDiffView string DecreaseContextInDiffView string CreatePullRequestOptions string @@ -1154,6 +1155,7 @@ func EnglishTranslationSet() TranslationSet { ToggleWhitespaceInDiffView: "Toggle whether or not whitespace changes are shown in the diff view", IgnoringWhitespaceInDiffView: "Whitespace will be ignored in the diff view", ShowingWhitespaceInDiffView: "Whitespace will be shown in the diff view", + IgnoreWhitespaceNotSupportedHere: "Ignoring whitespace is not supported in this view", IncreaseContextInDiffView: "Increase the size of the context shown around changes in the diff view", DecreaseContextInDiffView: "Decrease the size of the context shown around changes in the diff view", CreatePullRequest: "Create pull request",