*Warning* This message is in UTF-8. Any "modern" mailer ought to be able
to display it correctly by obeying its Content-Type header, which was
set correctly when I sent it.
Bug seen in:
gvim 7.2.245 (Huge, GTK2/Gnome2). Full ":version" text available on request.
Description:
v:beval_text incorrectly evaluates the mouse position in relation to the
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
and has 'encoding' set to UTF-8
2. Edit a file containing the following single-line text (this is UTF-8,
I recommend copy-paste from this message):
Jam pretiĝis li por tranĉi, fendi per tranĉil’ la fiŝon;
If you cannot use copy-paste, here are (in left-to-right order) the
non-ASCII codepoints in the line (from Chapter 5 of J.E.Leppäkoski's
translation of the Finnish national epic /Kalevala/ by Elias Lönnrot):
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
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='''Cursor is at line '' . v:beval_lnum . '', column ''
. v:beval_col . '' of file '' . bufname(v:beval_bufnr) . '' on word "''
. v:beval_text . ''"'''
(the above is all on one line, and inspired by the example under ":help
'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 "fiŝon" the balloon shows the current word as
"la"; but if you move the mouse to the ending semicolon, the current
word is shown in the balloon as "fiŝon".
Expected results:
The balloon should display the word under the mouse pointer, not the one
before it.
Additional info:
I suspect that v:beval_text is the word whose _byte_ position in the
line corresponds to the _screen_ position of the mouse (maybe after
correcting for hard tabs and/or ^A ~B etc., which I haven't tested). The
result is that if there are enough multibyte characters before the one
pointed by the mouse, v:beval_text will show a word which is somewhere
left of the mouse.
There are four 2-byte UTF-8 codepoints in the line and two 3-byte ones
for a total offset of 8 bytes, equal to the byte-size of the UTF-8
representation of " fiŝon" (including the space but not the semicolon).
The "virtual size" of "fiŝon", however, is only 4 characters, which is
longer than " la" but shorter than the bytesize of "’ la" with the
high-9 quote/apostrophe.
The 'ballooneval' option may be meant for the debugging of C programs,
but what about a line invoking printf with a multibyte localized format
string (in Chinese, maybe) followed by one or more variable names on the
same line? Or a line with multibyte text in a /* */ comment on the left
side?
Best regards,
Tony.
--
Beware of self-styled experts: an ex is a has-been, and a spurt is a
drip under pressure.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---