neoclide/coc.nvim · error · Error

Action "${action.title}" is disabled: ${action.disabled.reas

Error message

Action "${action.title}" is disabled: ${action.disabled.reason}

What it means

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.

Source

Thrown at src/handler/codeActions.ts:193

    return codeActions.filter(o => !o.disabled)
  }

  /**
   * Invoke preferred quickfix at current position
   */
  public async doQuickfix(): Promise<void> {
    let actions = await this.getCurrentCodeActions('currline', [CodeActionKind.QuickFix])
    if (!actions || actions.length == 0) {
      void window.showWarningMessage(`No quickfix action available`)
      return
    }
    await this.applyCodeAction(actions[0])
    this.nvim.command(`silent! call repeat#set("\\<Plug>(coc-fix-current)", -1)`, true)
  }

  public async applyCodeAction(action: CodeAction, token?: CancellationToken): Promise<void> {
    if (action.disabled) {
      throw new Error(`Action "${action.title}" is disabled: ${action.disabled.reason}`)
    }
    token = token == null ? CancellationToken.None : token
    let resolved = await languages.resolveCodeAction(action, token)
    if (!resolved || token.isCancellationRequested) return
    let { edit, command } = resolved
    if (edit) await workspace.applyEdit(edit)
    if (command) await commandManager.execute(command)
  }
}

export function shouldAutoApply(only: CodeActionKind[] | string | undefined): boolean {
  if (!only) return false
  if (typeof only === 'string' || only[0] === CodeActionKind.QuickFix || only[0] === CodeActionKind.SourceFixAll) {
    return workspace.initialConfiguration.get('coc.preferences.autoApplySingleQuickfix', true)
  }
  return false
}

View on GitHub (pinned to 50e974d969)

Solutions

  1. Choose a different, non-disabled code action (:CocAction codeAction list and pick another)
  2. Re-request code actions after saving/editing so the server re-evaluates applicability
  3. Check the reason in the message and fix the underlying condition (e.g. selection range, unsaved changes)

Example fix

// before
const actions = await codeActions.getCodeActions('quickfix')
await codeActions.applyCodeAction(actions[0])
// after
const actions = (await codeActions.getCodeActions('quickfix')).filter(a => !a.disabled)
await codeActions.applyCodeAction(actions[0])
Defensive patterns

Strategy: type-guard

Type guard

function isDisabledAction(a) { return typeof a === 'object' && a !== null && 'disabled' in a && a.disabled != null; }
// use: actions.filter(a => !isDisabledAction(a))

Try / catch

try {
  await codeActions.applyCodeAction(action);
} catch (e) {
  if (String(e.message).includes('is disabled')) {
    console.warn(String(e.message).match(/disabled: (.*)/)?.[1] ?? 'action unavailable');
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31). Data as JSON: /api/errors/395d93ed14b34a2a. Report an issue: GitHub.