Skip to content

Commit b96d188

Browse files
Merge pull request #882 from lorenzwalthert/issue-881
- Fix alignment detection for quoted keys
2 parents e4866e5 + 4833340 commit b96d188

File tree

5 files changed

+79
-13
lines changed

5 files changed

+79
-13
lines changed

NEWS.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
# styler 1.6.2.9000 (Development version)
22

3-
* Piped function without brackets `substitute(x %>% y)` don't get `()` added
4-
anymore, as this can change outcome of the code (#876).
5-
* Alignment detection respects stylerignore (#850).
6-
* Add vignette on distributing style guide (#846, #861).
7-
* Enable pre-commit.ci (#843).
3+
**API changes**
4+
85
* new R option `styler.cache_root` (defaulting to `"styler"`) that determines
96
the sub-directory under the {R.cache} cache directory that {styler} uses. Non-
107
default caches won't be cleaned up by {styler}. We suggest `"styler-perm"`
118
(also used by {precommit}).
12-
* rename default branch to main (#859).
13-
* Fix argument name `filetype` in Example for `style_dir()` (#855).
14-
* ensure a trailing blank line also if the input is cached (#867).
15-
* Bump minimal R requirement to 3.4 in line with the [tidyverse](https://www.tidyverse.org/blog/2019/04/r-version-support/), which
16-
allowed to remove the dependency at {backports} and some exception handling.
17-
* Remove dependency on {xfun} (#866).
18-
* use pre-commit via GitHub Actions (#872).
199

2010
* stylerignore markers are now interpreted as regular expressions instead of
2111
comments that must match exactly. This allows to specify multiple markers in
@@ -35,6 +25,28 @@
3525
* the built package size has been reduced by ~50% by listing `*-in_tree` files
3626
in `.Rbuildignore` (#879).
3727

28+
* Bump minimal R requirement to 3.4 in line with the [tidyverse](https://www.tidyverse.org/blog/2019/04/r-version-support/), which
29+
allowed to remove the dependency at {backports} and some exception handling.
30+
31+
**Other changes**
32+
33+
* Piped function without brackets `substitute(x %>% y)` don't get `()` added
34+
anymore, as this can change outcome of the code (#876).
35+
* Alignment detection respects stylerignore (#850).
36+
* Unaligned expressions with quoted key (e.g. `c("x" = 2)`) are now correctly
37+
detected (#881).
38+
* Add vignette on distributing style guide (#846, #861).
39+
* ensure a trailing blank line also if the input is cached (#867).
40+
* Fix argument name `filetype` in Example for `style_dir()` (#855).
41+
42+
**Infrastructure**
43+
44+
* Remove dependency on {xfun} (#866).
45+
* rename default branch to main (#859).
46+
* Enable pre-commit.ci (#843).
47+
* use pre-commit via GitHub Actions (#872).
48+
49+
3850
# styler 1.6.2
3951

4052
* clean up cache files older than one week (#842).

R/detect-alignment-utils.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ alignment_col1_all_named <- function(relevant_pd_by_line) {
8080
if (nrow(x) < 3) {
8181
return(FALSE)
8282
}
83-
identical(x$token[c(1, 3)], c("SYMBOL_SUB", "expr")) &&
83+
x$token[3] == "expr" &&
84+
x$token[1] %in% c("SYMBOL_SUB", "STR_CONST") &&
8485
x$token[2] %in% c(
8586
"EQ_SUB", "SPECIAL-IN", "LT", "GT", "EQ", "NE"
8687
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
df <- dplyr::rename(df,
2+
"xValues" = "Time",
3+
"xUnit" = "TimeUnit",
4+
"yValues" = "simulationValues",
5+
"yUnit" = "unit",
6+
"yDimension" = "dimension"
7+
)

tests/testthat/alignment/quoted-names-in_tree

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
df <- dplyr::rename(df,
2+
"xValues" = "Time",
3+
"xUnit" = "TimeUnit",
4+
"yValues" = "simulationValues",
5+
"yUnit" = "unit",
6+
"yDimension" = "dimension"
7+
)

0 commit comments

Comments
 (0)