Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Folding Ranges #3058

Merged
merged 34 commits into from
Sep 21, 2022
Merged

Feat: Folding Ranges #3058

merged 34 commits into from
Sep 21, 2022

Conversation

sloorush
Copy link
Contributor

@sloorush sloorush commented Jul 23, 2022

@sloorush
Copy link
Contributor Author

@kokobd I have started to implement Folding Ranges.

Is there any reference/documentation for Code Range that I can use to understand it better?

@sloorush
Copy link
Contributor Author

cc: @michaelpj

@kokobd
Copy link
Collaborator

kokobd commented Jul 24, 2022

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

@kokobd
Copy link
Collaborator

kokobd commented Aug 10, 2022

It would be nice to post a screencast here and add some tests to hls-code-range-plugin/test

@michaelpj
Copy link
Collaborator

Yeah, this definitely needs some tests.

@sloorush sloorush marked this pull request as ready for review August 12, 2022 10:45
@sloorush sloorush requested a review from kokobd August 12, 2022 10:45
@sloorush sloorush force-pushed the folding-ranges branch 2 times, most recently from abbc76c to ca807f0 Compare August 12, 2022 11:54
@sloorush
Copy link
Contributor Author

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.

@michaelpj
Copy link
Collaborator

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.

@sloorush
Copy link
Contributor Author

@michaelpj, All requested changes have been resolved, Please take a look.

cc: @kokobd

@kokobd
Copy link
Collaborator

kokobd commented Sep 19, 2022

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:
image

@sloorush I think it's okay to handle this in a subsequent PR if you are eager to merge this one.

@sloorush
Copy link
Contributor Author

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: image

@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?

@kokobd
Copy link
Collaborator

kokobd commented Sep 19, 2022

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.

@michaelpj
Copy link
Collaborator

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.

@sloorush
Copy link
Contributor Author

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:
image

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:
image

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))

@sloorush
Copy link
Contributor Author

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

@kokobd
Copy link
Collaborator

kokobd commented Sep 21, 2022

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.

@sloorush
Copy link
Contributor Author

I wonder why it starts from line 2 instead of line 0

For a file where there are no exports, The first folding range of the first function just folds the entire file.

So you can just skip the root node when constructing folding ranges

I'll do this

@sloorush
Copy link
Contributor Author

All set! Should be good to go now finally!

@kokobd kokobd added the merge me Label to trigger pull request merge label Sep 21, 2022
@kokobd
Copy link
Collaborator

kokobd commented Sep 21, 2022

Added "merge me" label. It will be squashed and merged automatically when CI passes.

@michaelpj michaelpj merged commit 42bcf92 into haskell:master Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants