Saturday, November 30, 2013

Re: Trouble with getpos()/setpos().

Hi Paul!

On Sa, 30 Nov 2013, Paul Isambert wrote:

> Hello all,
>
> I've encountered a behavior which really smells like a bug, but I'd
> like to check here beforehand to be sure:
>
> Go into linewise visual mode and leave it. Show the position of the '> mark with:
>
> echo getpos("'>")
>
> It returns something like (if you were on line 23):
>
> [0, 23, 2147483647, 0]
>
> where the very big value for the column means you were in linewise
> visual mode. Now try to set the '> mark with e.g.:
>
> echo setpos("'>", [0, 25, 12, 0])
>
> "0" is echoed, meaning nothing went wrong. Use "getpos("'>")" again to see
> the position of the mark, this time you'll see:
>
> [0, 25, 2147483647, 0]
>
> The line was changed, but not the column. And it seems to happen
> whenever the column number has that big value, i.e. whenever you went
> into linewise visual mode.
>
> Am I missing something?

You are seeing implementation details, leaking into the Vim API.

You are in *linewise* visual mode, so it doesn't really make sense, to
have the column somewhere different then either 0 or MAXCOLUMN.

Also note, that '< will always be the upper position of these two marks
within the buffer, while '> will always be the lower position of those
two marks. (e.g. you can't set '> to a lower line then '< and you can't
set '< to a larger line number then '>)

Best,
Christian
--
Das muß ein Esel sein, der mit fünfzig Jahren noch dieselben
Anschauungen hat wie vor zwanzig Jahren.
-- Otto von Bismarck

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment