When multiple selection ranges exist in a document, the fold command folds only the most recently selected range. foldAll ignores the selection and folds all foldable ranges. The fold command should fold all selection ranges, otherwise it's a tedious and janky process to fold multiple ranges.
Here's a reprex. Run the code below in RStudio to create a new document and select two ranges. The command to execute the fold action will be written to the console but will wait for you to run it.
library(rstudioapi)
id <- documentNew(
text = "if (TRUE) {
# code here
# code here
} else {
# code here
# code here
}"
)
setSelectionRanges(
id = id,
ranges = list(
document_range(
document_position(2, 1),
document_position(3, 14)
),
document_range(
document_position(5, 1),
document_position(6, 14)
)
)
)
sendToConsole(
sprintf('executeCommand("fold", "%s")', id),
execute = FALSE
)
When multiple selection ranges exist in a document, the
fold
command folds only the most recently selected range.foldAll
ignores the selection and folds all foldable ranges. Thefold
command should fold all selection ranges, otherwise it's a tedious and janky process to fold multiple ranges.Here's a reprex. Run the code below in RStudio to create a new document and select two ranges. The command to execute the
fold
action will be written to the console but will wait for you to run it.