Skip to content

Commit

Permalink
add case for unnamed
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Apr 13, 2021
1 parent e1b29c3 commit 622ceef
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 33 deletions.
2 changes: 1 addition & 1 deletion R/detect-alignment.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ token_is_on_aligned_line <- function(pd_flat) {

# when match via comma unsuccessful, matching by = must yield at least one =
is_aligned <- length(unique(start_after_eq + previous_line)) == 1 && length(start_after_eq) > 1
previous_line <- nchar(by_line)
previous_line <- nchar(by_line) + previous_line
if (column >= start_eval && !is_aligned) {
# when not all are named, we need colum 1 for previous_line
return(FALSE)
Expand Down
8 changes: 7 additions & 1 deletion tests/testthat/alignment/named-in.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,15 @@ ca(
m = c(rm.na = 7)
)

# aligned
# aligned =, first all named
fell(
x = 8, annoying = 3,
y = 23, # nothing in column 2 for row 2
zz = NULL, finally = "stuff"
)

# aligned =, first not all named
gell(
p = 2, g = gg(x), n = 3 * 3, #
31, fds = -1, gz = f / 3 + 1,
)
113 changes: 83 additions & 30 deletions tests/testthat/alignment/named-in_tree

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion tests/testthat/alignment/named-out.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,15 @@ ca(
m = c(rm.na = 7)
)

# aligned
# aligned =, first all named
fell(
x = 8, annoying = 3,
y = 23, # nothing in column 2 for row 2
zz = NULL, finally = "stuff"
)

# aligned =, first not all named
gell(
p = 2, g = gg(x), n = 3 * 3, #
31, fds = -1, gz = f / 3 + 1,
)

0 comments on commit 622ceef

Please sign in to comment.