antonWetzel / typst-languagetool

LanguageTool Integration for Typst for spell and grammer check
MIT License
33 stars 9 forks source link

Suggestion off by one character #30

Open hbierlee opened 2 weeks ago

hbierlee commented 2 weeks ago

Hi again once more,

One more (small) problem I've encountered in my complex document (which I also cannot reproduce in a simpler one) is that the suggestion span is off by one character:

image

It's completely livable, but it does mess up the auto-fix function:

image

Any idea why this happens?

Cheers,

Henk

antonWetzel commented 2 weeks ago

Looks like some bug with the indices in the long conversion chain: source $\to$ document $\to$ rust string $\to$ java string $\to$ languagetool diagnostic $\to$ source location $\to$ editor hint.

I saw this with the differences between utf8 (rust) and utf16 (java) and hoped I fixed all bugs. I try to find the problem, but without a minimal reproducible example this might be hard to pin down.

hbierlee commented 2 weeks ago

Ok! I will try to pin it down as well. So far no luck.

philher commented 3 days ago

It appears that changing adding indent to the first line of paragraph using #set par(first-line-indent: 2em) causes this issue.

image

image

Note how the squiggle location is correct in the first paragraph, which is not indented, but shifted in the second one.

antonWetzel commented 3 days ago

I think the issue originates from a bug in the typst source.

Typst-Issue: https://github.com/typst/typst/issues/4979