tpope / vim-speeddating

speeddating.vim: use CTRL-A/CTRL-X to increment dates, times, and more
http://www.vim.org/scripts/script.php?script_id=2120
971 stars 40 forks source link

Fix for selection=exclusive #9

Closed inkarkat closed 12 years ago

inkarkat commented 12 years ago

To reproduce:

:set selection=exclusive
:call setline(1, '2010-10-10 i am here')
:execute "normal vE\<C-a>"

Expected: 2010-10-11 i am here Actual: 2010-10-10 ii am here

tpope commented 12 years ago

The standard solution to this problem (which I sloppily forgot) is to save and restore 'selection', like I've done with 'virtualedit' in the same function. I'd be much obliged if you could provide an implementation that does that instead.

inkarkat commented 12 years ago

Since we're reselecting with gv here, temporarily setting selection=inclusive won't help. Vim will use the mark positions '< and '>, and the selection's end will have grown by one character, again requiring compensation through a move.

That approach only works when making and operating on a new selection; then you can indeed save yourself from those compensation movements.

tpope commented 12 years ago

Careful, you screwed up the permissions!

I fixed it for you, this time. :)