Fix idempotency issue with raw strings - #6696
Conversation
|
I’m not very familiar with the codebase, so there might be a better way to handle this. |
| match chr { | ||
| '"' => { | ||
| if sharps == 0 { | ||
| char_kind = FullCodeCharKind::Normal; |
There was a problem hiding this comment.
Question (not necessary for you, but one I had when looking at this diff): do we know or can we guess why we have to override char_kind in this arm? I'm a bit concerned that while this diff is seemingly tiny and fixes #6161, that it regresses another pattern that isn't occurring to me just yet.
There was a problem hiding this comment.
The override comes from 6748042, which first special cased r"...". Before that commit it was lexed through LitString, where the closing quote is already InString. The Normal override looks copied from the RawStringSuffix arm, where the last # is Normal.
| "a": r"bb | ||
| ccc | ||
| ", | ||
| }; |
There was a problem hiding this comment.
Discussion (not really for author): okay, so this I am not 100% sure about. Can we actually format raw strings, or strings in general, in user macros? Do we want to?
This raw string here AFAIK are indeed equivalent so...
50a49e7 to
cb10a13
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Fixes #6161
CharClassesclassifies the closing quote ofr"..."asNormal, while"..."andr#"..."#classify theirs asInString. When that quote starts a line,LineClassesfails to mark the line asEndString, sotrim_left_preserve_layouttreats it as code with zero leading whitespace. The minimum indentation of the macro body is then always zero and every run indents the body one more level.