jesseduffield/lazygit · warning
Cannot change the rename similarity threshold while in patch
Error message
Cannot change the rename similarity threshold while in patch building mode, because the custom patch can't cope with a rename turning into a delete and add underneath it.
What it means
Returned by RenameSimilarityThresholdController.checkCanChangeThreshold when the custom patch builder is active (Git().Patch.PatchBuilder.Active()). Rename detection affects how diffs are decomposed; if a rename turns into a delete+add while a custom patch is being built, the patch's file list becomes invalid, so the threshold cannot be changed mid-patch-building.
Source
Thrown at pkg/gui/controllers/rename_similarity_threshold_controller.go:100
currentContext := self.c.Context().CurrentSide()
switch currentContext.GetKey() {
// we make an exception for the files and commit-files contexts, because
// they actually need to refresh their state afterwards: a changed threshold
// can turn a rename into a separate delete and add, or vice versa.
case context.FILES_CONTEXT_KEY:
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}})
case context.COMMIT_FILES_CONTEXT_KEY:
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMIT_FILES}})
default:
currentContext.HandleRenderToMain()
}
return nil
}
func (self *RenameSimilarityThresholdController) checkCanChangeThreshold() error {
if self.c.Git().Patch.PatchBuilder.Active() {
return errors.New(self.c.Tr.CantChangeRenameThresholdError)
}
return nil
}
View on GitHub (pinned to c477a2959b)
Solutions
- Finish or discard the custom patch first (clear the patch), then change the threshold.
- Reset patch building via the patch-building menu's reset option and retry the threshold toggle.
- Set git.renameSimilarityThreshold (or similar) in config beforehand so no in-session change is needed.
Defensive patterns
Strategy: validation
Validate before calling
if self.c.Git().Patch.PatchBuilder.Active() {
// defer threshold change until patch building is done
} Prevention
- Check PatchBuilder.Active() before exposing the rename-threshold action.
- Set the similarity threshold in config ahead of starting patch building.
- Reset the in-progress patch before changing diff-affecting settings.
When it happens
Trigger: Pressing the rename-similarity-threshold keybinding while a custom patch is in progress in the commit-files / files diff view (PatchBuilder.Active() == true).
Common situations: User is staging selected lines/hunks and simultaneously wants to tune rename detection; forgot they are mid patch-building from an earlier partial-stage.
Related errors
- git.diffRenderers: 'command' must be specified for diff rend
- git.diffRenderers: 'args' cannot be used with diff renderer
- git.diffRenderers: 'args' cannot be used with diff renderer
- git.diffRenderers: 'command' cannot be used with diff render
- Cannot change context while in patch building mode because w
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/53bb3fb1ea134e88.
Report an issue: GitHub.