[BUG] Claude Code VS Code extension opens files with `showTextDocument`, bypassing custom editor associations
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When clicking a file link/reference in the Claude Code VS Code chat panel (e.g., a .md file path mentioned by Claude), the file always opens in VS Code's built-in text editor, ignoring the user's workbench.editorAssociations setting and any custom editors registered for that file type.
The extension uses vscode.workspace.openTextDocument() + vscode.window.showTextDocument() to open files. This API explicitly opens files as text documents in the built-in text editor, bypassing VS Code's editor resolution system entirely.
Opening the same file from the VS Code Explorer works correctly and respects custom editor associations.
What Should Happen?
Clicking a file link in the Claude Code chat panel should respect the user's workbench.editorAssociations setting and open the file in the configured custom editor. For example, if a user has:
"workbench.editorAssociations": {
"*.md": "msharp.customEditor"
}
A .md file link should open in Mark Sharp (or whichever custom editor is configured), not the built-in text editor.
Error Messages/Logs
No error messages. The file opens successfully, but in the wrong editor.
Affected code paths in `extension.js` (v2.1.83):
1. **File link handler** (~offset 1601875):
t.window.showTextDocument(x).then((W) => {
if (V?.searchText) { /* highlight logic */ }
})
2. **Secondary file open path** (~offset 1663808):
U = await g4.window.showTextDocument(q, {preview: V, preserveFocus: !B});
---
#
Steps to Reproduce
- Install a custom editor extension (e.g., [Mark Sharp](https://marketplace.visualstudio.com/items?itemName=jonathan-yeung.mark-sharp) for Markdown)
- Configure it as default in
settings.json:
``json``
"workbench.editorAssociations": {
"*.md": "msharp.customEditor"
}
- Verify it works from the VS Code Explorer — open any
.mdfile, it opens in the custom editor
- Open the Claude Code chat panel and have Claude reference or output a
.mdfile path
- Click the file link in the chat output
- Actual: file opens in the built-in text editor
- Expected: file opens in the configured custom editor (Mark Sharp)
Note: This is most noticeable in Remote SSH workspaces where the Claude Code extension runs on the remote server.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.83
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
Root cause
The extension uses vscode.window.showTextDocument() which forces the built-in text editor. The correct API is vscode.commands.executeCommand('vscode.open', uri) which goes through VS Code's editor resolver and respects workbench.editorAssociations and custom editor registrations.
Working patch (v2.1.83)
The following two sed replacements against extension.js fix the issue. For Remote SSH workspaces, apply to the remote copy at ~/.vscode-server/extensions/anthropic.claude-code-<version>-linux-x64/extension.js.
Patch 1 — file link handler:
sed -i 's|t.window.showTextDocument(x).then((W)=>{if(V?.searchText){let B=W.document|t.commands.executeCommand("vscode.open",x).then(()=>{let W=t.window.activeTextEditor;if(!W)return;if(V?.searchText){let B=W.document|' extension.js
Patch 2 — secondary file open path:
sed -i 's|U=await g4.window.showTextDocument(q,{preview:V,preserveFocus:!B})|U=(await g4.commands.executeCommand("vscode.open",v,{preview:V,preserveFocus:!B}),g4.window.activeTextEditor)|' extension.js
What the patches do:
- Replace
vscode.window.showTextDocument()(forces built-in text editor) withvscode.commands.executeCommand("vscode.open", uri)(goes through VS Code's editor resolver) - After opening, retrieve
activeTextEditorfor search/highlight logic; gracefully no-ops if the file opened in a custom editor where noTextEditoris available
Patches are overwritten on extension update.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗