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 prefix argument to Quickopen command (CTRL+P) #28617

Closed
bizoo opened this issue Jun 13, 2017 · 12 comments
Closed

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

bizoo opened this issue Jun 13, 2017 · 12 comments
Assignees
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@bizoo
Copy link

bizoo commented Jun 13, 2017

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.

@bpasero bpasero added good first issue Issues identified as good for first-time contributors feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities labels Jun 14, 2017
@bpasero bpasero removed their assignment Jun 14, 2017
@cristianhosu
Copy link
Contributor

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

@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.

@bizoo
Copy link
Author

bizoo commented Jun 15, 2017

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

@cristianhosu
Copy link
Contributor

cristianhosu commented Jun 15, 2017

@bizoo - finished. Can you have a look? or maybe @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

code-oss-dev@1.14.0 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! code-oss-dev@1.14.0 watch: gulp watch --max_old_space_size=524288
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the code-oss-dev@1.14.0 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

@cristianhosu
Copy link
Contributor

cristianhosu commented Jun 18, 2017

Hello @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.

@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?

cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jun 18, 2017
@bizoo
Copy link
Author

bizoo commented Jun 19, 2017

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 @bpasero is an array of arguments (couldn't find the implementation of "type" command to compare).
So is arguments of commands and keybindings different ?

cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jun 19, 2017
cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jun 20, 2017
cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jun 23, 2017
cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jun 23, 2017
cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jul 7, 2017
cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jul 7, 2017
cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jul 7, 2017
cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jul 7, 2017
cristianhosu added a commit to cristianhosu/vscode that referenced this issue Jul 7, 2017
@bpasero bpasero self-assigned this Jul 7, 2017
@bpasero bpasero added this to the July 2017 milestone Jul 7, 2017
@bpasero bpasero closed this as completed in 0095617 Jul 7, 2017
@bpasero
Copy link
Member

bpasero commented Jul 7, 2017

This is now possible via:

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

@bizoo
Copy link
Author

bizoo commented Jul 10, 2017

Thanks @cristianhosu and @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.

@bpasero
Copy link
Member

bpasero commented Jul 10, 2017

@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.

@bpasero
Copy link
Member

bpasero commented Jul 10, 2017

@bizoo this actually works:

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

@bizoo
Copy link
Author

bizoo commented Jul 13, 2017

@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.

@bpasero
Copy link
Member

bpasero commented Jul 13, 2017

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.

@bpasero bpasero added verification-needed Verification of issue is requested and removed good first issue Issues identified as good for first-time contributors help wanted Issues identified as good community contribution opportunities labels Jul 14, 2017
@bpasero
Copy link
Member

bpasero commented Jul 14, 2017

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');

@weinand weinand added the verified Verification succeeded label Jul 27, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants