Repository navigation
Repeat typing - #176
Repeat typing#176
Conversation
There was a problem hiding this comment.
@nathansobo This tries to type a character in the main editor, but the editor never gets it.
There was a problem hiding this comment.
The editor uses textInput events rather than keydown.
There was a problem hiding this comment.
This nastiness creates a string out of all of the inserted text; it works great if there were no deletions. I can't figure out a way to determine if a deletion in a transaction deletes another piece of text typed in the transaction, or if it's a completely unrelated operation. Other than diffing patch locations to see if the deletion position was already inserted, which is a pretty monstrous task. It doesn't look like Transaction has a better way to do this today, but I'm wondering if there's something planned that I can contribute towards that might make this sort of thing easier.
|
Checking my understanding here: The I'm thinking that So I'm thinking of supporting this pseudocode: @buffer.beginTransaction()
# make changes
transaction = @buffer.commitTransaction()
# later...
transaction.replay([7, 2]) # the position could be optional |
|
@nathansobo we talked about this a little, but just writing this down:
This is exactly how I think it should work. It's a little bit weird, because transactions can encompass things like 'replace the current selection', and that's not a concept that's 'repeatable' in vim; there's no |
Conflicts: lib/operators/general-operators.coffee lib/vim-state.coffee spec/vim-state-spec.coffee
There was a problem hiding this comment.
We try to have all potential fields on the object by the time the constructor completes, so it would be a good idea to put typed: false in the prototype.
|
Okay, I added some comments in various places. Summary:
|
|
Fantastic review @nathansobo, thanks! I will clean up the easy stuff. |
|
Okay, I'm about to merge this. Specific callout to a few recent contributors: would you please get master and see if repeat and undo on typing is not what you expect before I do a release? @carlosdcastillo @abijr @tony612 @tmm1 @jacobgardener @jcurtis @mcnicholls @mcolyer @nathansobo Future cleanups include:
Those are all pretty ugly but I am really tired of not having this when I'm on master. |
|
Looks good. Though it behaves a little differently with vim, but I think it's ok to publish. |
There was a problem hiding this comment.
But there's a bug when you press a or i, insert nothing then press escape.There'll be a error raised.
It can fixed simply by changing this line to @editor.getBuffer().insert(@editor.getCursorBufferPosition(), @typedText || "", true)
|
@bhuga: I coded today with what is in master as my vim-mode version. Everything is looking really good. I did find this obnoxious one: What works: I'll try to send a PR tomorrow to fix it. |
Repeat typing
This is quite the WIP. I need some help from @nathansobo on things that I have commented on inline.
The goal is to make
.work with typing. Currently this works for typing which has no deletions (backspaces). It's also not quite accurate yet;s, for example, deletes a character and enters insert mode, and.currently won't delete the character. I can fix up the edge cases if we can get this to a workable place.