Track single-quoted strings and skip comments when detecting missing record commas#202
Merged
fdncred merged 1 commit intoJul 5, 2026
Conversation
…repair detect_missing_record_comma_positions tracked single- and double-quote string state but had no awareness of `#` line comments. An apostrophe inside a comment (don't, it's, can't) toggled the single-quote tracking just like a real string, desyncing quote parity for everything after it until the next `'`. That could reintroduce the exact nushell#201 spurious-comma bug even with balanced quotes in actual code, as long as a comment with an odd number of apostrophes preceded a $"..." interpolation closely enough to fall in the repair window. Skip `#`-to-end-of-line comment spans before doing byte-level quote tracking, reusing the existing string-aware comment extraction from comments.rs so a `#` inside a string still isn't treated as a comment. Fixes nushell#201
Contributor
|
Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
detect_missing_record_comma_positionstracked double-quote string state but not single-quoted strings, so a"inside a'...'literal (e.g.let x = '"') desynced the parser's quote tracking and caused a spurious comma to be inserted into a later$"..."interpolation.This adds single-quote string tracking, and also skips
#comment bodies during the same scan (reusing the existing comment extraction from comments.rs) so an apostrophe inside a comment like# don'tcan't be mistaken for the start of a single-quoted string and desync things the same way.Relevant Issues
Fixes #201