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

Enablement using listDoubleSelection and listMultiSelection not working in contributed view #99767

Closed
aeisenberg opened this issue Jun 10, 2020 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders tree-views Extension tree view issues verified Verification succeeded
Milestone

Comments

@aeisenberg
Copy link

Issue Type: Bug

I am creating an extension with a custom view. I am trying to make sure that certain commands are only enabled when there are two items selected and other commands when only a single item is selected.

I have tried using "enablement": "listDoubleSelection" and "enablement": "!listMultiSelection" in the command declaration for these cases. However, it looks like the values listMultiSelection and listDoubleSelection are always false.

Perhaps I'm doing something wrong, but I'm pretty sure I'm following the docs.

I'm attaching a zip of a sample project that illustrates the problem I'm having.

multi-select-bug.zip

To reproduce:

  1. unzip the workspace above
  2. open workspace in vscode
  3. run the extension
  4. open the view with the icon like this: package_json_—_multi-select-bug
  5. select one or multiple items in the list view and right click. Notice that the enablement of the commands does not follow what is in the package.json file.

VS Code version: Code 1.45.1 (5763d90, 2020-05-14T08:33:47.663Z)
OS version: Darwin x64 19.5.0

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) 2, 3, 3
Memory (System) 64.00GB (34.46GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (22)
Extension Author (truncated) Version
vscode-markdownlint Dav 0.36.0
vscode-eslint dba 2.1.5
gitlens eam 10.2.1
tsl-problem-matcher eam 0.2.0
vscode-html-css ecm 0.2.3
prettier-vscode esb 5.0.0
vscode-diff fab 1.4.0
wolfram-language fli 0.1.0
vscode-codeql Git 1.2.2
vscode-pull-request-github Git 0.16.0
vscode-test-explorer hbe 2.19.1
mysql-syntax jak 1.3.1
vscode-edit-csv jan 0.2.9
code-beautifier mic 2.3.3
vscode-docker ms- 1.2.1
azure-account ms- 0.8.11
vscode-typescript-tslint-plugin ms- 1.2.3
vsliveshare ms- 1.0.2274
debugger-for-chrome msj 4.12.8
vscode-react-native msj 0.16.0
vscode-zipexplorer sle 0.3.1
html-css-class-completion Zig 1.19.0

(1 theme extensions excluded)

aeisenberg added a commit to aeisenberg/vscode-codeql that referenced this issue Jun 10, 2020
@alexr00
Copy link
Member

alexr00 commented Jun 11, 2020

It looks like listDoubleSelection and listMultiSelection are not implemented for extension provided tree views. @joaomoreno, is this something you would consider adding at a lower level, or should I add this as a consumer of WorkbenchAsyncDataTree?

@alexr00 alexr00 added the feature-request Request for new features or functionality label Jun 11, 2020
@alexr00 alexr00 added this to the Backlog milestone Jun 11, 2020
@joaomoreno
Copy link
Member

joaomoreno commented Jun 11, 2020

They should 🤔 :

this.hasDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
this.hasMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);

Must be a bug in some place. I would put my $$$ on which context key service the query is run on.

@joaomoreno
Copy link
Member

@alexr00 Where is that enablement value read, in our code base?

@alexr00
Copy link
Member

alexr00 commented Jun 11, 2020

I see it read here:

precondition: ContextKeyExpr.deserialize(enablement),

Then that precondition gets read in many places. Not sure which one is applicable here, but can do some digging.

@petrbroz
Copy link

This is probably related: I've been trying to achieve the same thing (showing/hiding specific commands in a custom tree view based on whether there are multiple items selected) by using listMultiSelection in the when clause, but with no luck.

If it is in fact possible to show/hide view/item/context items based on the selection count, is that documented anywhere? Thanks!

aeisenberg added a commit to aeisenberg/vscode-codeql that referenced this issue Jun 16, 2020
This is not quite ideal due to
microsoft/vscode#99767

Allow multiselection in the query-history view. For commands
that shouldn't accept multiple options, show a user message
to that effect.

For remove query, allow multiple removals at once.

For compare query, allow selecting of exactly two queries.
Otherwise, throw an error. Also, verify that the selected queries
are compatible to compare.
aeisenberg added a commit to aeisenberg/vscode-codeql that referenced this issue Jun 16, 2020
This is not quite ideal due to
microsoft/vscode#99767

Allow multiselection in the query-history view. For commands
that shouldn't accept multiple options, show a user message
to that effect.

For remove query, allow multiple removals at once.

For compare query, allow selecting of exactly two queries.
Otherwise, throw an error. Also, verify that the selected queries
are compatible to compare.
aeisenberg added a commit to github/vscode-codeql that referenced this issue Jun 17, 2020
This is not quite ideal due to
microsoft/vscode#99767

Allow multiselection in the query-history view. For commands
that shouldn't accept multiple options, show a user message
to that effect.

For remove query, allow multiple removals at once.

For compare query, allow selecting of exactly two queries.
Otherwise, throw an error. Also, verify that the selected queries
are compatible to compare.
@alexr00 alexr00 modified the milestones: Backlog, November 2020 Nov 5, 2020
@alexr00 alexr00 added bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues and removed feature-request Request for new features or functionality labels Nov 5, 2020
@alexr00 alexr00 closed this as completed in cd95d90 Nov 5, 2020
@joaomoreno
Copy link
Member

@alexr00 I would've made some $$$ here. 💸

@alexr00
Copy link
Member

alexr00 commented Nov 6, 2020

@joaomoreno indeed you would. Thanks for the context key service idea!

@roblourens roblourens added the verified Verification succeeded label Dec 3, 2020
aeisenberg added a commit to aeisenberg/vscode-codeql that referenced this issue Dec 9, 2020
1. Clicking on query history menu items when nothing is selected. Error
   message is clearer. It would be better to disable when nothing is
   selected, but waiting on
   microsoft/vscode#99767 to be released.
2. Trying to run query with a missing or invalid qlpack has better
   message.
3. Better hover text for "Open query".
aeisenberg added a commit to aeisenberg/vscode-codeql that referenced this issue Dec 9, 2020
1. Clicking on query history menu items when nothing is selected. Error
   message is clearer. It would be better to disable when nothing is
   selected, but waiting on
   microsoft/vscode#99767 to be released.
2. Trying to run query with a missing or invalid qlpack has better
   message.
3. Better hover text for "Open query".
aeisenberg added a commit to aeisenberg/vscode-codeql that referenced this issue Dec 9, 2020
1. Clicking on query history menu items when nothing is selected. Error
   message is clearer. It would be better to disable when nothing is
   selected, but waiting on
   microsoft/vscode#99767 to be released.
2. Trying to run query with a missing or invalid qlpack has better
   message.
3. Better hover text for "Open query".

Co-authored-by: Aditya Sharad <6874315+adityasharad@users.noreply.github.com>
aeisenberg added a commit to github/vscode-codeql that referenced this issue Dec 9, 2020
1. Clicking on query history menu items when nothing is selected. Error
   message is clearer. It would be better to disable when nothing is
   selected, but waiting on
   microsoft/vscode#99767 to be released.
2. Trying to run query with a missing or invalid qlpack has better
   message.
3. Better hover text for "Open query".

Co-authored-by: Aditya Sharad <6874315+adityasharad@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders tree-views Extension tree view issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants
@joaomoreno @roblourens @aeisenberg @petrbroz @alexr00 and others