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

Add utility for handling multiple selected nodes #1352

Open
alexweininger opened this issue Jan 17, 2023 · 2 comments
Open

Add utility for handling multiple selected nodes #1352

alexweininger opened this issue Jan 17, 2023 · 2 comments

Comments

@alexweininger
Copy link
Member

Docker has a similar challenge: https://github.com/microsoft/vscode-docker/blob/main/src/utils/multiSelectNodes.ts

When multiple nodes are selected and an action performed on one of them, we simply ignore those for which the action is not valid.

The only place where we use the "primary" node is in creating a list out of it, if there are no items in the selection list: https://github.com/microsoft/vscode-docker/blob/main/src/utils/multiSelectNodes.ts#L30-L33

Originally posted by @bwateratmsft in microsoft/vscode-azureresourcegroups#516 (comment)

@bwateratmsft
Copy link
Contributor

The way Docker does things is to depend on context value filters--much the same as we use for context commands launched through the command palette--to ignore nodes for which the action is invalid. This can theoretically end up in all of the selections being ignored, in which case we treat it the same as command palette where nothing is selected (and we prompt).

The real pain about this approach is it forces a given context value to show up in at least three places--once where the tree node is constructed, once in the package.json for controlling where the action is shown, and once in the command to filter for specific context value(s). The latter two are nearly or exactly identical regexs and the duplication of code is error-prone. It might be interesting to try to apply the when clause from the manifest to see what nodes still pass the filter, if it's possible.

@alexweininger
Copy link
Member Author

Related microsoft/vscode#170248 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants