Saturday, November 30, 2013

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

glts <676c7473@gmail.com> a écrit:
> Paul,
>
> On Saturday, November 30, 2013 10:03:07 AM UTC+1, Paul Isambert wrote:
> > 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?
>
> I tripped over this myself in the past and posted it here as a bug.
>
> But it's documented behaviour. :h setpos(), the last paragraph:
>
> > This does not restore the preferred column for moving vertically. See
> > |winrestview()| for that.

Thank you David. I'd seen that part without really reading it nor
understanding what it means. In particular, how does it explain that
"setpos()" doesn't set the column if and only if the current column is
"infinite", whereas it works ok otherwise?

To put it another way, if "setpos()" is half useless, why does it
exit to begin with?

Best,
Paul

--
--
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: