diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf22944df..4f34c10b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,6 @@ repos: )$ - id: roxygenize additional_dependencies: - - r-lib/pkgapi - dplyr - roxygen2 - rlang @@ -102,7 +101,7 @@ repos: )$ - id: pkgdown - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files args: ["--maxkb=200"] @@ -120,7 +119,7 @@ repos: tests/testthat/_snaps/.*| )$ - repo: https://github.com/lorenzwalthert/gitignore-tidy - rev: 517cddbf1d8514ddaf43159686617ae65895dc99 + rev: 0.1.2 hooks: - id: tidy-gitignore - repo: local diff --git a/DESCRIPTION b/DESCRIPTION index 42229a06c..a7d401163 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,7 +52,7 @@ Roxygen: list(markdown = TRUE, roclets = c( "rd", "namespace", "collate", if (rlang::is_installed("pkgapi")) "pkgapi::api_roclet" else { warning("Please install r-lib/pkgapi to make sure the file API is kept up to date"); NULL})) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Language: en-US Config/testthat/edition: 3 Config/testthat/parallel: true diff --git a/R/rules-spaces.R b/R/rules-spaces.R index c96584d6c..54f4bf289 100644 --- a/R/rules-spaces.R +++ b/R/rules-spaces.R @@ -174,8 +174,9 @@ add_space_after_for_if_while <- function(pd_flat) { #' @rdname set_line_break_around_curly_curly #' @keywords internal -set_space_in_curly_curly <- function(pd) { +set_space_in_curly <- function(pd) { if (is_curly_expr(pd)) { + # curly-curly after_inner_opening <- pd$token == "'{'" & pd$token_before == "'{'" before_inner_closing <- lead(pd$token == "'}'" & pd$token_after == "'}'") is_curly_curly_inner <- any(after_inner_opening, na.rm = TRUE) && @@ -193,6 +194,10 @@ set_space_in_curly_curly <- function(pd) { pd$spaces[after_outer_opening] <- 0L pd$spaces[before_outer_closing] <- 0L } + + # empty curly + after_is_empty_curly <- lead(pd$token == "'}'" & pd$token_before == "'{'") + pd$spaces[after_is_empty_curly] <- 0L } pd } diff --git a/R/style-guides.R b/R/style-guides.R index 1445586ac..39fc30118 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -122,7 +122,7 @@ tidyverse_style <- function(scope = "tokens", }, set_space_between_levels = set_space_between_levels, set_space_between_eq_sub_and_comma = set_space_between_eq_sub_and_comma, - set_space_in_curly_curly = set_space_in_curly_curly + set_space_in_curly = set_space_in_curly ) } @@ -209,7 +209,7 @@ tidyverse_style <- function(scope = "tokens", start_comments_with_space = "COMMENT", remove_space_after_unary_pm_nested = c("'+'", "'-'"), spacing_before_comments = "COMMENT", - set_space_in_curly_curly = c("'{'", "'}'") + set_space_in_curly = c("'{'", "'}'") ), indention = list( # indent_braces = c("'('", "'['", "'{'", "')'", "']'", "'}'"), diff --git a/man/set_line_break_around_curly_curly.Rd b/man/set_line_break_around_curly_curly.Rd index 06fd2fa9e..1215ff6d4 100644 --- a/man/set_line_break_around_curly_curly.Rd +++ b/man/set_line_break_around_curly_curly.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/rules-line-breaks.R, R/rules-spaces.R \name{set_line_break_around_curly_curly} \alias{set_line_break_around_curly_curly} -\alias{set_space_in_curly_curly} +\alias{set_space_in_curly} \title{Styling around \verb{\\\{\\\{}} \usage{ set_line_break_around_curly_curly(pd) -set_space_in_curly_curly(pd) +set_space_in_curly(pd) } \arguments{ \item{pd}{A parse table.} diff --git a/tests/testthat/line_breaks_and_other/curly-in.R b/tests/testthat/line_breaks_and_other/curly-in.R index 9f44b5716..03650832a 100644 --- a/tests/testthat/line_breaks_and_other/curly-in.R +++ b/tests/testthat/line_breaks_and_other/curly-in.R @@ -41,3 +41,9 @@ test_that( # comment expect_equal(1 + 1, 2) }) + + +while (TRUE) { } + +while (TRUE) + { } diff --git a/tests/testthat/line_breaks_and_other/curly-out.R b/tests/testthat/line_breaks_and_other/curly-out.R index c55508290..4ad742fc6 100644 --- a/tests/testthat/line_breaks_and_other/curly-out.R +++ b/tests/testthat/line_breaks_and_other/curly-out.R @@ -38,3 +38,8 @@ test_that( expect_equal(1 + 1, 2) } ) + + +while (TRUE) {} + +while (TRUE) {}