Skip to content

Add prefix argument to Quickopen command (CTRL+P) #28617

Closed

Description

Add an argument (prefix) to "workbench.action.quickOpen" command.
This way you can populate the content with predefined values ("task JS:", "view_", ...) to filter the result using different keybinding.

I think the quickOpenService.show() method has already a prefix argument, so all we need to do is add it to the registered command.

Activity

  1. added
    good first issue
    feature-request
    help wanted
    on Jun 14, 2017
  2. cristianhosu commented on Jun 15, 2017

    @cristianhosu
    Contributor

    I'd like to take this if no one else started working on it.
    Should be a quick fix :)

    Dominique Wahli (@bizoo) can you please elaborate just a little bit?
    Once you press CTRL + P, the command input appears, then what is the next step?
    As far as i can tell right now you have the option to view the tasks, recent files, got to symbol and others.

  3. bizoo commented on Jun 15, 2017

    @bizoo
    Author

    The goal is only to fill the input with the given argument, everything else must works the same.

    Currently when I want to compile my Java code, I type "task Java:" and select the desired item in the list (I have A LOT of task for different purpose).
    I like to have a keybinding that open the quickOpen ("workbench.action.quickOpen") and prefill the input with "task Java:", something like (not sure if it's the correct syntax for "args"):

      { "key": "ctrl+alt+j", "command": "workbench.action.quickOpen",
                        "args": { "prefix": "task Java:" }}
    

    Could be used for different purpose, like filter the list of files:
    "view_*.java"

    Thanks cristianhosu for looking at it.

    edit: There's an example of command with arguments here

  4. cristianhosu commented on Jun 15, 2017

    @cristianhosu
    Contributor

    Dominique Wahli (@bizoo) - finished. Can you have a look? or maybe Benjamin Pasero (@bpasero)
    Thank you

    Edit: Still need to get used to working with git.
    I've set my upstream and reset my master to the upstream/master and will redo the changes but now on master it throws an error while running:

    chosu@CH-Acer:~/dev/GitContrib/vscode2$ npm run watch

    [email protected] watch /home/chosu/dev/GitContrib/vscode2
    gulp watch --max_old_space_size=524288

    [23:51:13] Node flags detected: --max_old_space_size=524288
    [23:51:13] Respawned to PID: 4793

    undefined:252
    return JSON.stringify(word).replace(/[\u2028\u2029]/g, function(s) {
    ^
    illegal access

    npm ERR! Linux 4.4.0-79-generic
    npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "watch"
    npm ERR! node v6.11.0
    npm ERR! npm v3.10.10
    npm ERR! code ELIFECYCLE
    npm ERR! [email protected] watch: gulp watch --max_old_space_size=524288
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] watch script 'gulp watch --max_old_space_size=524288'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the code-oss-dev package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR! gulp watch --max_old_space_size=524288
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR! npm bugs code-oss-dev
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR! npm owner ls code-oss-dev
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR! /home/chosu/dev/GitContrib/vscode2/npm-debug.log

  5. cristianhosu commented on Jun 18, 2017

    @cristianhosu
    Contributor

    Hello Dominique Wahli (@bizoo)

    Args usually represents an array and is treated as such.
    Thus, is it acceptable for this issue to be implemented as:

    { "key": "ctrl+alt+j", "command": "_workbench.quickOpen",
                        "args": ["view Git"]}
    

    In the example the args will be an array where the first item will represent the prefix.

    Benjamin Pasero (@bpasero) - can you also validate that this is a valid implementation, or should I create a new class QuickOpenArguments which should contain prefix and showOptions?

  6. added a commit that references this issue on Jun 18, 2017
  7. bizoo commented on Jun 19, 2017

    @bizoo
    Author

    I'm a little bit confused by how args in commands (and keybindings) works.
    And as I know next to nothing of VSCode code, I couldn't help.

    From this example of "type" command, the argument is named, not an array. If you change the name of the argument of "type" command, it doesn't works anymore.

    But example from Benjamin Pasero (@bpasero) is an array of arguments (couldn't find the implementation of "type" command to compare).
    So is arguments of commands and keybindings different ?

  8. 10 remaining items

  9. bpasero commented on Jul 7, 2017

    @bpasero
    Contributor

    This is now possible via:

    vscode.commands.executeCommand('workbench.action.quickOpen', '>editor');

  10. bizoo commented on Jul 10, 2017

    @bizoo
    Author

    Thanks cristianhosu and Benjamin Pasero (@bpasero).

    May I ask a question ?
    Why the type command have named argument and not this (and others) command ?
    Doesn't change anything but just wonder why.

  11. bpasero commented on Jul 10, 2017

    @bpasero
    Contributor

    Dominique Wahli (@bizoo) good point, I think it would be nice if you can assign a keybinding with a type that is filled into quick open command. If you want to have a look how that works, feel free.

  12. bpasero commented on Jul 10, 2017

    @bpasero
    Contributor

    Dominique Wahli (@bizoo) this actually works:

    { "key": "cmd+o", "command": "workbench.action.quickOpen", "args": "foo" }

  13. bizoo commented on Jul 13, 2017

    @bizoo
    Author

    Benjamin Pasero (@bpasero) I expected it to works that way but didn't try it myself (I use the standard release).

    But my question is why this command get an array of params (actually only one), but some other command use an object:

      { "key": "enter", "command": "type",
                        "args": { "text": "Hello World" }}
    

    I think the syntax of type command is better.

  14. bpasero commented on Jul 13, 2017

    @bpasero
    Contributor

    That is up to the command to decide and the picker command accepts just a string (what else?). But agree, having an object would make it more explicit what the argument is used for.

  15. added
    verification-needed
    and removed
    good first issue
    help wanted
    on Jul 14, 2017
  16. bpasero commented on Jul 14, 2017

    @bpasero
    Contributor

    Verify: you can write an extension that programmatically triggers the workbench.action.quickOpen command and you can pass over a string to show as prefix in the quick open picker. E.g.:

    vscode.commands.executeCommand('workbench.action.quickOpen', '>editor');
  17. locked and limited conversation to collaborators on Nov 17, 2017
  18. added a commit that references this issue on Sep 6, 2026
    1023b8f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions