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 for quickpick commandline usage #2781

Merged
merged 3 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,25 @@ Are you on a Mac? Did you go through our [mac-setup](#mac-setup) instructions?

Press `shift+<esc>` to close all of those boxes.

### How can I use the commandline when in Zen mode or when the status bar is disabled?

This extension exposes a remappable command to show a vscode style quick-pick, limited functionality, version of the commandline. This can be remapped as follows in visual studio keybindings.json settings file.
```
{
"key": "shift+;",
"command": "vim.showQuickpickCmdLine",
"when": "editorTextFocus && vim.mode != 'Insert'"
}
```
Or for Zen mode only:
```
{
"key": "shift+;",
"command": "vim.showQuickpickCmdLine",
"when": "inZenMode && vim.mode != 'Insert'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When and where is this context variable being set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, cool.

}
```

## ❤️ Contributing

This project is maintained by a group of awesome [people](https://github.com/VSCodeVim/Vim/graphs/contributors) and contributions are extremely welcome :heart:. For a quick tutorial on how you can help, see our [contributing guide](/.github/CONTRIBUTING.md).
Expand Down
8 changes: 8 additions & 0 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ export async function activate(context: vscode.ExtensionContext) {
});

// register extension commands
registerCommand(context, 'vim.showQuickpickCmdLine', async () => {
let [modeHandler] = await ModeHandlerMap.getOrCreate(
new EditorIdentity(vscode.window.activeTextEditor).toString()
);
commandLine.PromptAndRun('', modeHandler.vimState);
modeHandler.updateView(modeHandler.vimState);
});

registerCommand(context, 'vim.remap', async (args: ICodeKeybinding) => {
taskQueue.enqueueTask(async () => {
const mh = await getAndUpdateModeHandler();
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
{
"command": "toggleVim",
"title": "Vim: Toggle Vim Mode"
},
{
"command": "vim.showQuickpickCmdLine",
"title": "Vim: Show Command Line"
}
],
"keybindings": [
Expand Down
18 changes: 18 additions & 0 deletions src/cmd_line/commandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ class CommandLine {
}
}

public async PromptAndRun(initialText: string, vimState: VimState): Promise<void> {
if (!vscode.window.activeTextEditor) {
logger.debug('commandLine : No active document');
return;
}
let cmd = await vscode.window.showInputBox(this.getInputBoxOptions(initialText));
await this.Run(cmd!, vimState);
}

private getInputBoxOptions(text: string): vscode.InputBoxOptions {
return {
prompt: 'Vim command line',
value: text,
ignoreFocusOut: false,
valueSelection: [text.length, text.length],
};
}

public async ShowHistory(initialText: string, vimState: VimState): Promise<string | undefined> {
if (!vscode.window.activeTextEditor) {
logger.debug('commandLine : No active document.');
Expand Down