r-lib / styler

Non-invasive pretty printing of R code
https://styler.r-lib.org
Other
713 stars 70 forks source link

wrong behavior with pipes for multiline lhs #1153

Closed moodymudskipper closed 10 months ago

moodymudskipper commented 10 months ago
requireNamespace("styler")

# minimal
structure(
  c("(x\n) |>", "  fun()"),
  class = "vertical"
)
#> (x
#> ) |>
#> ) |>n()

# use case
structure(
  c("(function(x) {\n  x\n}) |>", "  (`environment<-`)(.GlobalEnv)"),
  class = "vertical"
)
#> (function(x) {
#>   x
#> }) |>
#>   x`environment<-`)(.GlobalEnv)

Created on 2023-11-07 with reprex v2.0.2

lorenzwalthert commented 10 months ago

Thanks. But I don't know if I understand you correctly. Please descrite input, output and expected output. If applicable, please supply a reference to the tidyverse style guide what is wrong here.

moodymudskipper commented 10 months ago

The issue is that for these provided inputs the output is not syntactic and not faithful to the input, but I see now that it's a {prettycode} issue, not directly {styler}