Open t1m0thyj opened 1 month ago
Hey @t1m0thyj, thanks for the report and the investigation on the issue.
Since you already looked into this, are you interested in contributing a fix?
@msujew Sure, I'd be happy to. Which approach would you prefer for a fix?
instanceof
check less restrictive by checking for VS Code URIgetSelectedResources
method to return an array of Theia URIsI'm leaning towards the first option since it seems like a less impactful change.
@t1m0thyj I also think the first option is better 👍
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: https://github.com/eclipse-theia/theia/blob/7cbfc7a6d99c0317f5e741875dd9097e4eb74c97/packages/plugin-ext/src/plugin/plugin-context.ts#L442When
editor/context
menu command is executed, the argument passed is an instance ofCodeUri
which is populated by thegetSelectedResources
method: https://github.com/eclipse-theia/theia/blob/7cbfc7a6d99c0317f5e741875dd9097e4eb74c97/packages/plugin-ext/src/main/browser/menus/plugin-menu-command-adapter.ts#L324-L335Since 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.