{"record":{"id":"e5225262ac729529","repo":"neoclide/coc.nvim","slug":"document-not-attached","errorCode":null,"errorMessage":"Document not attached","messagePattern":"Document not attached","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/handler/symbols/outline.ts","lineNumber":184,"sourceCode":"        return a.kind - b.kind\n      }\n      return comparePosition(a.selectRange.start, b.selectRange.start)\n    }\n    return symbols.map(s => this.convertSymbolToNode(s, sortFn)).sort(sortFn)\n  }\n\n  public onSymbolsUpdate(bufnr: number, symbols: DocumentSymbol[]): void {\n    let provider = this.providersMap.get(bufnr)\n    if (provider) provider.update(this.convertSymbols(bufnr, symbols))\n  }\n\n  private createProvider(bufnr: number): BasicDataProvider<OutlineNode> {\n    let { nvim } = this\n    let provider = new BasicDataProvider({\n      expandLevel: this.config.expandLevel,\n      provideData: async () => {\n        let buf = this.buffers.getItem(bufnr)\n        if (!buf) throw new Error('Document not attached')\n        let doc = workspace.getDocument(bufnr)\n        if (!languages.hasProvider(ProviderName.DocumentSymbol, doc.textDocument)) {\n          throw new Error('Document symbol provider not found')\n        }\n        let meta = languages.getDocumentSymbolMetadata(doc.textDocument)\n        if (meta && meta.label) {\n          let views = this.treeViewList.filter(v => v.valid && v.targetBufnr == bufnr)\n          views.forEach(view => view.description = meta.label)\n        }\n        this.setMessage(bufnr, 'Loading document symbols')\n        let arr = await buf.getSymbols()\n        if (!arr || arr.length == 0) {\n          // server may return empty symbols on buffer initialize, throw error to force reload.\n          throw new Error('Empty symbols returned from language server. ')\n        }\n        this.setMessage(bufnr, undefined)\n        return this.convertSymbols(bufnr, arr)\n      },","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/handler/symbols/outline.ts#L166-L202","documentation":"Thrown by the outline (DocumentSymbol) tree data provider when its provideData callback runs and the requested buffer (bufnr) is no longer a tracked/attached document in coc's buffer collection. The outline view cannot fetch symbols for a document coc is not managing.","triggerScenarios":"Opening the outline (:CocOutline) for a buffer, then the buffer is deleted, wiped (`:bwipe`), unloaded, or was never attached (e.g. non-opened scratch/quickfix/help buffer), and the tree view later refreshes and calls provideData with the stale bufnr.","commonSituations":"Keeping an outline window open while cycling buffers and closing the source buffer; running :CocOutline in a non-file buffer (nofile buftype); using a session that restored a deleted buffer; coc restart clearing the buffers registry while an old tree view remains.","solutions":["Reopen the outline (:CocOutline) from the buffer you want; a fresh bufnr resolves it.","Check the buffer is a normal attached file buffer: run :CocCommand workspace.showOutput or `:echo getbufvar(bufnr,'&buftype')` — use real file buffers for outline.","Restart coc (:CocRestart) to resync the buffers collection and reopen the outline.","Close stale tree views; upgrade coc.nvim if outline windows persistently outlive their buffers."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// vimscript: only run outline on attached, normal buffers\nif empty(getbufvar(bufnr, 'coc_diagnostic_info')) && &buftype !=# ''\n  echom 'Outline not available for this buffer'\nelse\n  CocOutline\nendif","typeGuard":null,"tryCatchPattern":"try {\n  await outline.show(bufnr)\n} catch (e) {\n  if (String(e).includes('Document not attached')) {\n    // stale view: reopen outline for the current buffer\n  }\n}","preventionTips":["Open the outline only from a normal file buffer that coc has attached.","Close outline windows when their source buffer is wiped/deleted.","Avoid non-file buftypes (nofile, quickfix, help) as outline targets.","After :CocRestart, reopen the outline instead of relying on old views."],"tags":["outline","document-symbols","buffer-attach","coc-nvim"],"backgroundTag":"document-not-attached","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}