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

Feature Addition for Issue #24396 - New "Keyboard Shortcut" dialog should display current assignment #40405

Merged
merged 20 commits into from
May 23, 2018

Conversation

brandontruggles
Copy link
Contributor

Please let me know if there are any issues.

@msftclas
Copy link

msftclas commented Dec 18, 2017

CLA assistant check
All CLA requirements met.

@brandontruggles
Copy link
Contributor Author

brandontruggles commented Dec 18, 2017

I noticed that the automated builds failed...this might have to do with the last commit I made to remove types/which from the dependencies, not sure if I should've done that. During development I accidentally installed this package into the normal dependencies when I encountered compiler errors. Please advise.

@sandy081 sandy081 added this to the December 2017/January 2018 milestone Dec 18, 2017
Copy link
Contributor

@dadlerj dadlerj left a comment

Choose a reason for hiding this comment

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

lgtm

@alexdima alexdima modified the milestones: January 2018, February 2018 Feb 2, 2018
@bpasero bpasero modified the milestones: February 2018, March 2018 Mar 8, 2018
@bpasero bpasero modified the milestones: March 2018, April 2018 Apr 6, 2018
@brandontruggles
Copy link
Contributor Author

Re-synced with master, re-ran the smoke tests, and all the failed tests now pass. Seems to have been an issue with code outside of my own from the commit that I initially cloned from.

@sandy081
Copy link
Member

@brandonrninefive Thanks for the PR. Some changes

  • Let's not call them conflicts as they are not really conflicts. Because keybindings depend on when context value . That's why we call them same keybindings. How about 2 Exists or 1 Exist?
  • {0} Exists can be rendered as a link, on clicking, it will take back to Keybindings editor to show them
  • Layout: I think the keybinding should be always centred. Above message can be shown to the right

screen shot 2018-04-20 at 12 50 09

@brandontruggles
Copy link
Contributor Author

@sandy081 Thank you for the feedback! I'm working on implementing these changes now, and I should have an updated PR within the next few days.

@sandy081
Copy link
Member

Please ping me when you have changes ready. Thanks

…ing entries exist for the same keybinding. Clicking the link searches the list of assigned keybindings for all commands matching that specific keybinding.
@brandontruggles
Copy link
Contributor Author

@sandy081 Please let me know if the updated PR is acceptable. I followed your advice and made the label a clickable link which searches the input keybinding upon click. For the text of the label itself, I settled for "Existing", because I think it covers both the singular and plural cases of "Exists" nicely.

I have also re-centered the keybinding label as suggested, but instead of placing the "Existing" label to the right, I chose to place it centered underneath the keybinding label because I personally think it looks nicer this way. Please see the below screenshot for a quick glimpse at how I styled things.

If you see any issues with my new commit, please let me know, and I'll work to fix them.

image

new KeybindingLabel(this._outputNode, OS).set(this._firstPart, null);
if (this._chordPart) {
this._outputNode.appendChild(document.createTextNode(nls.localize('defineKeybinding.chordsTo', "chord to")));
new KeybindingLabel(this._outputNode, OS).set(this._chordPart, null);
}
}

public printConflicts(numConflicts: number, keybinding: [ResolvedKeybinding, ResolvedKeybinding]): void {
Copy link
Member

Choose a reason for hiding this comment

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

keybinding argument is not used, so this can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sandy081 Within this method, I am using the keybinding argument for the event listener for when the link I created is clicked. Please see line 267.

Since I generate the link within the method, I believe I need the argument here to pass the proper keybinding to the event such that it can be passed on to showSimilarKeybindings in keybindingsEditor.ts, in order to display the matching keybinding entries.

Copy link
Member

Choose a reason for hiding this comment

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

@brandonrninefive My suggestion is as follows:

  • Change onDidChange and onLinkClick events to emit key string just like how define method returns key string

  • While you are triggering onLinkClick you can get the key from the current state this._firstPart and this._chordPart. See define() method for how to get the key


private _firstPart: ResolvedKeybinding = null;
private _chordPart: ResolvedKeybinding = null;
private _isVisible: boolean = false;

private _onHide = this._register(new Emitter<void>());

private _onDidChange = this._register(new Emitter<[ResolvedKeybinding, ResolvedKeybinding]>());
Copy link
Member

Choose a reason for hiding this comment

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

Events can emit key string just like how define method returns key string

@@ -259,19 +259,49 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
this.searchWidget.clear();
}

showSimilarKeybindings(keybindingEntry: IKeybindingItemEntry): TPromise<any> {
const value = `"${keybindingEntry.keybindingItem.keybinding.getAriaLabel()}"`;
showSimilarKeybindings(keybindingEntry: IKeybindingItemEntry | [ResolvedKeybinding, ResolvedKeybinding]): TPromise<any> {
Copy link
Member

Choose a reason for hiding this comment

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

I do not think changes to this function are needed, if the events return the key string

if (value !== this.searchWidget.getValue()) {
this.searchWidget.setValue(value);
}
return TPromise.as(null);
}

showOverlayConflicts(keybinding: [ResolvedKeybinding, ResolvedKeybinding]): void {
Copy link
Member

Choose a reason for hiding this comment

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

  • This method should be private
  • It takes the key as string and call the fetch on the model by wrapping the key in quotes.
    This method will become a 2 liner like
const keybindingsEntries: IKeybindingItemEntry[] = this.keybindingsEditorModel.fetch(`"${keybinding}"`, this.sortByPrecedence.checked);
this.defineKeybindingWidget.printConflicts(keybindingsEntries.length);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sandy081 I attempted to make these changes as recommended, but I came across an issue. It seems that using keybindingsEditorModel.fetch on certain keybindings such as "Y" or "S D" will return any items that include these characters on any of their fields, and not necessarily their keybinding field. As you can see in the below screenshot, this behavior is what currently occurs when clicking the "show similar keybindings" button on a particular keybinding:

image

If this is the intended behavior of that method, that is fine, but it will not work for this purpose, as the length of the list returned by keybindingsEditorModel.fetch will often be much greater than the number of matching keybindings.

If I may make a recommendation, it would be to change the behavior of that method to concatenate a "+" after any characters in the keybinding, as doing so seems to return the results that we're looking for. As a side effect, this would also make the "show similar keybindings" button produce the same behavior, which makes more sense to me than searching through all the fields of the keybinding items for the characters in the keybinding. Please see the below screenshots for my proposed behavior:

image

image

Copy link
Member

Choose a reason for hiding this comment

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

@brandonrninefive Agreed to fix the behaviour of the method to match only keybindings when the filter string is quoted.

Copy link
Member

@sandy081 sandy081 left a comment

Choose a reason for hiding this comment

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

Please check the comments

Copy link
Member

@sandy081 sandy081 left a comment

Choose a reason for hiding this comment

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

Please check the comments

… display items based on the same keybinding. Also reworked how conflicting keybindings are searched for.
@brandontruggles
Copy link
Contributor Author

brandontruggles commented May 18, 2018

@sandy081 Please see my latest commit. I tried to follow your advice above as closely as possible. Let me know if things look good:

c4a19e0

@sandy081
Copy link
Member

@brandonrninefive Thanks for the changes. LGTM.

@sandy081 sandy081 merged commit 06d5047 into microsoft:master May 23, 2018
@sandy081
Copy link
Member

@brandonrninefive Did a bit of clean up (cosmetic changes). Wondering why is this change needed in showSimilarKeybindings

let value = `"${keybindingEntry.keybindingItem.keybinding.getAriaLabel().replace(' ', '+')}+"`;

@sandy081
Copy link
Member

I have removed the above change while clean up. Please let me know if it is needed.

@brandontruggles
Copy link
Contributor Author

@sandy081 That change in showSimilarKeybindings is the fix we discussed above to make the feature only display actions mapped to the same keybinding. Without concatenating the "+" character in between each letter in the keybinding, the search will display actions not necessarily matching the keybinding, but rather containing those letters on any field. This change is vital to everything working properly.

@sandy081
Copy link
Member

Ah I see... I would rather fix it in the keybindings model. If it is for a full match, then only compare keybindings and not compare with values of other properties.

@brandontruggles
Copy link
Contributor Author

@sandy081 Something to keep in mind with that approach is how we want to differentiate the full search from a keybindings-only search in the search box. Right now the "+" symbol acts as a delimiter.

@sandy081
Copy link
Member

True. But, filtering always considered a quoted string to match a keybinding completely. Show Same Keybindings action also does the same.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 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.

None yet

6 participants