Comments (7)
@mtsmfm Can you provide some more context please? Is executeCommandProvider
the name of your command. The error you point to happens when registering the same command twice.
from vscode-extension-samples.
@jrieken Sorry for being late.
I created an example extension to describe this problem:
Please try this extension with https://github.com/mtsmfm/example-workspace
This extension just inserts workspace folder name as a code action.
So it should insert file:///path/to/example-workspace/foo
for foo/foo.txt
and file:///path/to/example-workspace/bar
for bar/bar.txt
.
But I got file:///path/to/example-workspace/foo
for bar/bar.txt
.
from vscode-extension-samples.
I met command already exists error.
Actually, we can't notice this error normally because it's suppressed in this line:
from vscode-extension-samples.
@jrieken Isn't this explanation enough?
from vscode-extension-samples.
@jrieken I guess you're busy though, could you have a look at this?
I think this is a critical problem to provide commands/actions from multi-server.
from vscode-extension-samples.
I just ran into this, been using a multi-server LSP setup following the example here without realising the major limitation that it won't even initialize if it contains an executeCommandProvider
. If it can't be resolved it could at least be listed as a limitation.
(My plan is to avoid executeCommandProvider
and manually register/proxy commands to the appropriate LS server)
from vscode-extension-samples.
I think this should be related to this one.
What I've ended up doing is using a global clients: Map<string, LanguageClient>
(as showed in the multi-server lsp example) and then I locate the correct client for when I have to launch commands. Something like,
async function registerHiePointCommand(name: string,
command: string,
context: ExtensionContext) {
const editorCmd = commands.registerTextEditorCommand(name, (editor, edit) => {
const cmd = {
command,
arguments: [
{
file: editor.document.uri.toString(),
pos: editor.selections[0].active,
},
],
};
// Get the current file and workspace folder.
const uri = editor.document.uri;
const folder = workspace.getWorkspaceFolder(uri);
// If there is a client registered for this workspace, use that client.
if (clients.has(folder.uri.toString())) {
const client = clients.get(folder.uri.toString());
client.sendRequest('workspace/executeCommand', cmd).then(hints => {
return true;
}, e => {
console.error(e);
});
}
});
context.subscriptions.push(editorCmd);
}
It gets the current file, then looks up the workspace folder. It uses this folder.uri.toString()
as the key for the language server.
Then to get rid of the command already exists
, I simply check if commands have been registered, else I register them. E.g. a global let hieCommandsRegistered: boolean = false;
, and then check if (!hieCommandsRegistered) { ...; hieCommandsRegistered = true; }
.
from vscode-extension-samples.
Related Issues (20)
- InlineCompletion Not Triggered on accepting when "command" option provided to InlineCompletionItem. HOT 2
- Add example using TypeScript in webviews HOT 2
- vscode extesion http keep-alive problem HOT 1
- Vs code in git hub HOT 1
- semantic-tokens-sample doesn't activate on launch.
- Test-Provider-Sample: Continuous RunHandler registers redundantly HOT 6
- How do you get the node in the treeview that is being clicked HOT 1
- How to create multi language vscode plugins HOT 1
- Dynamic snippet.json loading | Help HOT 1
- Callback/Event after quickOpen is closed (item selected or cancel) HOT 1
- Please add a sample for using Editor Menus and Submenus
- Initialize response from LSP Server doesn't reach the (vscode) lsp client (TransportKind is stdio) HOT 3
- extension-terminal-sample is not working. HOT 1
- Codespace HelloWorld tutorial mismatched version
- feat: recommend and support Bun HOT 1
- Product icons not showing in webviews (React) HOT 1
- Command 'Github Authentication Sample: Get Github User' resulted in an error
- Report Extension Sample Issue
- The "View Problem" positioning error in the code diagnosis pop-up window HOT 1
- CANNOT use API proposal: chatAgents2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-extension-samples.