Hello Vim developers,

I have a custom surround function that basically does this:

    let save_cursor = getpos('.')
    execute "normal! eaXY\<Esc>"
    call setpos('.', save_cursor)

And this correctly restores the cursor to the original position. But
when I move down a line (with "j", same with "k" btw.) immediately after
triggering this, the cursor jumps to the column of the last insert (the
"Y" in the example above). This does not happen when:
- a (no-op) move within the same line is performed (e.g. "l" followed by
"h") before the "j"
- cursor() is used instead of setpos('.')

I can reproduce this down to Vim version 7.0. Interestingly, in Vim
7.0.000, the cursor() function is also affected, but that starts working
in Vim 7.1.000. I see this in the latest Vim 7.4.307 (HUGE build) on
Linux/x64, as well as Vim 7.4.264 on Windows/x64.

You can reproduce this with the attached scriptlet:

    $ vim -N -u NONE -S bug-cursor-j.vim

Or by executing this in the middle of some text:

    let save_cursor = getpos('.')|execute "normal! eaXY\<Esc>"|call
setpos('.', save_cursor)|normal! j

The problematic call incorrectly positions the cursor (represented by |)
on the last insert column, instead of the column of the "B" where the
function was triggered:

QuickBrownFoxJumpsOverMe |he he
Quick|BrownFoxJumpsOverMe he he

-- regards, ingo
-- 
  -- Ingo Karkat --  /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
  --   http://vim.sourceforge.net/account/profile.php?user_id=9713   --

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: bug-cursor-j.vim
Description: application/octetstream

Raspunde prin e-mail lui