Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Corrected shortcut #6960
Corrected shortcut #6960
Changes from 3 commits
5158e87
62a4fa8
692b398
87df8c7
bf6c0f7
3c3f918
d480045
3d120ac
3c9981c
2abea9e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this works? I would gess
getDefaultKeyBinding
is always empty forNEW_INBOOK
even though the user has overwritten it. On first glance, I would suggest to change thegetKeyCombination
method below topublic Optional<KeyCombination> getKeyCombination(KeyBinding bindName)
and return an empty optional ifbinding
is empty.Moreover,
get
should probably return en empty string instead of"Not associated"
to be consistent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works. If I change the next statement
from
public KeyCombination getKeyCombination(KeyBinding bindName)
to
Optional<KeyCombination> getKeyCombination(KeyBinding bindName)
I have to change other parts of code. For example line 141
from
KeyCombination keyCombination = getKeyCombination(binding);
to
KeyCombination keyCombination = getKeyCombination(binding).get()
;Is this what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, can you briefly explain why it works? I thought "getDefaultKeyBinding" then always returns an empty string, so this check is always false.
Yeah, there are more code changes required for my suggestion. I think it would provide a clean solution to handle the case that for a given keybinding there is not necessarily a keycombination. But I didn't had the time yet to check the code in detail. So if your solution indeed works, then it's fine with me as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started debugger and see that it always returns shortcut from
KeyBinding.java
file.Solution with
Optional
looks more clean. I just want to confirm that if we implement it, we also change other parts of code togetKeyCombination(binding).get()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case this is done, the code fragment is
getKeyCombination(binding).ifpresent(combination -> ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gena928 Exactly! So if you change the keybinding for "New inbook" to something, then
getDefaultKeybinding
should still return an empty string, so the code never goes into the if body in this case (although it should to match the new-user defined key).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobiasdiez
I agree. If you change default shortcut, this code will not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to fix today.