This repository has been archived by the owner on Apr 6, 2018. It is now read-only.
🐛 Fix repeat-insertion bug referenced in #1006 #1020
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi all,
I took a shot at fixing the repeat-insertions-after-change bug referenced in #1006 and #1010. As @t9md pointed out, there is an issue with
item.confirmChanges(changes)
function of theInsert
class. That function constructs an instance ofTransactionBundler
which relies onchange.newRange
and some other properties which don't exist. As a result,bundler.buildInsertText()
always returns""
, which is why the dot-command aftercwText
repeats the deletion, but not the insertion.This fix makes use of the
getChangesSinceCheckpoint
function, implemented in atom/text-buffer@9f9025f. That function replaces the function of the same name implemented inlib/vim-state.coffee
, which uses private API's. It essentially supplies equivalent information in a different format. TheTransactionBundler
class is changed accordingly.The dot-command now behaves as expected on conventional patterns like
iText
,cwText
,c2wText
,ccText
, etc.There is some funky behavior when moving the cursor outside of the edited region while in insert-mode and continuing to type (not when fixing something that was just typed). However, I don't think this is a result of this fix, but rather a consequence of the way
TransactionBundler
bundles the inserted text by calling@editor.getTextInBufferRange
. Similar behavior occurs using the release version of the vim-mode package on the 1.6.2 Atom release, when the dot-command was still working. To illustrate, takeOne two three.
In command-mode, move the cursor to the beginning of
two
. TypecwHello
which replacestwo
byHello
. Without leaving insert-mode, move the cursor to the beginning of the line and typeworld.<space><escape>
. I seeworld. One Hello three.
Now move the cursor to the beginning of the word
three
and hit.
. I see inAtom 1.7.3 + this fix:
world. One Hello world. One Hello.
All of
world. One Hello
is taken to be the typed text, and hence re-inserted after hitting.
. Everything between insertions is grouped together and taken to be typed text, even if it was there before.Atom 1.6.2 + vim-mode 0.65.0
world. One Hello d. One H.
This time
d. One H
is taken to be the typed text and reinserted after hitting.
.(Neo)vim
world. One Hello world. three.
In vim, it seems like
cw
is forgotten about once the cursor leaves the original region..
simply repeats the last insert (world.<space>
) and does not deletethree
.Since this kind of pattern isn't really the intended use of the
cw
, it's hard to say what the behavior should be, but the difference to vim is worth noting.Feedback is greatly appreciated.