{"record":{"id":"395d93ed14b34a2a","repo":"neoclide/coc.nvim","slug":"action-action-title-is-disabled-action-dis","errorCode":null,"errorMessage":"Action \"${action.title}\" is disabled: ${action.disabled.reason}","messagePattern":"Action \"(.+?)\" is disabled: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/handler/codeActions.ts","lineNumber":193,"sourceCode":"    return codeActions.filter(o => !o.disabled)\n  }\n\n  /**\n   * Invoke preferred quickfix at current position\n   */\n  public async doQuickfix(): Promise<void> {\n    let actions = await this.getCurrentCodeActions('currline', [CodeActionKind.QuickFix])\n    if (!actions || actions.length == 0) {\n      void window.showWarningMessage(`No quickfix action available`)\n      return\n    }\n    await this.applyCodeAction(actions[0])\n    this.nvim.command(`silent! call repeat#set(\"\\\\<Plug>(coc-fix-current)\", -1)`, true)\n  }\n\n  public async applyCodeAction(action: CodeAction, token?: CancellationToken): Promise<void> {\n    if (action.disabled) {\n      throw new Error(`Action \"${action.title}\" is disabled: ${action.disabled.reason}`)\n    }\n    token = token == null ? CancellationToken.None : token\n    let resolved = await languages.resolveCodeAction(action, token)\n    if (!resolved || token.isCancellationRequested) return\n    let { edit, command } = resolved\n    if (edit) await workspace.applyEdit(edit)\n    if (command) await commandManager.execute(command)\n  }\n}\n\nexport function shouldAutoApply(only: CodeActionKind[] | string | undefined): boolean {\n  if (!only) return false\n  if (typeof only === 'string' || only[0] === CodeActionKind.QuickFix || only[0] === CodeActionKind.SourceFixAll) {\n    return workspace.initialConfiguration.get('coc.preferences.autoApplySingleQuickfix', true)\n  }\n  return false\n}\n","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/handler/codeActions.ts#L175-L211","documentation":"Thrown by applyCodeAction when the chosen CodeAction carries a disabled property with a reason — the LSP server explicitly marked this action as not applicable. coc surfaces the server's reason instead of silently doing nothing.","triggerScenarios":"Executing a code action returned by the server with `disabled: {reason}` — e.g. via doCodeAction/doQuickfix picking actions[0], organizeImport, or codeActionRange when the first returned action is disabled.","commonSituations":"Quickfix lists an action that's invalid in current context (server marks it disabled); refactor requested where the server disallows it; stale actions cached after buffer change.","solutions":["Choose a different, non-disabled code action (:CocAction codeAction list and pick another)","Re-request code actions after saving/editing so the server re-evaluates applicability","Check the reason in the message and fix the underlying condition (e.g. selection range, unsaved changes)"],"exampleFix":"// before\nconst actions = await codeActions.getCodeActions('quickfix')\nawait codeActions.applyCodeAction(actions[0])\n// after\nconst actions = (await codeActions.getCodeActions('quickfix')).filter(a => !a.disabled)\nawait codeActions.applyCodeAction(actions[0])","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isDisabledAction(a) { return typeof a === 'object' && a !== null && 'disabled' in a && a.disabled != null; }\n// use: actions.filter(a => !isDisabledAction(a))","tryCatchPattern":"try {\n  await codeActions.applyCodeAction(action);\n} catch (e) {\n  if (String(e.message).includes('is disabled')) {\n    console.warn(String(e.message).match(/disabled: (.*)/)?.[1] ?? 'action unavailable');\n    return;\n  }\n  throw e;\n}","preventionTips":["Filter out disabled actions before executing","Re-fetch code actions after edits (they go stale)","Surface disabled reasons to users instead of picking actions[0] blindly"],"tags":["lsp","code-action","disabled"],"backgroundTag":"code-action-disabled","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}