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

Desktop: Put all keybindings in default #3545

Merged
merged 5 commits into from Aug 2, 2020
Merged

Conversation

CalebJohn
Copy link
Collaborator

This is an attempt to fix #3499 , i think the issue is that keymap.macosDefault is just a reference and the actually used map is default.

@laurent22
Copy link
Owner

Doesn't it mean that both regular and macOS shortcuts will be defined at the same time? i.e. Cmd+A and Ctrl+A do the same thing? If so I don't think that's the right approach as we should aim to be very specific about what shortcuts we support, so it should be Cmd+A only on macOS and Ctrl+A only on all other platforms.

Isn't it possible to get it working by using addKeyMap in combination with the keyMap option? Perhaps you could even set the keyMap option to an empty array, then define explicitely all the kemaps we support via addKeyMap. That way it would be easier to have a conditional for macOS/Windows/Linux. It's true that the CodeMirror doc is not the clearest for this though.

@CalebJohn
Copy link
Collaborator Author

addKeyMap is a method that allows you to change keymaps after the editor has been initialized (which is useful for plugins), in our case it's unnecessary because we have full control over the editor lifetime.

What I did here is that I manually set the default based on shim.isMac() so the mac version only ever gets mac commands. That way the keyMap option can remain (emacs, vim, default). But macOs only sees the mac default and windows/linux sees the others.

@laurent22 laurent22 changed the base branch from master to dev August 1, 2020 17:59
Copy link
Owner

@laurent22 laurent22 left a comment

Choose a reason for hiding this comment

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

Other than a typo it works, however I see that it's building the keymap every time I press a key. Shouldn't it be done within an effect?

@CalebJohn
Copy link
Collaborator Author

Good suggestion! My thought was that since it's stable it didn't need to be in an effect. This was of course wrong, it's fixed now.

@laurent22 laurent22 merged commit 223caca into laurent22:dev Aug 2, 2020
@laurent22
Copy link
Owner

Ok, there was still a typo keymap/keyMap which was crashing the app on macOS, but once fixed it's working fine. Thanks for the update!

@CalebJohn CalebJohn deleted the keymaps branch August 2, 2020 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undo and Select All not working in Code Mirror editor
2 participants