Skip to content

Wrong brace indent for not default indent value #909

@dbykova

Description

@dbykova

There is a case with wrong formatting of curl braces when styler is run with not default indent (indent_by = 4).
Here is an example:

styler_result <- styler::style_text("
value <- 5
if (value > 0)
    print(value)
",
indent_by = 4
)

print(styler_result)
#> # The result looks like:
#> value <- 5
#> if (value > 0) {
#>       print(value)
#>   }

#> # What I expect to get:
#> value <- 5
#> if (value > 0) {
#>     print(value)
#> }

Also, if I run the styler on this output, it won’t change anything.

styler::style_text(
    styler_result,
    indent_by = 4
)
#> value <- 5
#> if (value > 0) {
#>       print(value)
#>   }

At the same moment, the example works fine with the default indent (indent_by = 2):

styler::style_text("
value <- 5
if (value > 0)
    print(value)
")
#> value <- 5
#> if (value > 0) {
#>   print(value)
#> }

Versions.
R: 3.6.3
styler: 1.6.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions