Skip to content

Commit 44e3c64

Browse files
Merge branch 'main' into issue-984
2 parents b86e324 + 305644b commit 44e3c64

18 files changed

+145
-103
lines changed

.github/workflows/check-full.yaml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3-
43
on:
54
push:
65
branches: [main, master]
76
pull_request:
87
branches: [main, master]
98

10-
119
name: R-CMD-check
1210

1311
jobs:
@@ -20,26 +18,27 @@ jobs:
2018
fail-fast: false
2119
matrix:
2220
config:
23-
- {os: macOS-latest, r: 'release'}
21+
- {os: macos-latest, r: 'release'}
2422

2523
- {os: windows-latest, r: 'release'}
2624
# Use 3.6 to trigger usage of RTools35
2725
- {os: windows-latest, r: '3.6'}
26+
# use 4.1 to check with rtools40's older compiler
27+
- {os: windows-latest, r: '4.1'}
2828

29-
# Use older ubuntu to maximise backward compatibility
30-
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
31-
- {os: ubuntu-latest, r: 'release'}
32-
- {os: ubuntu-latest, r: 'oldrel-1'}
33-
- {os: ubuntu-latest, r: 'oldrel-2'}
34-
- {os: ubuntu-latest, r: 'oldrel-3'}
35-
- {os: ubuntu-latest, r: 'oldrel-4'}
29+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
30+
- {os: ubuntu-latest, r: 'release'}
31+
- {os: ubuntu-latest, r: 'oldrel-1'}
32+
- {os: ubuntu-latest, r: 'oldrel-2'}
33+
- {os: ubuntu-latest, r: 'oldrel-3'}
34+
- {os: ubuntu-latest, r: 'oldrel-4'}
3635

3736
env:
3837
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3938
R_KEEP_PKG_SOURCE: yes
4039

4140
steps:
42-
- uses: actions/checkout@v2
41+
- uses: actions/checkout@v3
4342

4443
- uses: r-lib/actions/setup-pandoc@v2
4544

@@ -56,10 +55,7 @@ jobs:
5655

5756
- uses: r-lib/actions/check-r-package@v2
5857
with:
58+
upload-snapshots: true
5959
error-on: '"note"'
6060
env:
6161
_R_CHECK_FORCE_SUGGESTS_: false
62-
63-
concurrency:
64-
group: ${{ github.workflow }}-${{ github.head_ref }}
65-
cancel-in-progress: true

.github/workflows/pkgdown.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
env:
2121
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v3
2424

2525
- uses: r-lib/actions/setup-pandoc@v2
2626

@@ -39,7 +39,7 @@ jobs:
3939

4040
- name: Deploy to GitHub pages 🚀
4141
if: github.event_name != 'pull_request'
42-
uses: JamesIves/[email protected].4
42+
uses: JamesIves/github-pages-deploy-action@v4.4.1
4343
with:
4444
clean: false
4545
branch: gh-pages
Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,31 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
13
on:
24
push:
3-
branches:
4-
- main
5+
branches: [main, master]
56
pull_request:
6-
branches:
7-
- main
7+
branches: [main, master]
88

99
name: test-coverage
1010

1111
jobs:
1212
test-coverage:
13-
runs-on: macOS-latest
13+
runs-on: ubuntu-latest
1414
env:
1515
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16-
steps:
17-
- uses: actions/checkout@v2
18-
19-
- uses: r-lib/actions/setup-r@master
2016

21-
- uses: r-lib/actions/setup-pandoc@master
22-
23-
- name: Query dependencies
24-
run: |
25-
install.packages('remotes')
26-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
27-
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
28-
shell: Rscript {0}
17+
steps:
18+
- uses: actions/checkout@v3
2919

30-
- name: Cache R packages
31-
uses: actions/cache@v1
20+
- uses: r-lib/actions/setup-r@v2
3221
with:
33-
path: ${{ env.R_LIBS_USER }}
34-
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
35-
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
22+
use-public-rspm: true
3623

37-
- name: Install dependencies
38-
run: |
39-
install.packages(c("remotes"))
40-
remotes::install_deps(dependencies = TRUE)
41-
remotes::install_cran("covr")
42-
shell: Rscript {0}
24+
- uses: r-lib/actions/setup-r-dependencies@v2
25+
with:
26+
extra-packages: any::covr
27+
needs: coverage
4328

4429
- name: Test coverage
45-
run: covr::codecov()
30+
run: covr::codecov(quiet = FALSE)
4631
shell: Rscript {0}
47-
48-
concurrency:
49-
group: ${{ github.workflow }}-${{ github.head_ref }}
50-
cancel-in-progress: true

R/expr-is.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ is_subset_expr <- function(pd) {
9696
if (is.null(pd) || nrow(pd) == 1) {
9797
return(FALSE)
9898
}
99-
pd$token[2L] == "'['"
99+
pd$token[2L] %in% subset_token_opening
100100
}
101101

102102

R/indent.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,15 @@ indent_without_paren_if_else <- function(pd, indent_by) {
8787
#' example in if-else expressions, this is not the case and indenting
8888
#' everything between '(' and the penultimate token would result in the wrong
8989
#' formatting.
90+
#' @section Handing of `[[`:
91+
#' Since text `[[` has token `"LBB"` and text `]]` is parsed as two independent
92+
#' `]` (see 'Examples'), indention has to stop at the first `]`.
93+
# one token earlier
9094
#' @importFrom rlang seq2
9195
#' @keywords internal
96+
#' @examples
97+
#' styler:::parse_text("a[1]")
98+
#' styler:::parse_text("a[[1\n]]")
9299
compute_indent_indices <- function(pd,
93100
token_opening,
94101
token_closing = NULL) {
@@ -105,7 +112,8 @@ compute_indent_indices <- function(pd,
105112
if (is.null(token_closing)) {
106113
stop <- npd
107114
} else {
108-
stop <- last(which(pd$token %in% token_closing)[needs_indention]) - 1
115+
offset <- if (any(pd$token == "LBB")) 2L else 1L
116+
stop <- last(which(pd$token %in% token_closing)[needs_indention]) - offset
109117
}
110118

111119
seq2(start, stop)

R/rules-indention.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
indent_braces <- function(pd, indent_by) {
55
indent_indices <- compute_indent_indices(
66
pd,
7-
token_opening = c("'('", "'['", "'{'"),
7+
token_opening = c("'('", "'['", "'{'", "LBB"),
88
token_closing = c("')'", "']'", "'}'")
99
)
1010
pd$indent[indent_indices] <- pd$indent[indent_indices] + indent_by

R/rules-line-breaks.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ set_line_break_around_comma_and_or <- function(pd, strict) {
128128
(pd$token %in% ops) &
129129
(pd$lag_newlines > 0L) &
130130
(pd$token_before != "COMMENT") &
131-
(lag(pd$token) != "'['")
131+
!(lag(pd$token) %in% subset_token_opening)
132132

133133
pd$lag_newlines[comma_with_line_break_that_can_be_removed_before] <- 0L
134134
pd$lag_newlines[lag(comma_with_line_break_that_can_be_removed_before)] <- 1L
@@ -137,7 +137,7 @@ set_line_break_around_comma_and_or <- function(pd, strict) {
137137
(pd$token == "EQ_SUB") &
138138
(pd$lag_newlines > 0L) &
139139
(pd$token_before != "COMMENT") &
140-
(lag(pd$token) != "'['")
140+
!(lag(pd$token) %in% subset_token_opening)
141141
)
142142

143143
pd$lag_newlines[comma_with_line_break_that_can_be_moved_two_tokens_left] <- 0L
@@ -362,7 +362,12 @@ set_line_break_before_closing_call <- function(pd, except_token_before) {
362362
pd$lag_newlines[setdiff(npd, exception)] <- 0L
363363
return(pd)
364364
}
365-
pd$lag_newlines[npd] <- 1L
365+
idx_non_comment <- previous_non_comment(pd, npd)
366+
if (pd$token[idx_non_comment] == "']'") {
367+
pd$lag_newlines[idx_non_comment] <- 1L
368+
} else {
369+
pd$lag_newlines[npd] <- 1L
370+
}
366371
pd
367372
}
368373

R/testing.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,11 @@ test_transformers_drop <- function(transformers) {
377377
}
378378
})
379379
}
380+
381+
382+
skip_during_parallel <- function() {
383+
Sys.getenv("STYLER_TEST_IS_TRULY_PARALLEL", TRUE) %>%
384+
toupper() %>%
385+
as.logical() %>%
386+
testthat::skip_if()
387+
}

R/token-define.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,5 @@ op_token <- c(
7070
"EQ_SUB", "ELSE", "IN",
7171
"EQ_FORMALS"
7272
)
73+
74+
subset_token_opening <- c("'['", "LBB")

man/compute_indent_indices.Rd

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

0 commit comments

Comments
 (0)