Feat: Folding Ranges
This PR adds the feature of Folding Ranges to the Range Plugin.
References:
- Folding ranges from haskell/lsp (https://github.com/haskell/lsp/blob/5422dd13f0362917e5981e07d60617ca6e233833/lsp-types/src/Language/LSP/Types/FoldingRange.hs)
- Folding ranges from LSP spec (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_foldingRange)
@kokobd I have started to implement Folding Ranges.
Is there any reference/documentation for Code Range that I can use to understand it better?
cc: @michaelpj
Is there any reference/documentation for Code Range
@sloorush "code range" is just a concept I come up with to unify selection range and folding range. The motivation is to split source code into "ranges". Please just read the code. And by design, you should be able to traverse the CodeRange tree, producing FoldingRanges along the way.
Moreover, feel free to add more fields to CodeRange as you need (if you need to preserve some extra information from HieAST). Maybe you have noticed, I already added CodeRangeKind, which corresponds to FoldingRangeKind
It would be nice to post a screencast here and add some tests to hls-code-range-plugin/test
Yeah, this definitely needs some tests.
It would be nice to post a screencast here and add some tests to
hls-code-range-plugin/test
Here is a screen recording of the feature:

You are free to run stylish-haskell at any time. In fact, if you have followed Style Guidelines carefully, you should have installed a pre-commit hook, which runs stylish-haskell automatically for you.
@kokobd, I have added the integration test but I'm not sure if this is the correct behaviour.
So the test case(plugins/hls-code-range-plugin/test/testdata/folding-range/Function.golden.txt) I have added is what the test is generating assume that it is correct, but logically thinking, I'm unsure as to why it is generating so many folding ranges for such a small function(plugins/hls-code-range-plugin/test/testdata/folding-range/Function.hs) which we can see in the screenshot has only 2 foldings.
PTAL. Is it something that I am doing incorrectly?

why it is generating so many folding ranges for such a small function(
plugins/hls-code-range-plugin/test/testdata/folding-range/Function.hs) which we can see in the screenshot has only 2 foldings.
@sloorush It means that VSCode has some deduplication logic built in. You should implement the deduplication in your code, only preserving the code ranges you want in the folding range handler.
Amm @kokobd, But I am not able to understand the logic of how these ranges are being generated. Like it seems very random, from the start of a line to the middle of a function definition.
Amm @kokobd, But I am not able to understand the logic of how these ranges are being generated. Like it seems very random, from the start of a line to the middle of a function definition.
@sloorush It corresponds to the AST. A single line of code doesn't mean a single node in AST. For example:
((4, 0) : (4, 25)) : isEven :: Integer -> Bool
((4, 0) : (4, 6)) : isEven
((4, 10) : (4, 25)) : Integer -> Bool
((4, 10) : (4, 17)) : Integer
((4, 21) : (4, 25)) : Bool
@sloorush It means that VSCode has some deduplication logic built in. You should implement the deduplication in your code, only preserving the code ranges you want in the folding range handler.
@kokobd, I have fixed it:
- removed all folding ranges in which startline and endline were the same.
- filtered final result to have only the largest folding range that starts from one startline
I'll pull and try it out locally. You may merge origin/master into your branch first, as some changes to hls-code-range-plugin have been made on master.
Okay! Also should I squash my commits? or will it be done while merging
On Mon, 12 Sep 2022 at 11:06, Kobayashi @.***> wrote:
I'll pull and try it out locally. You may merge origin/master into your branch first, as some changes to hls-code-range-plugin have been made on master.
— Reply to this email directly, view it on GitHub https://github.com/haskell/haskell-language-server/pull/3058#issuecomment-1243244087, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM7UPZIF3GMIIQLGDJ6CPKLV526MTANCNFSM54OU2ZFA . You are receiving this because you were mentioned.Message ID: @.***>
Okay! Also should I squash my commits? or will it be done while merging
Mergify will squash and merge for us.
What happened? There are still merge conflicts, and it fails to build. And almost everything is changed...
What happened? There are still merge conflicts, and it fails to build. And almost everything is changed...
![]()
@kokobd, Oops, I messed up the merge, fixed it. Sorry for the request spam.
Also it would probably be good to have some more substantial Haskell examples in the tests!
@michaelpj I always appreciate your unlimited energy on code reviewing! Many thanks!
I'm just sorry I didn't get to it earlier! Badly timed holiday!
Do we have tests for all the weird cases we observed during testing
I'll try to write those as well, They were mostly very random, I will check if there is a pattern.
I'll try to write those as well, They were mostly very random, I will check if there is a pattern.
Even writing down random examples is useful, it gives people something to start with if they want to investigate further.
@michaelpj, All requested changes have been resolved, Please take a look.
cc: @kokobd
It will be better to collapse the export list rather than the whole file when clicking on the folding marker at line 6. See below:

@sloorush I think it's okay to handle this in a subsequent PR if you are eager to merge this one.
It will be better to collapse the export list rather than the whole file when clicking on the folding marker at line 6. See below:
@sloorush I think it's okay to handle this in a subsequent PR if you are eager to merge this one.
We will have to tinker with code ranges and why is this code range so big, Should we make a new issue to tackle this?
We will have to tinker with code ranges and why is this code range so big, Should we make a new issue to tackle this?
I recommend adding a test case in testdata for that, and see if it can be easily solved (for example if you can figure out what AST node it corresponds to, then filter it out somewhere.) If it's not so trivial, open an issue for that, and add a link to the issue in that test case.
Yeah, the best thing if you ever find a weird case is to record it with a test. Helps to remember and make it obvious why it's weird, and have somewhere to start to fix it.
Not really sure why this is happening but it happens when there is an export, I'll check how exports work in the AST and write if I find something on this
In this function:

The folding ranges generated look like this:
((2, 4) : (8, 21))
((2, 4) : (2, 10))
((5, 0) : (8, 21))
((5, 0) : (5, 25))
((5, 0) : (5, 6))
((5, 10) : (5, 25))
((5, 10) : (5, 17))
((5, 21) : (5, 25))
((6, 0) : (8, 21))
((6, 0) : (6, 6))
((6, 7) : (6, 8))
((6, 9) : (8, 21))
((6, 11) : (8, 21))
((6, 14) : (6, 28))
((6, 14) : (6, 23))
((6, 14) : (6, 15))
((6, 16) : (6, 21))
((6, 22) : (6, 23))
((6, 24) : (6, 26))
((6, 27) : (6, 28))
((7, 16) : (7, 20))
((8, 16) : (8, 21))
The first one is causing the issue, This happens when there is an export(even a single line one) like:
function:

folding ranges:
((2, 22) : (7, 21))
((2, 22) : (2, 28))
((4, 0) : (7, 21))
((4, 0) : (4, 25))
((4, 0) : (4, 6))
((4, 10) : (4, 25))
((4, 10) : (4, 17))
((4, 21) : (4, 25))
((5, 0) : (7, 21))
((5, 0) : (5, 6))
((5, 7) : (5, 8))
((5, 9) : (7, 21))
((5, 11) : (7, 21))
((5, 14) : (5, 28))
((5, 14) : (5, 23))
((5, 14) : (5, 15))
((5, 16) : (5, 21))
((5, 22) : (5, 23))
((5, 24) : (5, 26))
((5, 27) : (5, 28))
((6, 16) : (6, 20))
((7, 16) : (7, 21))
So for this file:

The first folding range seen on VSCode collapses everything after this line

The first code range looks like this:
{_codeRange_range = Range {_start = Position {_line = 2, _character = 16}, _end = Position {_line = 7, _character = 21}} ...}
Which has the root node range ((2,16):(7,21)) which is from the start of the export parenthesis to the end of the file(even when there are functions that are not exported, it is folded till the end of the file)
Full Output of CodeRanges of this function:
CodeRange {_codeRange_range = Range {_start = Position {_line = 2, _character = 16}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 2, _character = 16}, _end = Position {_line = 2, _character = 22}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 6}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 17}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 21}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 0}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 0}, _end = Position {_line = 5, _character = 6}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 7}, _end = Position {_line = 5, _character = 8}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 9}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 11}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 15}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 16}, _end = Position {_line = 5, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 22}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 24}, _end = Position {_line = 5, _character = 26}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 27}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 6, _character = 16}, _end = Position {_line = 6, _character = 20}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 7, _character = 16}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 2, _character = 16}, _end = Position {_line = 2, _character = 22}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 6}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 17}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 21}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 0}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 0}, _end = Position {_line = 5, _character = 6}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 7}, _end = Position {_line = 5, _character = 8}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 9}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 11}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 15}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 16}, _end = Position {_line = 5, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 22}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 24}, _end = Position {_line = 5, _character = 26}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 27}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 6, _character = 16}, _end = Position {_line = 6, _character = 20}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 7, _character = 16}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 6}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 17}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 21}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 0}, _end = Position {_line = 4, _character = 6}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 17}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 21}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 10}, _end = Position {_line = 4, _character = 17}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 4, _character = 21}, _end = Position {_line = 4, _character = 25}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 0}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 0}, _end = Position {_line = 5, _character = 6}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 7}, _end = Position {_line = 5, _character = 8}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 9}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 11}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 15}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 16}, _end = Position {_line = 5, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 22}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 24}, _end = Position {_line = 5, _character = 26}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 27}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 6, _character = 16}, _end = Position {_line = 6, _character = 20}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 7, _character = 16}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 0}, _end = Position {_line = 5, _character = 6}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 7}, _end = Position {_line = 5, _character = 8}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 9}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 11}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 15}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 16}, _end = Position {_line = 5, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 22}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 24}, _end = Position {_line = 5, _character = 26}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 27}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 6, _character = 16}, _end = Position {_line = 6, _character = 20}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 7, _character = 16}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 11}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 15}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 16}, _end = Position {_line = 5, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 22}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 24}, _end = Position {_line = 5, _character = 26}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 27}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 6, _character = 16}, _end = Position {_line = 6, _character = 20}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 7, _character = 16}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 15}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 16}, _end = Position {_line = 5, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 22}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 24}, _end = Position {_line = 5, _character = 26}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 27}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 15}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 16}, _end = Position {_line = 5, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion},CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 22}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 14}, _end = Position {_line = 5, _character = 15}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 16}, _end = Position {_line = 5, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 22}, _end = Position {_line = 5, _character = 23}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 24}, _end = Position {_line = 5, _character = 26}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 5, _character = 27}, _end = Position {_line = 5, _character = 28}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 6, _character = 16}, _end = Position {_line = 6, _character = 20}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
CodeRange {_codeRange_range = Range {_start = Position {_line = 7, _character = 16}, _end = Position {_line = 7, _character = 21}}, _codeRange_children = [], _codeRange_kind = CodeKindRegion}
I believe this is an issue dealing with CodeRange conversion from the AST.
@michaelpj @kokobd
I believe this is an issue dealing with CodeRange conversion from the AST.
@sloorush So you can just skip the root node when constructing folding ranges? I believe no one wants to fold the whole file. I wonder why it starts from line 2 instead of line 0, but that's another problem.