[vim] clip cursor, fix #1084 #8788
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "github/fork/aeosynth/vim"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
my try at a fix for #1084. instead of
@metatheos' approach of trackingvim.head, i peek at the current modesome notes / thoughts:
historyChangeFromChange, as modifying the cursor in thebeforeSelectionChangecallback caused an issue where undoing a deletion would delete a character to the left of the cursor@mightyguavaThis looks like a breaking change for existing users of the vim keymap, which is not ok. We need to have a period of time (at least a few CodeMirror releases and possibly until the next major release) for both registering as a keymap and registering as a mode to work. I would restore the initialization functions, keep track of whether Vim is initialized, and if initialization has not already been done by the time
handleKeyis executed, do the initialization then.Also why are you clearing global state whenever the
vimModeoption is set? The whole point of global state is for it to persist between codemirror instances, even if new instances are created later.Finally, there are a few reasons why I kept the state as getters instead of directly referencing the variables
vimStateneeds to be kept ascm.vimState. Thatvimandcmare kept distinct withgetVimState(cm)makes it easier for me to think about them separately and leaves room for a different future implementation.if vim is kept as a keymap instead of an option, how can i deregister the
beforeSelectionChangelistener when the keymap is changed? should i only add that listener if vim is an option (leaving behind legacy users), or should i patch codemirror to allow update functions in keymaps? i suppose i could callgetOption('keyMap')inside the listenerhttps://github.com/marijnh/CodeMirror/issues/1084#issuecomment-15012968
this led me to believe that you were ok with storing
vimStateoncmI agree with you and
@marijnhthat the Vim keymap has grown enough that it should be considered more of a mode than a keymap, so I wouldn't patch codemirror to callback on keymap change.I think not deregistering the
beforeSelectionChangeis fine because keymap change isn't really something that would usually be done except at cm initialization, and we currently don't deregister any of the visual/insert mode listeners on keymap change. But that's a weak argument, so leaving behind legacy users would also be an ok option. Either is fine really. I just don't want this change to completely break the vim keymap.I am a bit back and forth on that yes... Since you called it out, stick with storing
vimStateoncm, but I still prefer to keep thegetVimGlobalStatefunction.Well, that's not really true.
setOptionon the keyMap option is expected to work, and I can imagine IDEs providing a keybindings dropdown somewhere in the interface allowing people to switch bindings on the fly.As for storing things in a CM instance -- a lot of addons have moved to a model where they add a property to the
.stateobject of editor instances, so doing that too is nothing to be ashamed of.state checked for in
handleKey,globalStatereset only once,beforeSelectionChangelistener added only when vim is an option. also switched to the.stateconventiongetVimStateisn't really useful anymore. Can you rename it tomaybeInitVimState()and use it only indefineOptionandhandleKey?Looks good otherwise. Thanks for the changes.
done
Thanks, good to merge.
Nice. Merged as 70a267a
Pull request closed