jesseduffield/lazygit · info

Cannot change context while in patch building mode because w

Error message

Cannot change context while in patch building mode because we were too lazy to support it when releasing the feature. If you really want it, please let us know!

What it means

Thrown by ContextLinesController.checkCanChangeContextSize when the user attempts to change the diff context size (the '+'/'-' controls for context lines shown around hunks) while the patch builder is active. Resizing context while a patch is being built would change which lines the patch contains, and that interaction was never implemented, so lazygit blocks it outright (the message even jokes about it).

Source

Thrown at pkg/gui/controllers/context_lines_controller.go:93

func (self *ContextLinesController) applyChange() error {
	self.c.Toast(fmt.Sprintf(self.c.Tr.DiffContextSizeChanged, self.c.UserConfig().Git.DiffContextSize))

	currentContext := self.c.Context().CurrentSide()
	switch currentContext.GetKey() {
	// we make an exception for our staging and patch building contexts because they actually need to refresh their state afterwards.
	case context.PATCH_BUILDING_MAIN_CONTEXT_KEY:
		self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.PATCH_BUILDING}})
	case context.STAGING_MAIN_CONTEXT_KEY, context.STAGING_SECONDARY_CONTEXT_KEY:
		self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STAGING}})
	default:
		currentContext.HandleRenderToMain()
	}
	return nil
}

func (self *ContextLinesController) checkCanChangeContext() error {
	if self.c.Git().Patch.PatchBuilder.Active() {
		return errors.New(self.c.Tr.CantChangeContextSizeError)
	}

	return nil
}

View on GitHub (pinned to c477a2959b)

Solutions

  1. Apply, reset, or otherwise finish the in-progress patch (custom patch options menu, 'c' in patch mode), then change the context size
  2. If you need more context to select lines, increase context before starting patch building
Defensive patterns

Strategy: validation

Validate before calling

// Gate context-size changes on patch-builder state, as the controller does:
if patchBuilder.Active() {
    return errors.New("finish or reset the patch before changing context size")
}

Prevention

When it happens

Trigger: Building a custom patch (lines/files added to the patch builder) and then pressing the increase/decrease context keys before applying or resetting the patch.

Common situations: Users building a cherry-pick/revert-style partial patch who want more surrounding context to pick lines accurately — they must finish or reset the patch first.

Related errors


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