{"record":{"id":"4b92fda5f6e43159","repo":"jesseduffield/lazygit","slug":"cannot-change-context-while-in-patch-building-mode","errorCode":null,"errorMessage":"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!","messagePattern":"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!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/gui/controllers/context_lines_controller.go","lineNumber":93,"sourceCode":"func (self *ContextLinesController) applyChange() error {\n\tself.c.Toast(fmt.Sprintf(self.c.Tr.DiffContextSizeChanged, self.c.UserConfig().Git.DiffContextSize))\n\n\tcurrentContext := self.c.Context().CurrentSide()\n\tswitch currentContext.GetKey() {\n\t// we make an exception for our staging and patch building contexts because they actually need to refresh their state afterwards.\n\tcase context.PATCH_BUILDING_MAIN_CONTEXT_KEY:\n\t\tself.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.PATCH_BUILDING}})\n\tcase context.STAGING_MAIN_CONTEXT_KEY, context.STAGING_SECONDARY_CONTEXT_KEY:\n\t\tself.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STAGING}})\n\tdefault:\n\t\tcurrentContext.HandleRenderToMain()\n\t}\n\treturn nil\n}\n\nfunc (self *ContextLinesController) checkCanChangeContext() error {\n\tif self.c.Git().Patch.PatchBuilder.Active() {\n\t\treturn errors.New(self.c.Tr.CantChangeContextSizeError)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":75,"sourceCodeEnd":98,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/context_lines_controller.go#L75-L98","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Apply, reset, or otherwise finish the in-progress patch (custom patch options menu, 'c' in patch mode), then change the context size","If you need more context to select lines, increase context before starting patch building"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Gate context-size changes on patch-builder state, as the controller does:\nif patchBuilder.Active() {\n    return errors.New(\"finish or reset the patch before changing context size\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set the desired context-lines value before entering patch-building mode","Reset the patch before adjusting diff context","Bind context-size keys where they are disabled during active patches to avoid surprise"],"tags":["lazygit","patch-building","context-size","feature-limitation"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}