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

Keybindings for arrow keys don't always fire #119

Open
andrechen77 opened this issue Oct 30, 2023 · 2 comments
Open

Keybindings for arrow keys don't always fire #119

andrechen77 opened this issue Oct 30, 2023 · 2 comments
Labels
bug Something isn't working Lower priority

Comments

@andrechen77
Copy link
Collaborator

Following 7f756de, it became possible for a client to directly add keybindings to the underlying CodeMirror instance. The 'ArrowUp' and 'ArrowDown' keybindings only fire when the cursor is at the edge of the document (that is to say, when pressing the key would no longer affect the position of the cursor).

In order for proper up-arrowing through history in command input, these keybindings should take precedence over moving the cursor.

@andrechen77 andrechen77 added the bug Something isn't working label Oct 30, 2023
@CIVITAS-John
Copy link
Contributor

Another repository using CodeMirror-NetLogo managed to solve the issue without additional changes:

https://netlogo-mobile.github.io/TU-Editor/editor.html

https://github.com/NetLogo-Mobile/TU-EDITOR

Please check it out and let me know if the solution here works or not.

@andrechen77
Copy link
Collaborator Author

The solution used in TU-Editor is the same one I'm employing in Galapagos, namely, using the OnKeyUp option of the GalapagosEditor constructor. I am referring to this. The OnKeyUp option works fine for both Galapagos and evidently TU-Editor as well, but this issue is about the KeyBindings option.

One of the symptoms of using OnKeyUp is that both Galapagos and TU-Editor suffer from the issue that the handler only fires after the key is released, not after it is pressed. The reason for adding the KeyBindings option in the first place was to mitigate effects such as this by providing a cleaner way to add key bindings. Thus, the original issue stands, that setting the option to something like KeyBindings: [{ key: 'ArrowUp', run: handler }] only works some of the time, making it unsuitable for up-arrowing through history.

However, given that the small delay imposed by using OnKeyUp doesn't prevent it from being a viable alternative, this issue is probably not a high priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Lower priority
Projects
None yet
Development

No branches or pull requests

2 participants