Skip to content

Commit 9d076fc

Browse files
empty curly have no spaces
1 parent 08d11e1 commit 9d076fc

File tree

7 files changed

+24
-9
lines changed

7 files changed

+24
-9
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ repos:
3434
)$
3535
- id: roxygenize
3636
additional_dependencies:
37-
- r-lib/pkgapi
3837
- dplyr
3938
- roxygen2
4039
- rlang
@@ -102,7 +101,7 @@ repos:
102101
)$
103102
- id: pkgdown
104103
- repo: https://github.com/pre-commit/pre-commit-hooks
105-
rev: v4.6.0
104+
rev: v5.0.0
106105
hooks:
107106
- id: check-added-large-files
108107
args: ["--maxkb=200"]
@@ -120,7 +119,7 @@ repos:
120119
tests/testthat/_snaps/.*|
121120
)$
122121
- repo: https://github.com/lorenzwalthert/gitignore-tidy
123-
rev: 517cddbf1d8514ddaf43159686617ae65895dc99
122+
rev: 0.1.2
124123
hooks:
125124
- id: tidy-gitignore
126125
- repo: local

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Roxygen: list(markdown = TRUE, roclets = c( "rd", "namespace", "collate",
5252
if (rlang::is_installed("pkgapi")) "pkgapi::api_roclet" else {
5353
warning("Please install r-lib/pkgapi to make sure the file API is kept
5454
up to date"); NULL}))
55-
RoxygenNote: 7.3.1
55+
RoxygenNote: 7.3.2
5656
Language: en-US
5757
Config/testthat/edition: 3
5858
Config/testthat/parallel: true

R/rules-spaces.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ add_space_after_for_if_while <- function(pd_flat) {
174174

175175
#' @rdname set_line_break_around_curly_curly
176176
#' @keywords internal
177-
set_space_in_curly_curly <- function(pd) {
177+
set_space_in_curly <- function(pd) {
178178
if (is_curly_expr(pd)) {
179+
# curly-curly
179180
after_inner_opening <- pd$token == "'{'" & pd$token_before == "'{'"
180181
before_inner_closing <- lead(pd$token == "'}'" & pd$token_after == "'}'")
181182
is_curly_curly_inner <- any(after_inner_opening, na.rm = TRUE) &&
@@ -193,6 +194,10 @@ set_space_in_curly_curly <- function(pd) {
193194
pd$spaces[after_outer_opening] <- 0L
194195
pd$spaces[before_outer_closing] <- 0L
195196
}
197+
198+
# empty curly
199+
after_is_empty_curly <- lead(pd$token == "'}'" & pd$token_before == "'{'")
200+
pd$spaces[after_is_empty_curly] <- 0L
196201
}
197202
pd
198203
}

R/style-guides.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ tidyverse_style <- function(scope = "tokens",
122122
},
123123
set_space_between_levels = set_space_between_levels,
124124
set_space_between_eq_sub_and_comma = set_space_between_eq_sub_and_comma,
125-
set_space_in_curly_curly = set_space_in_curly_curly
125+
set_space_in_curly = set_space_in_curly
126126
)
127127
}
128128

@@ -209,7 +209,7 @@ tidyverse_style <- function(scope = "tokens",
209209
start_comments_with_space = "COMMENT",
210210
remove_space_after_unary_pm_nested = c("'+'", "'-'"),
211211
spacing_before_comments = "COMMENT",
212-
set_space_in_curly_curly = c("'{'", "'}'")
212+
set_space_in_curly = c("'{'", "'}'")
213213
),
214214
indention = list(
215215
# indent_braces = c("'('", "'['", "'{'", "')'", "']'", "'}'"),

man/set_line_break_around_curly_curly.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/line_breaks_and_other/curly-in.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ test_that(
4141
# comment
4242
expect_equal(1 + 1, 2)
4343
})
44+
45+
46+
while (TRUE) { }
47+
48+
while (TRUE)
49+
{ }

tests/testthat/line_breaks_and_other/curly-out.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ test_that(
3838
expect_equal(1 + 1, 2)
3939
}
4040
)
41+
42+
43+
while (TRUE) {}
44+
45+
while (TRUE) {}

0 commit comments

Comments
 (0)