jesseduffield/lazygit · info

Ignoring whitespace is not supported in this view

Error message

Ignoring whitespace is not supported in this view

What it means

Returned by ToggleWhitespaceAction.Call when the user toggles 'ignore whitespace in diff view' while the current context is one of the staging main/secondary or patch-building main contexts. Those views implement custom line-level diff handling that cannot reproduce a whitespace-ignoring diff, so the toggle is blocked with an explanatory message.

Source

Thrown at pkg/gui/controllers/toggle_whitespace_action.go:25

	"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
}

View on GitHub (pinned to c477a2959b)

Solutions

  1. Leave the staging/patch-building view (escape back to the files or commits panel) before toggling whitespace ignoring.
  2. Set git.ignoreWhitespaceInDiffView: true in the config so it is already on before entering staging.
  3. Stage at the hunk/line level with whitespace noise in mind, or fix the whitespace in a separate commit first.

Example fix

# before
# toggled while inside staging view -> error

# after
# ~/.config/lazygit/config.yml
git:
  ignoreWhitespaceInDiffView: true
Defensive patterns

Strategy: validation

Validate before calling

unsupported := []types.ContextKey{
    context.STAGING_MAIN_CONTEXT_KEY,
    context.STAGING_SECONDARY_CONTEXT_KEY,
    context.PATCH_BUILDING_MAIN_CONTEXT_KEY,
}
if lo.Contains(unsupported, self.c.Context().Current().GetKey()) {
    // hide/disable the whitespace toggle in this context
}

Prevention

When it happens

Trigger: Pressing the ignore-whitespace keybinding while focused on STAGING_MAIN, STAGING_SECONDARY, or PATCH_BUILDING_MAIN context (lo.Contains match on the context key list).

Common situations: User is mid line-staging and wants to ignore indentation noise from a refactor; toggle attempted without leaving the staging view first.

Related errors


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/c0982c332cba88bc. Report an issue: GitHub.