Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Dec 7, 2024
1 parent e4da5ae commit bf5c500
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/rules-spaces.R
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ set_space_after_bang_bang <- function(pd_flat) {
remove_space_around_dollar <- function(pd_flat) {
dollar_after <- (pd_flat$token == "'$'") & (pd_flat$lag_newlines == 0L)
dollar_before <- lead(dollar_after, default = FALSE)
pd_flat$spaces[dollar_after] <- 0L
pd_flat$spaces[dollar_before] <- 0L
pd_flat$spaces[dollar_after] <- 0L
pd_flat
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/indention_operators/dollar_R6-in.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
x$
x$ add(10)$
add(10) $ add(10) $
add(10)$sum +
3
2 changes: 1 addition & 1 deletion tests/testthat/indention_operators/dollar_R6-out.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
x$
x$add(10)$
add(10)$add(10)$
add(10)$sum +
3
5 changes: 5 additions & 0 deletions tests/testthat/spacing/dollar-in.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mtcars $wt

mtcars$ wt

mtcars $ wt
5 changes: 5 additions & 0 deletions tests/testthat/spacing/dollar-out.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mtcars$wt

mtcars$wt

mtcars$wt
7 changes: 7 additions & 0 deletions tests/testthat/test-spacing.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ test_that("spacing around square brackets / braces", {
transformer = style_text, strict = TRUE
), NA)
})

test_that("spacing around dollar", {
expect_warning(test_collection(
"spacing", "dollar",
transformer = style_text, strict = TRUE
), NA)
})

0 comments on commit bf5c500

Please # to comment.