Skip to content

Developed commands to change focus between preview editor and references within Peek View#85859

Merged
jrieken merged 4 commits intomicrosoft:masterfrom
GustavoASC:master
Dec 9, 2019
Merged

Developed commands to change focus between preview editor and references within Peek View#85859
jrieken merged 4 commits intomicrosoft:masterfrom
GustavoASC:master

Conversation

@GustavoASC
Copy link
Contributor

@GustavoASC GustavoASC commented Nov 30, 2019

This PR fixes part of #23001 because now one can, from within Peek View, change focus between preview editor and references tree with KeyCode.F2.

peek

I said 'part of' because there is still no setting available yet, to select which component will receive focus by default when Peek View is opened (preview editor or references).

I chose KeyCode.F2 to by default fire this command because:

  • It's ergonomically confortable since it's next to F4 which is used to go to next reference within Peek View references;
  • Personally, I think people wouldn't do major changes like renaming elements from inside Peek View. (F2 is also the default KeyCode for renaming elements on Language Server, so this behavior would be overwritten by the feature provided by this PR). I think one could easily close Peek View to rename element with F2 if needed;
  • F2 KeyCode is just a default and can be changed from VS Code Settings, so one can go back to previous behavior and rename elements from inside Peek View.

@msftclas
Copy link

msftclas commented Nov 30, 2019

CLA assistant check
All CLA requirements met.

id: 'changeFocusFromEmbeddedEditor',
weight: KeybindingWeight.EditorContrib + 50,
primary: KeyCode.F2,
when: PeekContext.inPeekEditor,
Copy link
Member

Choose a reason for hiding this comment

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

needs a try but I believe that this isn't needed anymore now that when supports OR

Copy link
Contributor Author

@GustavoASC GustavoASC Dec 3, 2019

Choose a reason for hiding this comment

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

If KeyCode.F2 is set to primary then 'when' conditions correctly appear on Keyboard Shortcuts screen:

image

But if I remove line 308 'primary: KeyCode.F2' or change it to KeyCode.Unknown, 'when' conditions do not appear anymore.

image

Should they appear? Is it a bug? Because if they really shouldn't appear I could simply remove 'when' clause from this new command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the other hand, the when clause is highly associated with the specified KeyBinding. If no KeyBinding is set on 'primary' option, then I think it makes sense to be empty as well...

Maybe I just should set when clause to undefined or something similar.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, the when-clause only comes to use with a keybinding. I think it's OK to add a keybinding but not one that is in use already

KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'changeFocusFromEmbeddedEditor',
weight: KeybindingWeight.EditorContrib + 50,
primary: KeyCode.F2,
Copy link
Member

Choose a reason for hiding this comment

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

👎 for using F2. Given the amount of VS Code users there certainly will be some that want to rename. Leaving unbound or using something like ctrl+left and ctrl+right.

});
}

async changeFocusBetweenPreviewAndReferences() {
Copy link
Member

Choose a reason for hiding this comment

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

async?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your feedback! I will make these changes and commit again.

@GustavoASC GustavoASC requested a review from jrieken December 5, 2019 23:32
@jrieken jrieken added this to the November 2019 milestone Dec 6, 2019
Copy link
Member

@jrieken jrieken left a comment

Choose a reason for hiding this comment

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

lgtm - will merge once master is open for business again

@jrieken jrieken merged commit ce12ff4 into microsoft:master Dec 9, 2019
@GustavoASC
Copy link
Contributor Author

@jrieken Hi! The link for this PR is missing on 1.42 release notes 😅 could you add it please? I've also updated my profile with my name (Gustavo Cassel) today. Big thank you!

@jrieken jrieken modified the milestones: November 2019, January 2020 Feb 3, 2020
@jrieken
Copy link
Member

jrieken commented Feb 3, 2020

Sorry, issue had the wrong milestone... I will update

@GustavoASC
Copy link
Contributor Author

No problem! Thank you 😅

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants