-
Notifications
You must be signed in to change notification settings - Fork 44
Off-by-one error in multiline error highlights #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A possible fix is to change annotate-snippets-rs/src/display_list/from_snippet.rs Lines 430 to 433 in 46c5588
to let end_mark = (end - line_start).saturating_sub(1);
let range = (
end_mark - margin_left,
(end_mark + 1) - margin_left,
); The question here is what to do about annotations that end on a newline, like
which is the same as the current behavior, but if the annotation is extended to
I don't know how to test what rustc does if the error highlight ends on a newline; it generally tries to avoid this and it also doesn't come up in my application so it doesn't seem very important. |
Ah, I found the relevant code in rustc. start_col: self.end_col.saturating_sub(1),
end_col: self.end_col, Using
But this is also an option if that seems reasonable to folks. |
In both cases, the highlight begins at letter
e
and ends at letterl
. In the one-line case, it is correct:But in multiple lines it is off by one - the end pointer points to one past the end rather than the last character of the highlight:
I could propose code but I'm not sure I'll get all the details of continuations right since I haven't used those and am not certain of the desired behavior. Here's the issue presented as a test case.
The text was updated successfully, but these errors were encountered: