Hi folks, when working on https://github.com/theia-ide/theia/issues/4084, I have come across two issues related to the execution of arbitrary commands. Commands, for example, are passed from plugins to theia when executing code actions.
In Theia, there are two command registries: the first is the “global” one, where you can register commands that are not editor related. The second one is the command registry of the embeded monaco editor. This command registry delegates to the global registry when executing commands that are not related to the current editor.
The first problem we’re facing, then is that the plugin API only delegates to the global registry. Editor-related commands like “editor.action.showReferences” are therefore not found. My proposed fix for this would be to delegate command execution to the current editor. If no editor is open, the command is passed to the global registry for execution.
The second problem relates to the parameters array that can be passed with the commands: For example, the “showReferences” command has a vscode.Position as a parameter. However, we are implementing Position with “_line” and “_character” private variables and property accessor methods. But class information does not survive the travel through the plugin API, so when we later interpret the passed parameter as a position, it will not be the class type “Position”, but just an object with none of the fields “line” nor “character” set.
The alternative to always converting those classes would be to only do it for certain, well known commands (see https://code.visualstudio.com/api/references/commands). I find that more “correct”, but I’d like to to hear opinions on this.
[original thread by Thomas Mäder]