Merged
Conversation
DavisVaughan
commented
Aug 6, 2025
Comment on lines
53
to
61
| json_format_text <- function(text, spaces = 4) { | ||
| stopifnot(is.character(json)) | ||
| json <- paste(json, collapse = '\n') | ||
| stopifnot(is.character(text)) | ||
| text <- paste(text, collapse = '\n') | ||
| opts <- list(insertSpaces = spaces > 0, tabSize = spaces) | ||
| jsonc$call('json_format', json, opts) | ||
| if (!is.null(json_parse_errors(text))) { | ||
| stop("Can't format when there are existing parse errors.") | ||
| } | ||
| jsonc$call('json_format', text, opts) | ||
| } |
Member
Author
There was a problem hiding this comment.
json wasn't actually defined here so this previously failed. i think you meant to use text, and ive standardized all functions to just use text now
Member
There was a problem hiding this comment.
Ah right I renamed those variables at some point 🤦
Merged
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.
I feel like if we were to use this then we'd fail early if there are parse errors to avoid weirdness
We get a data frame of info back when there are parse errors which we could use to inform the user about where the problem is
For now I'm not using this
https://github.com/microsoft/node-jsonc-parser/blob/fe330190baba3ba630934d27ea2083638feddadc/src/main.ts#L151
Also worth noting that just yesterday they added
startLineandstartCharacterto the error output struct, so we'd get that too and it might be easier to show the user info using that infomicrosoft/node-jsonc-parser#102