{"record":{"id":"b6349c2b86ca8f5e","repo":"jesseduffield/lazygit","slug":"disabledreason-text","errorCode":null,"errorMessage":"{{disabledReason.Text}}","messagePattern":"\\{\\{disabledReason\\.Text\\}\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/gui/keybindings.go","lineNumber":406,"sourceCode":"\n\tfor _, key := range binding.Keys {\n\t\tgui.g.SetKeybinding(binding.ViewName, key, handler)\n\t}\n}\n\nfunc (gui *Gui) SetMouseKeybinding(binding *gocui.ViewMouseBinding) error {\n\treturn gui.g.SetViewClickBinding(binding)\n}\n\nfunc (gui *Gui) callKeybindingHandler(binding *types.Binding) error {\n\tif binding.GetDisabledReason != nil {\n\t\tif disabledReason := binding.GetDisabledReason(); disabledReason != nil {\n\t\t\tif disabledReason.AllowFurtherDispatching {\n\t\t\t\treturn &types.ErrKeybindingNotHandled{DisabledReason: disabledReason}\n\t\t\t}\n\n\t\t\tif disabledReason.ShowErrorInPanel {\n\t\t\t\treturn errors.New(disabledReason.Text)\n\t\t\t}\n\n\t\t\tif len(disabledReason.Text) > 0 {\n\t\t\t\tgui.c.ErrorToast(gui.Tr.DisabledMenuItemPrefix + disabledReason.Text)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn binding.Handler()\n}\n","sourceCodeStart":388,"sourceCodeEnd":418,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/keybindings.go#L388-L418","documentation":"Returned when a keybinding's GetDisabledReason callback produces a DisabledReason with ShowErrorInPanel set, meaning the action is unavailable and the reason must be surfaced in the error panel rather than as a toast. callKeybindingHandler converts disabledReason.Text into a plain errors.New value instead of running binding.Handler. It is lazygit's way of saying 'this key is bound but not usable in the current context'.","triggerScenarios":"Pressing a key whose binding is disabled in the current view state where the disabled reason explicitly requests panel display (ShowErrorInPanel=true), e.g. acting on a worktree/branch/submodule that does not support the operation. Also produced when AllowFurtherDispatching is false and ShowErrorInPanel is true on the returned DisabledReason.","commonSituations":"Pressing a shortcut in a view where the selection type doesn't support it (e.g. delete on a special branch), or a plugin/custom command binding whose disabled condition now triggers after a state change.","solutions":["Read the error text: it names exactly why the action is disabled (e.g. 'cannot X in this context'); fix that precondition first.","Check the current view's selection/state that the keybinding's GetDisabledReason checks in pkg/gui/controllers/","If the keybinding comes from user config (custom keybinding), verify it isn't bound to a context where its handler is invalid.","If you believe the action should be available, file an issue: the disabled-reason guard may be too strict for your state."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before invoking an action programmatically, check whether its binding is disabled:\nif binding.GetDisabledReason != nil {\n    if reason := binding.GetDisabledReason(); reason != nil {\n        // skip / show reason.Text; do not call the handler\n        return reason.Text\n    }\n}\nreturn binding.Handler()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat disabled-reason errors as expected control flow, not failures; match on the DisabledReason before invoking handlers.","When adding custom keybindings, test them in each view/context where they may fire.","UI code should render DisabledReason.Text via toasts/panel instead of generic error handling."],"tags":["keybindings","gui","disabled-action","lazygit"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}