{"record":{"id":"340b876455c2efcf","repo":"neoclide/coc.nvim","slug":"provider-returns-null-on-prepare-unable-to-rename","errorCode":null,"errorMessage":"Provider returns null on prepare, unable to rename at current position","messagePattern":"Provider returns null on prepare, unable to rename at current position","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/handler/refactor/index.ts","lineNumber":75,"sourceCode":"      openCommand: config.get('openCommand', 'vsplit'),\n      saveToFile: config.get('saveToFile', true),\n      showMenu: config.get('showMenu', '<Tab>')\n    })\n  }\n\n  /**\n   * Refactor of current symbol\n   */\n  public async doRefactor(): Promise<void> {\n    let { doc, position } = await this.handler.getCurrentState()\n    if (!languages.hasProvider(ProviderName.Rename, doc.textDocument)) {\n      throw new Error(`Rename provider not found for current buffer`)\n    }\n    await doc.synchronize()\n    let edit = await this.handler.withRequestToken('refactor', async token => {\n      let res = await languages.prepareRename(doc.textDocument, position, token)\n      if (token.isCancellationRequested) return null\n      if (res === false) throw new Error(`Provider returns null on prepare, unable to rename at current position`)\n      let edit = await languages.provideRenameEdits(doc.textDocument, position, 'NewName', token)\n      if (token.isCancellationRequested) return null\n      if (!edit) throw new Error('Provider returns null for rename edits.')\n      return edit\n    })\n    if (edit) {\n      await this.fromWorkspaceEdit(edit, doc.filetype)\n    }\n  }\n\n  /**\n   * Search by rg\n   */\n  public async search(args: string[]): Promise<void> {\n    let buf = await this.createRefactorBuffer()\n    let cwd = await this.nvim.call('getcwd', []) as string\n    let search = new Search(this.nvim)\n    await search.run(args, cwd, buf)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/handler/refactor/index.ts#L57-L93","documentation":"During doRefactor, the `textDocument/prepareRename` request returned `false` (or was treated as failed) at the current position, meaning the server explicitly says the symbol under the cursor cannot be renamed. coc.nvim surfaces this as the prepare-null error.","triggerScenarios":"Cursor is on a token the server disallows renaming (keyword, comment, whitespace, generated/readonly symbol); server implements prepareRename and returns false or null for the position; request raced with document changes.","commonSituations":"Cursor not exactly on an identifier (e.g. on a brace or inside a string); renaming imported/readonly module paths the server marks immutable; stale cursor position after buffer edits.","solutions":["Place the cursor directly on the symbol to rename and retry.","Verify the symbol is renameable in this server (try plain `:CocRename` to compare).","Wait for document diagnostics/indexing to settle (server may reject during heavy edits).","Check server output for the prepareRename response details via `:CocCommand workspace.showOutput`."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await coc.commands.executeCommand('document.renameRefactor')\n} catch (e) {\n  if (String(e?.message).includes('Provider returns null on prepare'))\n    return vim.notify('Cursor is not on a renameable symbol')\n  throw e\n}","preventionTips":["Place the cursor exactly on the identifier before renaming","Wait for the server to finish indexing after large edits","Compare with `:CocRename` to confirm the server's stance on the symbol"],"tags":["lsp","rename","prepare-rename","coc-nvim"],"backgroundTag":"rename-not-allowed-at-position","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}