@@ -68,7 +68,7 @@ style_active_file <- function() {
6868 } else if (is_r_file ) {
6969 out <- try_transform_as_r_file(context , transformer )
7070 } else {
71- abort(" Can only style .R, .Rmd and .Rnw files." )
71+ abort(" Can only style .qmd, . R, .Rmd, and .Rnw files." )
7272 }
7373 rstudioapi :: modifyRange(
7474 c(1L , 1L , length(context $ contents ) + 1L , 1L ),
@@ -97,11 +97,12 @@ save_after_styling_is_active <- function() {
9797 op_old <- as.logical(toupper(Sys.getenv(" save_after_styling" )))
9898 op_new <- getOption(" styler.save_after_styling" , default = " " )
9999 if (! is.na(op_old )) {
100- rlang :: warn(paste(
101- " Using the environment variable save_after_styling is depreciated and" ,
102- " won't work in a future version of styler. Please use the R option" ,
103- " `styler.save_after_styling` to control the behavior. If both are set," ,
104- " the R option is taken."
100+ cli :: cli_warn(c(
101+ " Using the environment variable {.envvar save_after_styling} is \\
102+ deprecated and won't work in a future version of styler. " ,
103+ " !" = " Please use `options(styler.save_after_styling)` \\
104+ to control the behavior." ,
105+ i = " If both are set, the R option is used."
105106 ))
106107 }
107108
@@ -123,7 +124,7 @@ style_selection <- function() {
123124 communicate_addins_style_transformers()
124125 context <- get_rstudio_context()
125126 text <- context $ selection [[1L ]]$ text
126- if (all(nchar (text ) == 0L )) abort(" No code selected" )
127+ if (! any(nzchar (text ))) abort(" No code selected" )
127128 out <- style_text(
128129 text ,
129130 transformers = get_addins_style_transformer(),
@@ -212,9 +213,9 @@ try_transform_as_r_file <- function(context, transformer) {
212213 transformer(context $ contents ),
213214 error = function (e ) {
214215 preamble_for_unsaved <- paste(
215- " Styling of unsaved files is only supported for R files with valid " ,
216- " code. Please save the file (as .R or .Rmd) and make sure that the R " ,
217- " code in it can be parsed. Then, try to style again."
216+ " Styling of unsaved files is only supported for R files with valid" ,
217+ " code. Please save the file (as .qmd, .R, or .Rmd) and make sure that" ,
218+ " the R code in it can be parsed. Then, try to style again."
218219 )
219220
220221 if (context $ path == " " ) {
0 commit comments