Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix style_selection when styler.save_after_styling is not set #726

Merged
merged 2 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
the R option `styler.save_after_styling` to control if a file is saved after
styling with the RStudio Addin. Note than in RStudio >= 1.3.0, you can
auto-save edits in general (Code -> Saving -> Auto-Save), e.g. on idle editor
or focus loss, so this feature becomes less relevant. (#631).
or focus loss, so this feature becomes less relevant (#631, #726).
- blank lines in function calls and headers are now removed, for the former only
when there are no comments before or after the blank line (#629, #630, #635,
#723).
Expand Down
2 changes: 1 addition & 1 deletion R/addins.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ style_selection <- function() {
context$selection[[1]]$range, paste0(c(out, if (context$selection[[1]]$range$end[2] == 1) ""), collapse = "\n"),
id = context$id
)
if (getOption("styler.save_after_styling") == TRUE && context$path != "") {
if (save_after_styling_is_active() == TRUE && context$path != "") {
invisible(rstudioapi::documentSave(context$id))
}
}
Expand Down