glint
glint copied to clipboard
Add JS/TS code folding support to language server
Part of https://github.com/typed-ember/glint/issues/626
This adds support for code folding in js & ts files. This implementation is based on tsserver's. This does not add support for gts/gjs files.
Folding seems to work as expected, but two odd things had to be handled:
- The OutliningSpans have TextSpans with inclusive length, leading to off-by-one errors. I handled this inline, but I'm concerned that this is unintentional and may not always be the case.
- There are some additional OutliningSpans that incorrectly have a "0" starting offset and don't match any foldable code. I believe these are retrieved from the template file and are meant to represent their folding ranges. As is, these are superfluous and cause an incorrect FoldingRange on line 1 of every component file.
Any guidance on better ways to handle either of these would be appreciated!
https://github.com/camerondubas/glint/assets/6216460/b132d090-5ebb-46bb-bd65-1dd1113d9465
Thank you @camerondubas!
I just wanted to say this hasn't been forgotten about; you've asked some good questions about the implementation that I'm expecting will take a little time to investigate, and I haven't had a lot of uninterrupted time this week. I'm aiming to give a more thorough look early next week, but please ping me if you don't hear anything—I want to make sure this doesn't sit idle too long!
@dfreeman I updated this with the latest main. Friendly bump to take a look at this when you have some time. No rush though, life's busy! Cheers
Here is template part if needed: https://github.com/lifeart/ember-language-server/blob/component-context-info-origin/src/folding-provider/template-folding-provider.ts, quite easy to implement.
@camerondubas any chance you want to rebase? <3
looks like a floating dep dropped node 16, breaking our ci.
I'd consider this non-blocking for merge, myself, and fixing the floating dep issue can happen in a different PR