yihui / formatR

Format R Code Automatically
https://yihui.org/formatr/
256 stars 52 forks source link

Comment blocks are not maintained #85

Closed bersbersbers closed 3 years ago

bersbersbers commented 4 years ago

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

This is bug.R:

#####
# a #
#####

Then I run formatR::tidy_source("bug.R", file = "bug2.R").

And this is the result:

##### a #

Shouldn't the comment block be maintained by default?

> getOption("formatR.comment", TRUE)
[1] TRUE
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041), RStudio 1.3.1056

Locale:
  LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
  LC_NUMERIC=C                           LC_TIME=English_United States.1252    

Package version:
  formatR_1.7
yihui commented 3 years ago

If you don't want comments to be rewrapped, you need to use tidy_source(wrap = FALSE) (or set the global option).

Duplicate of #73.