Hello, I apologize if this is the wrong list/place for the following concern:
I did some tests with virtcol() and compared the results with my expectations (which may be plain wrong), see also Issue 277. Here is one example of the test-set for the line: πa ββββββ¬βββββ¬βββββββββββ¬βββββ¬ββββββββββββββββββ Ind.βByteβcodepoint βVcolβ grapheme cluster ββββββΌβββββΌβββββββββββΌβββββΌββββββββββββββββββ 00 β f0 β U+01f600 β 01 β π 01 β 9f β β β 02 β 98 β β β 03 β 80 β β β ββββββΌβββββΌβββββββββββΌβββββΌββββββββββββββββββ 04 β 61 β U+000061 β 03 β a ββββββ΄βββββ΄βββββββββββ΄βββββ΄ββββββββββββββββββ vcol(Ind= 0)=virtcol([<line>, 1])= 2; expected= 2 β vcol(Ind= 1)=virtcol([<line>, 2])= 3; expected= 2 β vcol(Ind= 2)=virtcol([<line>, 3])= 3; expected= 2 β vcol(Ind= 3)=virtcol([<line>, 4])= 3; expected= 2 β vcol(Ind= 4)=virtcol([<line>, 5])= 3; expected= 3 β vcol(Ind= 5)=virtcol([<line>, 6])= 4; expected= 4 β vcol(Ind= 6)=virtcol([<line>, 7])= 0; expected= 0 β Here is the test-script with more examples https://github.com/luchr/tests/blob/master/vim/issue277/issue277.vim and here are the results for (g)vim 8.0.237: https://raw.githubusercontent.com/luchr/tests/master/vim/issue277/testresult.txt Can somebody help me and tell me, where my expectations are wrong and/or where the current given results (of virtcol()) are considered as wrong/bug? I tried to produce human-readable output, such that the test results can be viewed/studied without running vim. In case somebody has the same expectations, then the following patch solves a lot (but not all) of the problematic cases for me. [I'm unsure/uncertain, because for me this is a difficult topic.] ``` --- charset_orig.c 2017-01-26 23:10:59.294937663 +0100 +++ charset.c 2017-01-26 23:44:21.713784701 +0100 @@ -1286,6 +1286,7 @@ char_u *ptr; /* points to current char */ char_u *posptr; /* points to char at pos->col */ char_u *line; /* start of the line */ + char_u *nextpos; int incr; int head; int ts = wp->w_buffer->b_p_ts; @@ -1355,11 +1356,14 @@ incr = g_chartab[c] & CT_CELL_MASK; } - if (posptr != NULL && ptr >= posptr) /* character at pos->col */ + nextpos = ptr; + mb_ptr_adv(nextpos); + + if (posptr != NULL && (ptr >= posptr || nextpos > posptr )) break; vcol += incr; - mb_ptr_adv(ptr); + ptr = nextpos; } } else ``` Bye C. Ludwig -- -- 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.
