-
Notifications
You must be signed in to change notification settings - Fork 9
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
highlight() trims long strings #20
Comments
tibble::as_tibble(getParseData(parse(text = paste0("fun('", strrep("-", 10), "')")), includeText=TRUE))
#> # A tibble: 7 × 9
#> line1 col1 line2 col2 id parent token terminal text
#> <int> <int> <int> <int> <int> <int> <chr> <lgl> <chr>
#> 1 1 1 1 17 10 0 expr FALSE fun('-----…
#> 2 1 1 1 3 1 3 SYMBOL_FUNCTION_CALL TRUE fun
#> 3 1 1 1 3 3 10 expr FALSE fun
#> 4 1 4 1 4 2 10 '(' TRUE (
#> 5 1 5 1 16 4 6 STR_CONST TRUE '---------…
#> 6 1 5 1 16 6 10 expr FALSE '---------…
#> 7 1 17 1 17 5 10 ')' TRUE )
tibble::as_tibble(getParseData(parse(text = paste0("fun('", strrep("-", 10), "')")), includeText=TRUE))$text[5:6]
#> [1] "'----------'" "'----------'"
tibble::as_tibble(getParseData(parse(text = paste0("fun('", strrep("-", 1000), "')")), includeText=TRUE))
#> # A tibble: 7 × 9
#> line1 col1 line2 col2 id parent token terminal text
#> <int> <int> <int> <int> <int> <int> <chr> <lgl> <chr>
#> 1 1 1 1 1007 10 0 expr FALSE fun('-----…
#> 2 1 1 1 3 1 3 SYMBOL_FUNCTION_CALL TRUE fun
#> 3 1 1 1 3 3 10 expr FALSE fun
#> 4 1 4 1 4 2 10 '(' TRUE (
#> 5 1 5 1 1006 4 6 STR_CONST TRUE [1000 char…
#> 6 1 5 1 1006 6 10 expr FALSE '---------…
#> 7 1 1007 1 1007 5 10 ')' TRUE ) Created on 2022-11-06 with reprex v2.0.2 |
I wonder if it is the same with raw strings. Probably. |
Yes it does, and with long symbols too, though I guess it's pretty rare to have a 1000 char long symbol. This seems to do it :
Would you like a PR ? |
Yes, please. But please use the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This causes issues in {styler} : r-lib/styler#216
data <- getParseData(parsed, includeText = NA)
is the culprit, we'd needincludeText = TRUE
and then a bit of wrangling.If we want to keep the default behaviour could we add some argument to opt out ?
{prettycode} is sometimes used in use cases where faithfully representing code is important, so I hope it makes sense to fix it here.
For context such long strings can be found in the output of
sessionInfo()
The text was updated successfully, but these errors were encountered: