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
Multiple tokens that cause indention on the same line with at least one token causing indention over more than one line are problematic if the unindention they cause is not on the same line. This is because some lines might not be indented at all which looks odd in practice.
text<- c(
"a <- 3",
"b <- 5",
"c <- purrr::map(a|",
"b,",
"a = 1,",
"c = 2",
")"
)
styler::style_text(text)
#> a <- 3#> b <- 5#> c <- purrr::map(a |#> b,#> a = 1,#> c = 2#> )
In the example above, the opening brace does not cause indention because | will. But the scope of the indention of | ends on the next line, leaving the remainder unindented, although it is within an expression that needs indention.
Easy fix: Don't allow multiple indention tokens on the same line if their indention scope does not end on the same line but then break the line.
purrr::map(
a|b,
a=1,
c=2
)
The same with braces, i.e. the following is not nice:
{{
x
}
}
But the easy fix is to move the second { one line down. Similar to #428, but just that this issue also covers indention of tokens other than braces, but when you look at the examples in #428, I think it becomes evident that the brace case is much more common. This issue is probably also blocked by #357.
The text was updated successfully, but these errors were encountered:
Multiple tokens that cause indention on the same line with at least one token causing indention over more than one line are problematic if the unindention they cause is not on the same line. This is because some lines might not be indented at all which looks odd in practice.
Created on 2019-03-15 by the reprex package (v0.2.1)
In the example above, the opening brace does not cause indention because
|
will. But the scope of the indention of|
ends on the next line, leaving the remainder unindented, although it is within an expression that needs indention.Easy fix: Don't allow multiple indention tokens on the same line if their indention scope does not end on the same line but then break the line.
The same with braces, i.e. the following is not nice:
{{ x } }
But the easy fix is to move the second
{
one line down. Similar to #428, but just that this issue also covers indention of tokens other than braces, but when you look at the examples in #428, I think it becomes evident that the brace case is much more common. This issue is probably also blocked by #357.The text was updated successfully, but these errors were encountered: