-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Allow for no-results message in editor.action.goToLocations-command #95308
Comments
@jdneo Is this a problem that occurs when using |
Thank you @jrieken! In Java, we have a feature called To better expose the feature, we hope to add it into the context menu as well. Something like this: So we hope we can get the same experience when there is no result for this navigation, show the editor message, just like what VS Code has for |
Great. Than let's do this. The Java extension will call the |
@jrieken Pretty cool! That works for us! Thank you! |
Alright, I'll try to get something in for tomorrow |
I have pushed those changes, this is how you call the api command return vscode.commands.executeCommand(
'editor.action.goToLocations',
vscode.window.activeTextEditor.document.uri, // anchor uri and position
vscode.window.activeTextEditor.selection.start,
[], // results (vscode.Location[])
'goto', // mode
'No Foo Found' // <- message
); The command is a bit more powerful than what "go to super" needs, e.g it can handle multiple results etc, just like "Go to References" etc. Still, with the snippet above you should be able to get what you need and be as close as possible to our native experience. |
Adding verified based on the previous comment |
Hi @jrieken, one more question: The API works fine when the location array is empty. Today I tried to add a location into it: return commands.executeCommand(
'editor.action.goToLocations',
window.activeTextEditor.document.uri,
window.activeTextEditor.selection.active,
[targetLocation],
'goto',
'No super implementation found'
); where the
Then I got an error: Is that anything I missed here? Thanks Update: Seems the range needs to be defined as:
which is different from the type defined in @jrieken Does that mean we should still use the API |
The |
I tried to get a Range using the constructor, and failed to go to the target location. targetLocation = {
uri: Uri.parse(superImpl.uri),
range: new Range(new Position(0, 0), new Position(0, 0)),
}; |
Yeah, I see it now. There is something wrong |
Sorry, what must be is that the result array should be instances of vscode.Location-types. When calling commands we have special logic to check for that type which then turns it into the corresponding objects on the client side |
@jrieken Thank you! I should try to use the constructor of Location... 😃 |
Is it possible to add the API to show the editor message?
The use case could be:
A extension registered a command in the context menu, and the user clicks on it. After the execution, show a editor message to provide some result hint.
The text was updated successfully, but these errors were encountered: