fix(ui): escape quotes/backslashes when promoting ini() comments to l… - #1198
Open
billdenney wants to merge 1 commit into
Open
fix(ui): escape quotes/backslashes when promoting ini() comments to l…#1198billdenney wants to merge 1 commit into
billdenney wants to merge 1 commit into
Conversation
…abel()
A trailing `#` comment on an `ini({})` line is promoted to a `label()`
call by `.rxReplaceCommentWithLabel()` when the model is parsed with its
source refs intact. The label text was escaped correctly by `deparse1()`,
but was then interpolated into the *replacement* argument of `sub()`,
which parses backslashes in a replacement and strips one level. That
undid the escaping, so a comment containing a double quote generated
`label("fixed to a "small value"")`, which failed the re-parse with a bare
syntax error pointing into regenerated text rather than at the offending
source line. A lone backslash in the comment failed the same way.
Build the promoted line with `paste0()` instead, leaving `deparse1()`'s
escaping intact. Output is byte-identical for every comment that already
worked, including ones containing single quotes.
Because the promotion only runs when source refs are kept, the same model
resolved fine without them -- so a package build could be green while a
test suite run with `keep.source = TRUE` was red on the identical file.
Adds an enumerating test over plain, double-quoted, unbalanced-quote,
single-quoted, backslash, escaped-quote and mixed comments asserting the
comment text round-trips into the label verbatim, plus exact-output checks
for a population parameter and an eta line, and a check that a line
already carrying `label()` is left alone.
Fixes nlmixr2/rxode2 issue 1195
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
billdenney
marked this pull request as ready for review
August 7, 2026 01:46
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.
…abel()
A trailing
#comment on anini({})line is promoted to alabel()call by.rxReplaceCommentWithLabel()when the model is parsed with its source refs intact. The label text was escaped correctly bydeparse1(), but was then interpolated into the replacement argument ofsub(), which parses backslashes in a replacement and strips one level. That undid the escaping, so a comment containing a double quote generatedlabel("fixed to a "small value""), which failed the re-parse with a bare syntax error pointing into regenerated text rather than at the offending source line. A lone backslash in the comment failed the same way.Build the promoted line with
paste0()instead, leavingdeparse1()'s escaping intact. Output is byte-identical for every comment that already worked, including ones containing single quotes.Because the promotion only runs when source refs are kept, the same model resolved fine without them -- so a package build could be green while a test suite run with
keep.source = TRUEwas red on the identical file.Adds an enumerating test over plain, double-quoted, unbalanced-quote, single-quoted, backslash, escaped-quote and mixed comments asserting the comment text round-trips into the label verbatim, plus exact-output checks for a population parameter and an eta line, and a check that a line already carrying
label()is left alone.Fixes #1195