Skip to content

Easy pick codelenses with keyboard shortcut#91232

Merged
jrieken merged 4 commits intomicrosoft:masterfrom
GustavoKatel:codelens-easypick
Mar 9, 2020
Merged

Easy pick codelenses with keyboard shortcut#91232
jrieken merged 4 commits intomicrosoft:masterfrom
GustavoKatel:codelens-easypick

Conversation

@GustavoKatel
Copy link
Contributor

Signed-off-by: Gustavo Sampaio [email protected]

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.

@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

@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

@GustavoKatel GustavoKatel requested a review from jrieken March 8, 2020 12:28

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