Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workspace: add command mapping to plugin-system #9840

Closed
vince-fugnitto opened this issue Aug 4, 2021 · 5 comments · Fixed by #10039
Closed

workspace: add command mapping to plugin-system #9840

vince-fugnitto opened this issue Aug 4, 2021 · 5 comments · Fixed by #10039
Labels
beginners issues that are perfect for beginners good first issue good first issues for new contributors plug-in system issues related to the plug-in system

Comments

@vince-fugnitto
Copy link
Member

Feature Description:

The command workspace:openConfigFile requires a mapping in the plugin system to be able to be executable by vscode plugins. We should therefore add an appropriate mapping for workbench.action.openWorkspaceConfigFile (vscode command id) to the plugin system like so:

commands.registerCommand({ id: 'workbench.action.openWorkspaceConfigFile'}, {
    execute: () => commands.executeCommand(WorkspaceCommands.OPEN_WORKSPACE_FILE.id)
});

at:

commands.registerCommand({ id: 'workbench.action.openSettings' }, {
execute: (query?: string) => commands.executeCommand(CommonCommands.OPEN_PREFERENCES.id, query)
});

@vince-fugnitto vince-fugnitto added beginners issues that are perfect for beginners good first issue good first issues for new contributors plug-in system issues related to the plug-in system labels Aug 4, 2021
@dineshUmasankar
Copy link
Contributor

Is there a way to test this command's functionality?
I have taken the liberty of adding this command mapping into the plugin system through the provided code, but curious on where / how to write up a test for this command mapping's functionality.

@vince-fugnitto
Copy link
Member Author

Is there a way to test this command's functionality?
I have taken the liberty of adding this command mapping into the plugin system through the provided code, but curious on where / how to write up a test for this command mapping's functionality.

@dineshUmasankar generally you would create a vscode plugin that uses this functionality, package it and include it in the framework for test purposes. You can then execute these commands and confirm the behavior is correct.

@dineshUmasankar
Copy link
Contributor

dineshUmasankar commented Aug 31, 2021

I would like to be assigned to this task if possible, but I require some help clarifying workspace:openConfigFile.

I have made a vscode plugin following the extension tutorial but I am having trouble going through the VS Code API finding this mapping equivalent method. As such, I cannot figure out how to call upon this specific functionality within a vscode plugin for the purposes of testing the functionality of the code provided.

My attempts so far lead me to https://code.visualstudio.com/api/references/vscode-api#workspace, specifically the method: workspace.getConfiguration().update(), which I believe would technically open the workspace config file and write to it.
Where is this mapping located within the docs and how can I properly call upon it?

If anyone could point in the right direction, within the VS Code API, regarding upon how to call this function and its parameters. I would really appreciate it and apologize in advance for the beginner question, as I'm taking my time to carefully learn the ins-outs of Theia and Typescript.

@vince-fugnitto
Copy link
Member Author

vince-fugnitto commented Sep 1, 2021

@dineshUmasankar to test it is quite simple, I created a plugin to test which you can use since you were having difficulty:

The plugin simply executes the command:

export function activate(context: vscode.ExtensionContext) {
    let disposable = vscode.commands.registerCommand('vscode-open-config-file.test', () => {
        vscode.commands.executeCommand('workbench.action.openWorkspaceConfigFile');
    });

    context.subscriptions.push(disposable);
}

The command workbench.action.openWorkspaceConfigFile is available when we start the application, and we have a multi-root workspace opened (a workspace with more than one root folder, and described as a workspace file). In vscode this plugin will successfully work, but in the theia framework we need to make sure to add the proper mapping so that it is available by the plugin.

Error (theia):

Error: Command with id 'workbench.action.openWorkspaceConfigFile' is not registered.

To test the feature you would do the following:

  1. add the test plugin to the plugins/ folder
  2. start the application
  3. open a workspace
  4. use the command add folder to workspace (to add a secondary root and create a multi-root workspace)
  5. use the command test: open config file (the configuration file should open)

I confirmed it works locally with the plugin and the mapping updates:

Screen Shot 2021-08-31 at 9 50 08 PM

@dineshUmasankar
Copy link
Contributor

@vince-fugnitto Thank you so much for the guidance and your time. I managed to get the test working successfully after fixing a couple build issues on my own hardware, and with your documentation. I apologize for the hassle and appreciate the opportunity to contribute significantly.

testing-openWorkspaceConfigFile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginners issues that are perfect for beginners good first issue good first issues for new contributors plug-in system issues related to the plug-in system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants