When we parse the report produced by a source, we usually read and forward the column index, but in Lua, the index of a substring depends on the number of bytes in the string, not the number of printable characters.
For example, the line:
• Any rule whose heading is ~~struck through~~ is deprecated.
Produces the report:
text:1:47:"is deprecated" may be passive voice
But if we use that 47 to create the diagnostic, Lua will count 47 bytes, which will give us:
"~~ is deprecated"
Instead of
"is deprecated"
That's why we end up with the odd range described in #19.
Luckily, the Neovim team has a function to find the index we need through the function vim.str_byteindex.
When we parse the report produced by a source, we usually read and forward the column index, but in Lua, the index of a substring depends on the number of bytes in the string, not the number of printable characters.
For example, the line:
Produces the report:
But if we use that
47
to create the diagnostic, Lua will count 47 bytes, which will give us:Instead of
That's why we end up with the odd range described in #19.
Luckily, the Neovim team has a function to find the index we need through the function
vim.str_byteindex
.