From ceea5a620b8cbe61d9dc280ce5be0f1470cfda3c Mon Sep 17 00:00:00 2001 From: edugp Date: Sat, 5 Mar 2016 21:33:29 +0100 Subject: [PATCH 1/2] Add all the arguments of tidy_source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add ‘comment’, ‘arrow’ and ‘blank’ arguments and change the default width to 80, R’s default. --- R/reformatAddin.R | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/R/reformatAddin.R b/R/reformatAddin.R index adaadbd..81ce09d 100644 --- a/R/reformatAddin.R +++ b/R/reformatAddin.R @@ -11,8 +11,11 @@ reformatAddin <- function() { hr(), stableColumnLayout( checkboxInput("brace.newline", "Place left braces '{' on a new line?", FALSE), + checkboxInput("comment", "Keep comments?", TRUE), + checkboxInput("arrow", "Replace the assign operator '=' with '<-'?", TRUE), + checkboxInput("blank", "Keep blank lines?", TRUE), numericInput("indent", "Indent size: ", 2), - numericInput("width", "Column width: ", 60) + numericInput("width", "Column width: ", 80) ), uiOutput("document", container = rCodeContainer) ) @@ -29,11 +32,17 @@ reformatAddin <- function() { brace.newline <- input$brace.newline indent <- input$indent width <- input$width - + comment <- input$comment + blank <- input$blank + arrow <- input$arrow + # Build formatted document formatted <- formatR::tidy_source( text = context$contents, output = FALSE, + comment = comment, + blank = blank, + arrow = arrow, width.cutoff = width, indent = indent, brace.newline = brace.newline From 723156a9dff30aa3d1d51fa3e180e611cf68a617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Garc=C3=ADa-Portugu=C3=A9s?= Date: Tue, 8 Mar 2016 11:23:37 +0100 Subject: [PATCH 2/2] Put back default's line width to 60 Put back the 'minimum line width' to 60. I thought that the previous 'column width' was the *maximum* column width instead of the minimum. --- R/reformatAddin.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/reformatAddin.R b/R/reformatAddin.R index 81ce09d..ef23bae 100644 --- a/R/reformatAddin.R +++ b/R/reformatAddin.R @@ -15,7 +15,7 @@ reformatAddin <- function() { checkboxInput("arrow", "Replace the assign operator '=' with '<-'?", TRUE), checkboxInput("blank", "Keep blank lines?", TRUE), numericInput("indent", "Indent size: ", 2), - numericInput("width", "Column width: ", 80) + numericInput("width", "Minimum line width: ", 60) ), uiOutput("document", container = rCodeContainer) )