yihui / formatR

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

Unwanted white space inserted in code #88

Closed nylander closed 3 years ago

nylander commented 3 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.

Description

Unwanted white-space characters are inserted while running tidy_file().

Example:

Input:

idMatches <- function(tree1, tree2, least.inclusive=TRUE)
{
  #set the results table up
  results <- tableSetup(tree1, tree2)

  #define tree1 nodes here
  nodes1 <- getNode()
}

Output

Note: Line no. 4 has four white-space characters inserted (should be none).

idMatches <- function(tree1, tree2, least.inclusive = TRUE) {
    # set the results table up
    results <- tableSetup(tree1, tree2)

    # define tree1 nodes here
    nodes1 <- getNode()
}

Session info:

R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Locale:
  LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
  LC_TIME=sv_SE.UTF-8        LC_COLLATE=en_US.UTF-8    
  LC_MONETARY=sv_SE.UTF-8    LC_MESSAGES=en_US.UTF-8   
  LC_PAPER=sv_SE.UTF-8       LC_NAME=C                 
  LC_ADDRESS=C               LC_TELEPHONE=C            
  LC_MEASUREMENT=sv_SE.UTF-8 LC_IDENTIFICATION=C       

Package version:
  formatR_1.7
yihui commented 3 years ago

Should be fixed now. Thanks for the report!