Alexey Radkov wrote: > 2014-07-04 18:22 GMT+04:00 Павлов Николай Александрович <[email protected]>: > > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA512 > > > > Are you sure you need exactly screen cells? There are the following > > possible ways to identify position inside a string: > > > > 1. Byte offset. > > 2. Unicode codepoints offset. > > 3. Composed characters offset (one "composed character" is "one Unicode > > codepoint with attached composing characters (if any)"). > > 4. Screen cells offset. > > > > Ok, i can imagine all the use cases but i cannot map all of them against > their usage frequency in majority of the vim plugins. If I have known that > 4 is very rare i would not have suggested this patch :) ... I just remember > that LCD asked for 4 in Syntastic plugin. > > > > I doubt anybody will use 4. outside of a editor because it is hard to > > calculate. There are two settings that affect 4. and are only defined in a > > editor: &tabstop and &ambiwidth. *You must not use screen cells offset with > > editor settings if you received it from another source.* It is incorrect: > > you need settings from another source, not from this instance of editor. > > > > And ***do never use screen cells to count characters***. Code that assumes > > any fixed amount of Unicode codepoints per one cell is brain-damaged, > > broken and wrong. > > > > > > For this patch I heard the following use cases: > > > > 1. matchparen. Will happily live with byte offset. > > > > Not really. Apart of the fact that it gets matching parens in a wrong way > like > > c = getline(c_lnum)[c_col - 1] > > which will always mean 1 byte symbol, it uses matchaddpos() (or 3match > earlier) that rely on 1-byte symbol too.
We already concluded that the code should round the size up to a full character. You can't highlight one byte of a multi-byte character. > I made an experiment: > > :set matchpairs()+=в:д > > These symbols are not pairly highlighted with matchparen whereas '%' works > just fine: the reason is simple: both result of getline() and > matchaddpos()/3match must know that symbol under cursor is longer than 1 > byte, it means that script must calculate it itself. There is no need to make calculations if we round up to a character. -- When I look deep into your eyes, I see JPEG artifacts. I can tell by the pixels that we're wrong for each other. (xkcd) /// 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.
