-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
vim use of keydown and keypress preventing codemirrorIgnore? #2915
Comments
this helped give me the behavior that I wanted. The other issue is that I have to modify the |
You could register your handler before turning on the vim mode, i.e.
and that should put your handlers before vim gets it. |
How would I cancel vim handling for certain events? |
I suppose |
Yeah, that how I patched my local CodeMirror. I think it's the wrong place to handle it, but we'd need to split handlers into |
Tricky problem. @marijnh do you have any suggestions on a good way for clients to suppress |
I think it would be preferable to move the vim mode's key handling down into the keymap layer again, which has at least some concept of priorities and fine-grained handling. Would it work for you to be able to add a function to a keymap that is simply called for each key, and which can return a value indicating whether it chose to handle that key? You'd have to translate from CodeMirror-style key names to Vim-style names, but that's probably not very hard. |
Yes, that's probably a good idea. I didn't realize until after I finished the insert mode key handling work that I didn't actually have to move the key handling out of the keymap layer. A function on the keymap that is called for each key would make the vim code cleaner if we take this approach. |
Attached patch should allow you to give the vim keymap(s) a You might also want to take a look at the new functionality for multi-stroke key bindings. Basically, if you return |
By the way, if you need access to the editor state during dispatch, I am also open to passing the editor instance as second argument to the keymap function. It's less clean, but I could live with it. |
I took a crack at this today, and realized I do need the editor instance. Vim mode's key mappings can change depending on its current state |
Attached patch causes the editor instance to be passed as second argument to the keymap's |
I believe this issue is preventing Light Table's Vim from upgrading - see LightTable/Vim#45 |
@cldwalker This should be resolved on Monday when I sync up with @heppe |
As far as I can tell, the move to
on('keydown')
andon('keypress'
)` is circumventing the normal way of preventing codemirror from doing things with events.What's the proper way to register a keyevent handler that can prevent the keymap from firing?
The text was updated successfully, but these errors were encountered: