Christian Ludwig wrote:
> Bram Moolenaar wrote:
> >> [...]
> >>
> >> I did some tests with virtcol() and compared the results with my
> >> expectations (which may be plain wrong), see also Issue 277.
> >> [...]
> >
> > You are passing in an invalid position, halfway a character, thus the
> > returned value is undefined.
>
> Thank you for your answer.
>
> Vim itself passes sometimes invalid positions ("halfway a character") to
> getvcol() [that's why I looked at halfway characters]. There is a one
> character example in https://github.com/vim/vim/issues/277
>
> ─
> ─────┬────┬──────────┬────┬──────────────────
> Ind.│Byte│codepoint │Vcol│ grapheme cluster
> ─────┼────┼──────────┼────┼──────────────────
> 00 │ e2 │ U+002500 │ 01 │ ─
> 01 │ 94 │ │ │
> 02 │ 80 │ │ │
> ─────┴────┴──────────┴────┴──────────────────
>
> If I use visual character mode and if I yank this one character and then
> ask (where was the yank)
> :echo virtcol("']")
>
> then Vim passes (internally) the col=2 (index/Ind.) to getvcol. That's
> the reason why the answer (2) of this echo is wrong, because the
> character has only one column. And that's why I also looked at halfway
> positions.
>
> >
> > I don't know why you pass in an invalid position, but it looks like it
> > can be made to accept the position by changing f_virtcol() to adjust the
> > column to the start of the character. Changing getvcol() is probably a
> > bad idea.
> >
> If getvol() should not be changed, then one has to look, why vim itself
> is sometimes passing "wrong" byte-positions ...
Thanks for explaining. So the '] mark is on the last byte of the yanked
text. I hesitate to change this, since quite a few Vim functions with
byte positions, and the number of bytes between '[ and '] could be used.
So we can change virtcol(). I'll make a patch for that.
--
"It's so simple to be wise. Just think of something stupid to say
and then don't say it." -- Sam Levenson
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
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.