Skip to content

Commit

Permalink
preserve the := operator
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Dec 22, 2022
1 parent 2c184a1 commit 6148578
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: formatR
Type: Package
Title: Format R Code Automatically
Version: 1.13
Version: 1.13.1
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Ed", "Lee", role = "ctb"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# CHANGES IN formatR VERSION 1.14

- `tidy_source()` supports the `:=` operator now (which is widely used in **data.table**).

# CHANGES IN formatR VERSION 1.13

- `tidy_source()` supports anonymous functions of the form `\(args) expr` for R >= 4.1.0 now (thanks, @notPlancha, #98).
Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ mask_comments = function(x, comment, blank.line, wrap, arrow, pipe, args.newline
d.text[d.text == '|>'] = paste0('%', '\b|>', spaces, '%')
# preserve the assignment operator ->
d.text[d.text == '->'] = '%\b->%'
# preserve := for data.table
d.text[d.text == ':='] = '%\b:=%'
# R 4.1.0 anonymous functions
if (length(i <- which(d.token == "'\\\\'"))) {
d.text[i] = '`\\\\`'
Expand Down

0 comments on commit 6148578

Please sign in to comment.