You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
if-else must be either on the same line or surrounded by braces #229
It was actually implemented with that use case in mind. The idea was to only add parenthesis if the
expression after if or else was on a new line for strict = TRUE.
styler::style_text("{\n if (TRUE) 1\nelse \n2\n}")
#> {#> if (TRUE) {#> 1#> } else {#> 2#> }#> }
With strict = FALSE, we do not add parentheses.
styler::style_text("{\n if (TRUE) 1\nelse \n2\n}", strict=FALSE)
#> {#> if (TRUE) 1#> else#> 2#> }
So how does the concrete desired implementation look like? Maybe we can produce the result from strict = FALSE with the current strict = TRUE solution and change strict = TRUE to what you @krlmlr suggest?
Activity
lorenzwalthert commentedon Oct 4, 2017
It was actually implemented with that use case in mind. The idea was to only add parenthesis if the
expression after
iforelsewas on a new line forstrict = TRUE.With
strict = FALSE, we do not add parentheses.lorenzwalthert commentedon Oct 4, 2017
So how does the concrete desired implementation look like? Maybe we can produce the result from
strict = FALSEwith the currentstrict = TRUEsolution and changestrict = TRUEto what you @krlmlr suggest?krlmlr commentedon Oct 23, 2017
strict = TRUEshould add braces also for theelsepart,strict = FALSEdoesn't need to add any braces.all-or-nothing approach for adding braces in if statemtns
all-or-nothing approach for adding braces in if statemtns