Dominique wrote:

> Related to this thread, the grammar checker LanguageTool has
> changed its API [1] and now defines the position of errors as:
> - an offset in Unicode characters from the beginning of the
>   document (not from the beginning of the line! newlines \n are
>   counted as 1 character)
> - and length in Unicode characters.
> 
> This API change breaks my LanguageTool grammar checker
> plugin [2] with the latest LanguageTool.
> 
> LanguageTool API is poorly documented, but experimenting
> with it, I see that combining Unicode characters such as
> U+0065 + U+0301 for e-acute are counted as 2
> characters.
> 
> I wonder whether vim has suitable functions() to find the
> corresponding byte offset of a line/column with such input
> data (i.e. Unicode character offset from start of file + Unicode
> character length). At first glance, I did not see any suitable
> Vim function.

There isn't one.  And there probably will not be one.

We do have the byte2line() function, which works with the byte offset.
This was quite a bit of work to implement and get right.  And it adds
overhead, since any change to the text requires the cached values to be
updated.  Adding character offset on top of that would make it less
efficient, and since it wasn't askef for until now I expect it to be
rarely used.

I would suggest to the authors, explain that the API can't be used this
way, and that they should fix that.  They could provide a setting to
either use byte or character offsets.  Or at least provide the line
number, then the computation on the Vim side is likely fast enough.

-- 
A meeting is an event at which the minutes are kept and the hours are lost.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221122110646.D9BA01C212A%40moolenaar.net.

Raspunde prin e-mail lui