glint icon indicating copy to clipboard operation
glint copied to clipboard

Add JS/TS code folding support to language server

Open camerondubas opened this issue 1 year ago • 5 comments

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

camerondubas avatar Oct 14 '23 22:10 camerondubas

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 avatar Oct 19 '23 12:10 dfreeman

@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

camerondubas avatar Nov 16 '23 11:11 camerondubas

@camerondubas any chance you want to rebase? <3

NullVoxPopuli avatar Apr 19 '24 20:04 NullVoxPopuli

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

NullVoxPopuli avatar Apr 20 '24 15:04 NullVoxPopuli