You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The vscode.window.showTextDocument method supports only Theia URIs, and is incompatible with the VSCode URI passed as an argument when an editor/context menu command is executed.
Steps to Reproduce:
Create a VS Code extension that contributes an editor/context menu command named theia.sampleCommand, and registers a handler like the following:
vscode.commands.registerCommand("theia.sampleCommand",async(uri)=>{// Ensure document is open and not in preview modevscode.window.showTextDocument(uri,{preview: false});// Do other stuffvscode.window.showInformationMessage(uri.toString());});
Install the extension in Theia and trigger the command by clicking it in editor context menu.
Note that the info message never appears, and there is an error in the console:
Uncaught (in promise)
TypeError: Cannot read properties of undefined (reading 'toString')
at DocumentsExtImpl.showDocument (:3000/home/theia/nod…documents.js:192:63)
at Object.showTextDocument (:3000/home/theia/nod…n-context.js:232:33)
at Object.<anonymous> (:3000/home/theia/.th…ension.js:33:299442)
at Generator.next (<anonymous>)
at :3000/home/theia/.th…ension.js:33:276506
at new Promise (<anonymous>)
at r (:3000/home/theia/.th…ension.js:33:276251)
at t.submitJcl (:3000/home/theia/.th…ension.js:33:299223)
at Object.<anonymous> (:3000/home/theia/.th…ension.js:90:501340)
at Generator.next (<anonymous>)
Additional Information
Operating System: Alpine Linux (Docker)
Theia Version: 1.49.1
I believe I've tracked this down to the following line in showTextDocument, which has an instanceof check for Theia URIs:
Since the URI passed to the command handler is a VSCode URI (from @theia/core/shared/vscode-uri), it fails the instanceof check that expects a Theia URI, resulting in document.uri evaluating to undefined.
The text was updated successfully, but these errors were encountered:
Bug Description:
The
vscode.window.showTextDocument
method supports only Theia URIs, and is incompatible with the VSCode URI passed as an argument when aneditor/context
menu command is executed.Steps to Reproduce:
editor/context
menu command namedtheia.sampleCommand
, and registers a handler like the following:Additional Information
I believe I've tracked this down to the following line in
showTextDocument
, which has aninstanceof
check for Theia URIs:theia/packages/plugin-ext/src/plugin/plugin-context.ts
Line 442 in 7cbfc7a
When
editor/context
menu command is executed, the argument passed is an instance ofCodeUri
which is populated by thegetSelectedResources
method:theia/packages/plugin-ext/src/main/browser/menus/plugin-menu-command-adapter.ts
Lines 324 to 335 in 7cbfc7a
Since the URI passed to the command handler is a VSCode URI (from
@theia/core/shared/vscode-uri
), it fails theinstanceof
check that expects a Theia URI, resulting indocument.uri
evaluating to undefined.The text was updated successfully, but these errors were encountered: