amuletml / amulet

An ML-like functional programming language
https://amulet.works/
BSD 3-Clause "New" or "Revised" License
324 stars 14 forks source link

Code folding support #271

Closed SquidDev closed 4 years ago

SquidDev commented 4 years ago

Goodness knows @plt-abigail has seen enough screenshots over the last three hours, but for reference this PR adds support for folding ranges such as the following:

image

As they're all on the same indentation level, by default such an expression wouldn't be folded.

This PR also refactors the spans we use for function/match a little, to ensure it's more accurate. We now store two positions:

This does change the span of non-exhaustive patterns a little, but I think this is preferable - it's a little confusing when you're matching on a complex expression.

    Non-exhaustive patterns in expression
    │ 
  7 │   match expr with
-   │   ^^^^^^^^^^^^^^^
+   │   ^^^^^