annotate-snippets-rs icon indicating copy to clipboard operation
annotate-snippets-rs copied to clipboard

Fix origin position computation

Open KarelPeeters opened this issue 1 year ago • 1 comments

This PR fixes an issue in the computation of the position in the origin file. When a highlighted section starts at the beginning of the line, the origin position used to point to the end of the previous line, instead of the start of the current line. This resulted in outputs like this:

error: title
 --> origin.txt:2:4
  |
1 | aaa
2 | bbb
3 | ccc
  | ^^^ annotation
4 | ddd
  |

Here origin.txt:2:4 is wrong, it should be origin.txt:3:1, which actually matches the highlighted setting.

As a drive-by fix, 21645ad032dd9117d811db57a5740b6a6406f94a fixes EndLine, which was used incorrectly in multiple places that happened to cancel out.

KarelPeeters avatar Oct 13 '24 22:10 KarelPeeters