Enable multiple-level fold section of R document like RStudio#566
Enable multiple-level fold section of R document like RStudio#566renkun-ken merged 33 commits intoREditorSupport:masterfrom
Conversation
| } | ||
|
|
||
| # for a r document, we split the document into two element, one for document | ||
| # content out of blocks, another for document content in blocks. |
There was a problem hiding this comment.
blocks ranges are codes between pairs like ("[" and "]"), ("(" and ")"), and ("{" and "}").
| line_seq <- start_line:end_line | ||
| # only keep blocks between start_line and end_line | ||
| block_lines_list <- lapply( | ||
| block_lines_list, "[", |
There was a problem hiding this comment.
block_lines_list is a list with two element, the first element is all block start lines and the second is all block end lines
| line_seq, block_lines_list | ||
| ) | ||
| sections_in_blocks <- NULL | ||
| if (length(block_lines_list) && length(block_lines_list[[1L]])) { |
There was a problem hiding this comment.
if there exists some blocks, we firstly extract the outermost blocks (highest_level_block_lines) and treat the content in these blocks as a new R document, so we can re-use this function to parse them.
|
Thanks for re-submitting the PR. I'll take a look later today. |
|
I re-arranged some functions so that |
|
Thank you for working on it! |
|
@Yunuuuu Some of the test cases failed. Would you like to update the test cases in the following files according to the errors reported at https://github.com/REditorSupport/languageserver/runs/7883213618?check_suite_focus=true: |
| type = "block", | ||
| start_line = start_line, | ||
| end_line = end_line | ||
| end_line = end_line - 1L |
There was a problem hiding this comment.
Exclude lines where close brackets stand
| expect_equal(result[[6]]$startLine, 9) | ||
| expect_equal(result[[6]]$endLine, 10) | ||
| expect_equal(result[[6]]$endLine, 10) # mark | ||
| }) |
There was a problem hiding this comment.
By excluding lines with close brackets, this can be fixed
|
Thanks for the reviewing @renkun-ken, I have run |
|
In addition to updating existing test cases, are you interested in adding some new test cases for the newly introduced features in this PR? |
|
Sorry for the late reply @renkun-ken, I'll improve the test tomorow, it's a little busy these days. |
|
For symbols, the "Document section symbol works" test in test-symbol.R file has provide nested section symbol test |
|
Sorry for the delayed test commits, it's busy for the new school semester, |
renkun-ken
left a comment
There was a problem hiding this comment.
LGTM Thanks for working on this!
Here is some example code to explain this work:
This is what the outline look like: