-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Account for tabs when highlighting multiline code suggestions #87976
Conversation
r? @cjgillot (rust-highfive has picked a reviewer for you, use r? to override) |
compiler/rustc_errors/src/emitter.rs
Outdated
.take(*start) | ||
.map(|ch| match ch { | ||
'\t' => 4, | ||
_ => unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, I want to confirm that the output of the terminal without emoji support you showed here is reasonable (as I fully expect it to be, because it relies on what we were doing for the multiline case, which looks ok in that screenshot).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, now I'm seeing other issues :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
655a555
to
1a519ff
Compare
This comment has been minimized.
This comment has been minimized.
d8fc003
to
e86547e
Compare
Can you take care of this PR @m-ou-se? |
e86547e
to
1cfe7c0
Compare
@m-ou-se do let me know if there's anything left here. I want to avoid this not reaching master before the next beta cutoff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found one more (unlikely) edge case (which is not very important, but not hard to fix), and a have a small comment on the code.
r=me either way
max_line_num_len + 3 + start + tabs, | ||
max_line_num_len + 3 + end + tabs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes. I assumed that we didn't have tabs in the suggestion because I didn't account for cases where snippets from the user include them :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose all cases where user snippets are included should be replaced by multispan suggestions. (This specific one is already fixed by #87958, but I think there's quite a few places left where this happens.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give me the repro case? I think I fixed this, but the suggestions seem to be doing the right thing for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With #87958 merged, the test case in the screenshot above doesn't trigger the problem anymore. We'll have to find another case where a bunch of user code gets put verbatim in the suggestion. Grepping for span_to_snippet
now. ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5398b6b
to
8f746d2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
8f746d2
to
955e913
Compare
This comment has been minimized.
This comment has been minimized.
@bors r=m-ou-se |
📌 Commit 955e913 has been approved by |
Rollup of 6 pull requests Successful merges: - rust-lang#87976 (Account for tabs when highlighting multiline code suggestions) - rust-lang#88174 (Clarify some wording in Rust 2021 lint docs) - rust-lang#88188 (Greatly improve limitation handling on parallel rustdoc GUI test run) - rust-lang#88230 (Fix typos “a”→“an”) - rust-lang#88232 (Add notes to macro-not-found diagnostics to point out how things with the same name were not a match.) - rust-lang#88259 (Do not mark `-Z thir-unsafeck` as unsound anymore) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
I'm getting this when I run
|
@camsteffen it sounds like there might be a malformed |
Yes I am seeing that error on multiple Clippy UI tests just running that command on 4878034 (and probably current master). |
I wasn't able to reproduce this :-/ |
Well shoot. Must've been an artifact of my local setup. I'm not seeing it either and it hasn't shown up in CI. |
Address
'\t'
case in #87972.Before:
After: