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

Allow extension commands to define the behaviour when Alt modifier is pressed #18064

Open
alefragnani opened this issue Jan 3, 2017 · 8 comments
Assignees
Labels
api feature-request Request for new features or functionality quick-open Quick-open issues (search, commands)
Milestone

Comments

@alefragnani
Copy link

When you declare a command for an extension, it appears in Command Palette and you can select/use it with Return Key/Mouse Click. But there are some core commands that has special behavior when you combine with Ctrl, like Open on the Side.

I would like to have the ability to declare a command and have the normal and alternative behaviors, just like that.

Thanks in advance

@sandy081
Copy link
Member

sandy081 commented Jan 4, 2017

You cannot achieve that with a single command. A command will always have a single behavior and no alternate behavior. You always have to define different commands for different behaviors and can bind different key bindings to them.

@sandy081 sandy081 closed this as completed Jan 4, 2017
@alefragnani
Copy link
Author

Hi @sandy081 , I guess I messed up with the issue description 😢 . The intention was not for commands, but for QuickPick . I just noted my mess when I was starting to answer you to better explain my needs, sorry. This is my real scenario:

My Project Manager extension has two commands: List Projects to Open and List Projects to Open in New Window. Both uses a QuickPick to display a list of folders. The user selects one and I open VSCode with that folder. The only difference is that the second command opens a new VSCode instance instead of replacing the current one.

The original idea of this issue was to be able to select items (and detect the modifier) with Ctrl + Return. Doing so, I could _remove the List Projects to Open in New Window command from my extension. As you can see, there was nothing to do with Ctrl modifier for commands, my bad 😢

Sorry for the misunderstanding.

@sandy081
Copy link
Member

sandy081 commented Jan 4, 2017

If I understand correctly, your requirement was to know how a user selected an entry in quick pick say

  • source (mouse, key board)
  • alt modifiers

@alefragnani
Copy link
Author

Yes, exactly 👍

I have looked at VSCode source code sometime ago, and found where this was handled. If I remember correctly, only the Ctrl modifier being handled (not Shift nor Alt), but this may have changed since then.

Thanks in advance

@sandy081 sandy081 reopened this Jan 4, 2017
@bpasero bpasero changed the title Expose Ctrl+Return as alternate behavior for extensions commands Allow extension commands to define the behaviour when Alt modifier is pressed Jan 4, 2017
@bpasero bpasero added feature-request Request for new features or functionality workbench labels Jan 4, 2017
@bpasero bpasero removed their assignment Jan 4, 2017
@bpasero bpasero added keybindings VS Code keybinding issues and removed workbench labels Nov 16, 2017
@alexrussell
Copy link

alexrussell commented Apr 11, 2020

Looks like the new alternativeAcceptSelectedQuickOpenItem signals that this is now possible, though it's not obvious from the release notes whether extension authors can use this QuickPick select+modifier functionality, or only the open/symbols pickers...

@TylerLeonhardt
Copy link
Member

Although I agree that this is a valid request, I wonder if instead you'd prefer to use the new QuickPickItemButtons as it is more obvious what the alternative actions for a particular item are.

Sometimes I accidentally trigger the ctrl+enter behavior in the quick pick and worry that it could be confusing to a lot of users if they don't know that ctrl causes an alternate behavior.

@alefragnani
Copy link
Author

In fact, I would like to have both 😬, but yes, the new QuickPickItemButtons API is a great alternative and I'm definitely embracing, when available.

The reason to prefer the modifier approach is because users complains about the extension not following VS Code behavior. Not only my Project Manager extension would use, but also both Bookmarks extensions.

But I understand your point. The issue is quite old and has only a few upvotes/interactions. If you don't see this happening in the near future, nor other devs/teams requesting such API, feel free to close the issue in favor of the QuickPickItemButtons API. I'm ok with that 👍 .

Thank you

@jppellet
Copy link

I agree this would be useful. I would enjoy being able to tell if e.g. Alt or Ctrl is pressed when for instance an action button atop the editor area that I contribute is pressed, and act then accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api feature-request Request for new features or functionality quick-open Quick-open issues (search, commands)
Projects
None yet
Development

No branches or pull requests

7 participants