Added extensibility points for searchView/context#109049
Added extensibility points for searchView/context#109049roblourens merged 8 commits intomicrosoft:masterfrom
Conversation
69454f4 to
eae3fcc
Compare
|
Also remember to fix the existing context menu actions that rely on the context. |
e1d5472 to
bce86a1
Compare
|
@roblourens I'm sorry, I had to revert this PR via 14140d2 because it was causing browser integration tests to fail in our nightly build |
| } | ||
|
|
||
| toJSON(): object { | ||
| return {}; // We send an IRenderableMatchContext to the extensions |
There was a problem hiding this comment.
Such changes aren't good and data that's transfers between processes should have explicit DTOs (data transfer objects)
| key: 'search/context', | ||
| id: MenuId.SearchContext, | ||
| description: localize('menus.searchContext', "The search context menu") | ||
| }, |
There was a problem hiding this comment.
@roblourens This smell like "under the radar" API work. Esp. interesting is what arguments those commands are invoked with. We have no API representation for search results and shouldn't introduce one with these changes unless properly reviewed and designed
There was a problem hiding this comment.
I thought the whole space of arguments for commands is sort of under the radar API. I looked at some other context menu contexts and they are invoked with different arbitrary things.
There was a problem hiding this comment.
This is API since changing arguments breaks extensions. I would be surprised if context menus use arbitrary objects as arguments, the rule should be use URI whenever the source itself has no representation in the API, eg. the explorer uses URI, so does the editor title and editor context, but SCM uses SCM things, custom tree use TreeItem etc.
For search results a URI isn't enough and search API (which I assume would talk about search matches) has never been tackled for finalization
There was a problem hiding this comment.
I was looking at variables and callstacks, which as far as I can tell are arbitrary objects with no api representation @isidorn.
There was a problem hiding this comment.
@roblourens correct, they have no official vscode api representation.
Here's a expert from the documentation for more details:
"When a registered context menu command is executed, both the underlying variable and its container are passed as Debug Adapter Protocol (DAP) objects. Please note that VS Code's extension API uses opaque stand-in types instead of the real DAP types. In order to access their properties, they can be easily coerced into the corresponding DAP types."
There was a problem hiding this comment.
On the callstack, I saw this
which I think isn't associated with any single DAP type, but I guess it's all coming directly from stuff in the DAP.
Let's reopen the issue for discussion. I'm looking at the proposed API that we have for search results and trying to decide whether it makes sense to use the same objects here. You could make a case either way. If we can make a case to design this api without necessarily tying it to search provider API, then we can do this without making it part of the whole search provider api problem.
One difference between the UI results and the provider results is that providers return one Match per line, possibly with multiple ranges on the line. The UI object always has one object per actual match. Or you would want some additional info like the replacement value.
There was a problem hiding this comment.
Yeah unlike the variables view the callstack is in a bad shape and I have this issue to tackle it #85696
We can continue the discussion there
I tested this by writing a mini extension that contributes a menu for the search results:
I got the menu to appear, and I got the expected parameters when I clicked on it:

I tested the IMatchContext and IFileMatchContext cases. I haven't been able to figure out how to make the editor call me with a IFolderMatchContext yet.
This PR fixes part of #107996
cc @roblourens