Skip to content

Section collapsing issues #643

@kylebutts

Description

@kylebutts

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

languageserver/R/section.R

Lines 319 to 337 in 7f7605b

#' 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:

  1. Add nline_to_break_succession option to S6 option Settings
  2. In section.R, use lsp_settings$get("nline_to_break_succession") here:
    nline_to_break_succession <- 2L

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions