Unexpected setpos() behaviour

41 views
Skip to first unread message

glts

unread,
Dec 5, 2012, 10:39:03 AM12/5/12
to vim...@googlegroups.com
Hi

Requesting comments on unexpected setpos() behaviour; possibly a bug.
Consider this buffer:

First line example text
Second line, tab character in front

Steps to reproduce:
* Put the cursor on the "t" of the word "First"
* Place the cursor on virtual column 8 of line 2 with setpos():
:call setpos('.', [0, 2, 1, 7])
* Press k to move back up one line

As you can see, the cursor lands back on the "t" of "First". This is
unexpected: It should either land on the "i" of "line", or on the "F" of
first, depending on whether the offset 7 in setpos() is taken into
account.

Note that it doesn't matter whether 'virtualedit' is set to "all" or
not.

glts

Bram Moolenaar

unread,
Dec 5, 2012, 12:10:01 PM12/5/12
to glts, vim...@googlegroups.com
This is documented:

This does not restore the preferred column for moving
vertically. See |winrestview()| for that.

--
A meeting is an event at which the minutes are kept and the hours are lost.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

glts

unread,
Dec 5, 2012, 12:19:14 PM12/5/12
to vim...@googlegroups.com
On Wednesday, December 5, 2012 6:10:01 PM UTC+1, Bram Moolenaar wrote:
> This is documented:
>
> This does not restore the preferred column for moving
> vertically. See |winrestview()| for that.

Oh right, sorry.

Then setpos() can't be used to reliably set the cursor to some new
position in mappings or commands? Well then. Thanks!

glts

Reply all
Reply to author
Forward
0 new messages