mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 11:02:41 +03:00
When toggling the value in the UI we simply overwrite the value in UserConfig; this would be bad if there was ever a chance that we want to write the user config back to disk, but it is very unlikely that we can do that, because currently we have no way to tell which parts of the config come from the global config file and which ones come from a repo-local one.
33 lines
965 B
Go
33 lines
965 B
Go
package controllers
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
"github.com/samber/lo"
|
|
)
|
|
|
|
type ToggleWhitespaceAction struct {
|
|
c *ControllerCommon
|
|
}
|
|
|
|
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.Context().Current().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 errors.New(self.c.Tr.IgnoreWhitespaceNotSupportedHere)
|
|
}
|
|
|
|
self.c.UserConfig().Git.IgnoreWhitespaceInDiffView = !self.c.UserConfig().Git.IgnoreWhitespaceInDiffView
|
|
|
|
self.c.Context().CurrentSide().HandleFocus(types.OnFocusOpts{})
|
|
return nil
|
|
}
|