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

Easy pick codelenses with keyboard shortcut #91232

Merged
merged 4 commits into from Mar 9, 2020

Conversation

GustavoKatel
Copy link
Contributor

Signed-off-by: Gustavo Sampaio gbritosampaio@gmail.com

This PR closes #41579

This adds a new command that when invoked, shows in a quickpick all the codelenses available in the current line. This makes it easier to "activate"/run a codelens with keyboard. One can set a keybinding for that command and easily switch between the available codelenses with the keyboard.

peek

This is my first pr! I appreciate any suggestions or comments on where to improve this.

@msftclas
Copy link

msftclas commented Feb 23, 2020

CLA assistant check
All CLA requirements met.

Signed-off-by: Gustavo Sampaio <gbritosampaio@gmail.com>
@GustavoKatel
Copy link
Contributor Author

GustavoKatel commented Feb 23, 2020

I tried debugging the failure in the monaco job but without success. Can anyone point me to the right direction of how I can solve this?

Figured out what was going on. Tests for monaco are ok. Thanks anyway

Signed-off-by: Gustavo Sampaio <gbritosampaio@gmail.com>
@jrieken jrieken self-assigned this Feb 24, 2020
@jrieken jrieken added this to the March 2020 milestone Feb 24, 2020
}
}

export class ShowLensesInCurrentLineCommand extends Command {
Copy link
Member

Choose a reason for hiding this comment

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

Use EditorCommand instead of the generic command. It will already have the correct editor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice! Changed to use it. Thanks @jrieken


public getLenses(): CodeLensWidget[] {
return this._lenses;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why expose the widgets and not the model itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need the line number of the widget on line 421:

const activeLensesWidgets = codelensController.getLenses().filter(lens => lens.getLineNumber() === lineNumber);

Copy link
Member

Choose a reason for hiding this comment

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

Ah, the live/updated line numbers... That makes good sense. Thanks for clarifying


const commandArguments: Map<string, any[] | undefined> = new Map();

const picker = quickInputService.createQuickPick();
Copy link
Member

Choose a reason for hiding this comment

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

You can use IQuickInputService#pick instead of createQuickPick. For simple cases like this you don't to write that much code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice! Just updated it! Thanks @jrieken

@jrieken
Copy link
Member

jrieken commented Mar 9, 2020

Thanks

@jrieken jrieken merged commit 22bdd60 into microsoft:master Mar 9, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow invocation of codelens actions via keyboard
3 participants