The language server has preferences over the way sections collapse (namely, collapse up to a set of 2 blank lines:
|
nline_to_break_succession <- 2L |
and
|
#' two or more blank lines out of block ranges should break sections succession |
|
#' @noRd |
|
extract_document_section_breaks <- function(line_numbers, line_content) { |
|
blank_lines <- line_numbers[ |
|
grepl("^\\s*$", line_content, perl = TRUE) |
|
] |
|
if (!length(blank_lines)) { |
|
return(NULL) |
|
} |
|
# make continuous blank lines as groups |
|
groups <- split(blank_lines, factor(cumsum(diff(c(0L, blank_lines)) > 1L))) |
|
# how many lines should break off section succession ? ( 2L ) |
|
groups <- groups[lengths(groups) >= nline_to_break_succession] |
|
if (length(groups)) { |
|
vapply(groups, min, integer(1L)) |
|
} else { |
|
NULL |
|
} |
|
} |
I'm wondering if changing this could be part of the available settings? I personally, like extra whitespace, so it would be nice to configure. I would be happy to open a PR. I think the steps would be:
- Add
nline_to_break_succession option to S6 option Settings
- In section.R, use
lsp_settings$get("nline_to_break_succession") here:
|
nline_to_break_succession <- 2L |
The language server has preferences over the way sections collapse (namely, collapse up to a set of 2 blank lines:
languageserver/R/section.R
Line 19 in 7f7605b
languageserver/R/section.R
Lines 319 to 337 in 7f7605b
I'm wondering if changing this could be part of the available settings? I personally, like extra whitespace, so it would be nice to configure. I would be happy to open a PR. I think the steps would be:
nline_to_break_successionoption toS6optionSettingslsp_settings$get("nline_to_break_succession")here:languageserver/R/section.R
Line 19 in 7f7605b