Christian Ludwig wrote: > 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.]
You are passing in an invalid position, halfway a character, thus the returned value is undefined. 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. -- Seen on the back of a biker's vest: If you can read this, my wife fell off. /// 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.
