Fixed yank cursor bug#417
Conversation
isaachess
commented
Oct 13, 2014
- When yanking, there was a bug that made the cursor move to the very end of the yank selection, rather than moving the cursor to the beginning of the selection like vim does. After the yank, cursor now moves to start of selection.
- Also, @editor.getSelection() is deprecated, so we are now using editor.getLastSelection().
There was a problem hiding this comment.
Rather than just measure the screen position, we get the range of the selection and use that to check the selection position.
|
I see that the Travis CI build failed, but I can't find anything in the spec files that mention Yank. Can you point me in the right direction of where I need to update those? |
|
I have updated the tests so this now passes. This functionality still does not work exactly like vim, but I personally feel it is close to vim, and a better "not-like-vim" than we had before. Now whenever you yank anything, the cursor moves to the very beginning of that selection. This is how vim works, except in the special cases of shift+Y, y y, y j, etc. In those cases, vim leaves the cursor in its original position, but my fix moves it to the start of the line (i.e., the start of the selection). However, while it used to work correctly in those special cases, it worked incorrectly in every other yank. So I personally this fix, while not perfect, is better than where we were. Thoughts? I'll understand if you don't want to merge this in. But let's not let the "perfect be the enemy of the good," right? 🚀 |
|
Can I get a review/comment on this? |
There was a problem hiding this comment.
Could this be selection.getText() since you already have the selection variable?
There was a problem hiding this comment.
Never mind, I'm assuming that line 145 may have changed the selection so you would need to re-grab it?
|
Can you elaborate a bit more which cases this fixes? And were those cases covered by new specs? It looks like all the spec changes have |
|
As for which cases it fixes, please see my bullet points on the pull request. The reason FIXME is there is because it does not yet work exactly like VIM, but works (in my opinion) better than what we had before. But yes, the new functionality is all in the specs. |
|
@isaachess - as far as I can tell, your change fixes the cursor position for the following operations:
and it breaks the cursor position for line-wise yanks. I'm ok with merging this and then re-fixing the behavior for line-wise yanks, but would you mind adding tests for the cases that you fixed? It looks like your only changes to the specs were adding |
|
Looks like the problems addressed by this PR are completely solved in 0.54.0. At least, |
|
Thanks @bronson. Closing this out. |