Tony Mechelynck wrote:

> *Warning* This message is in UTF-8. Any "modern" mailer ought to be able=20
> to display it correctly by obeying its Content-Type header, which was=20
> set correctly when I sent it.
> 
> Bug seen in:
> gvim 7.2.245 (Huge, GTK2/Gnome2). Full ":version" text available on reque=
> st.
> 
> Description:
> v:beval_text incorrectly evaluates the mouse position in relation to the=20
> text when there are multibyte characters before it.
> 
> AFAICT this is not mentioned in todo.txt dated 2009-Jul-26.
> 
> Reproducible: Always
> 
> Steps to reproduce:
> 
> 1. Make sure that your Vim is compiled with +balloon_eval +multi_byte=20
> and has 'encoding' set to UTF-8
> 
> 2. Edit a file containing the following single-line text (this is UTF-8,=20
> I recommend copy-paste from this message):
> 
> Jam preti=C4=9Dis li por tran=C4=89i, fendi per tran=C4=89il=E2=80=99 la =
> =EF=AC=81=C5=9Don;
> 
> If you cannot use copy-paste, here are (in left-to-right order) the=20
> non-ASCII codepoints in the line (from Chapter 5 of J.E.Lepp=C3=A4koski's=
> =20
> translation of the Finnish national epic /Kalevala/ by Elias L=C3=B6nnrot=
> ):
> U+011D LATIN SMALL LETTER G WITH CIRCUMFLEX
>       - Vim digraph g>
>       2nd word, 3rd from end
> U+0109 LATIN SMALL LETTER C WITH CIRCUMFLEX
>       - Vim digraph c>
>       5th word, next-to-last letter
> also  8th word, 5th letter (3rd from end not including the apostrophe)
> U+2019 RIGHT SINGLE QUOTATION MARK
>       * this is the preferred character to use for the apostrophe (sic)
>       - Vim digraph '9
>       at the end of 3rd word from right
> U+FB01 LATIN SMALL LIGATURE FI
>       - Vim digraph fi
>       at the start of last word
>       used here for "pretty text" effect, as my browsers don't use this 
> glyph=20
> for 0x66 0x69 (ASCII fi in two letters)
> U+015D LATIN SMALL LETTER S WITH CIRCUMFLEX
>       - Vim digraph s>
>       immediately after the above
> 
> 3. Set the balloon-evaluation options as follows:
> 
> :let &balloonexpr=3D'''Cursor is at line '' . v:beval_lnum . '', column '=
> '=20
> . v:beval_col . '' of file '' . bufname(v:beval_bufnr) . '' on word "''=20
> . v:beval_text . ''"'''
> 
> (the above is all on one line, and inspired by the example under ":help=20
> 'balloonexpr'"). Beware of multiple quotes: use copy-paste if you can.
> 
> :set ballooneval
> 
> The 'balloondelay' setting is not critical (default 600, I use 1000).
> 
> 4. Hover the mouse near the end of the edit text line.
> 
> Actual results:
> With the mouse anywhere on "=EF=AC=81=C5=9Don" the balloon shows the curr=
> ent word as=20
> "la"; but if you move the mouse to the ending semicolon, the current=20
> word is shown in the balloon as "=EF=AC=81=C5=9Don".
> 
> Expected results:
> The balloon should display the word under the mouse pointer, not the one=20
> before it.
> 
> Additional info:
> I suspect that v:beval_text is the word whose _byte_ position in the=20
> line corresponds to the _screen_ position of the mouse (maybe after=20
> correcting for hard tabs and/or ^A ~B etc., which I haven't tested). The=20
> result is that if there are enough multibyte characters before the one=20
> pointed by the mouse, v:beval_text will show a word which is somewhere=20
> left of the mouse.
> 
> There are four 2-byte UTF-8 codepoints in the line and two 3-byte ones=20
> for a total offset of 8 bytes, equal to the byte-size of the UTF-8=20
> representation of " =EF=AC=81=C5=9Don" (including the space but not the s=
> emicolon).=20
> The "virtual size" of "=EF=AC=81=C5=9Don", however, is only 4 characters,=
>  which is=20
> longer than " la" but shorter than the bytesize of "=E2=80=99 la" with th=
> e=20
> high-9 quote/apostrophe.
> 
> The 'ballooneval' option may be meant for the debugging of C programs,=20
> but what about a line invoking printf with a multibyte localized format=20
> string (in Chinese, maybe) followed by one or more variable names on the=20
> same line? Or a line with multibyte text in a /* */ comment on the left=20
> side?

Thanks for the clear description.  I'll look into it later.

-- 
hundred-and-one symptoms of being an internet addict:
170. You introduce your wife as "[email protected]" and refer to your
     children as "forked processes."

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui