Skip to content
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

Indention with multiple tokens starting (but not ending) on same line #485

lorenzwalthert opened this issue Mar 15, 2019 · 0 comments


None yet
1 participant
Copy link

commented Mar 15, 2019

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|",
  "a = 1,",
  "c = 2",
#> a <- 3
#> b <- 5
#> c <- purrr::map(a |
#>   b,
#> a = 1,
#> c = 2
#> )

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.

  a | 
  a = 1, 
  c = 2

The same with braces, i.e. the following is not nice:


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.