lit-analyzer icon indicating copy to clipboard operation
lit-analyzer copied to clipboard

Add support to code collapse

Open abdonrd opened this issue 5 years ago • 12 comments

Add support to code collapse:

feb-26-2019 17-34-51

abdonrd avatar Feb 26 '19 16:02 abdonrd

Update on this: I build support for this feature but ended up disabling it last minute because it was sometimes interfering with the Typescript Language Server. Specifically, I would get old versions of source files after I called "program.getSourceFile(fileName)" from the "getOutliningSpans" callback, so it seemed like a bug in Typescript. However I didn't get time to investigate it further. Soon I plan on trying to enable it again to see if it has somehow been fixed with a newer version of Typescript.

runem avatar Aug 08 '19 12:08 runem

Any news? Thanks in advance, @runem!

abdonrd avatar Aug 30 '19 11:08 abdonrd

Any news? Thanks @runem!

aguillenb avatar Sep 19 '19 09:09 aguillenb

I tried to enable code collapse again, but now it seems like the getOutliningSpans callback is never being called by vscode. I also tried with the lit-html vscode extension, and it seems like folding is not working there as well.

I made sure to double check all my settings, but I have enabled code folding everywhere, and code-folding also works for other JS/TS code. All extensions, except lit-plugin, were disabled.

In that process I also discovered that setting "editor.foldingStrategy": "indentation" will actually enable code folding for lit-html templates given that the HTML is correct indented.

Of course, it could also be a breaking change for TS language service that I'm not aware of, but I couldn't find any related issues/changelogs.

As mentioned, it could be my local vscode configuration, so it would be really helpful to me if you are able to test the feature locally yourselves. You can find the the .vsix extension file with code collapse enabled here: https://github.com/runem/lit-analyzer/suites/233972939/artifacts/46998 :-)

runem avatar Sep 22 '19 12:09 runem

I tried to enable code collapse again, but now it seems like the getOutliningSpans callback is never being called by vscode. I also tried with the lit-html vscode extension, and it seems like folding is not working there as well.

I made sure to double check all my settings, but I have enabled code folding everywhere, and code-folding also works for other JS/TS code. All extensions, except lit-plugin, were disabled.

In that process I also discovered that setting "editor.foldingStrategy": "indentation" will actually enable code folding for lit-html templates given that the HTML is correct indented.

Of course, it could also be a breaking change for TS language service that I'm not aware of, but I couldn't find any related issues/changelogs.

As mentioned, it could be my local vscode configuration, so it would be really helpful to me if you are able to test the feature locally yourselves. You can find the the .vsix extension file with code collapse enabled here: https://github.com/runem/lit-analyzer/suites/233972939/artifacts/46998 :-)

Hy @runem , seems like "editor.foldingStrategy": "indentation" solves the problem. Thanks a lot!

aguillenb avatar Sep 25 '19 09:09 aguillenb

Hi looking to testing but tying https://github.com/runem/lit-analyzer/suites/233972939/artifacts/46998 i get "Failed to generate URL to download artifact."

blikblum avatar Sep 17 '20 19:09 blikblum

@runem Awesome! "editor.foldingStrategy": "indentation" works for me as well 🎉

tvvignesh avatar Sep 19 '20 10:09 tvvignesh

Just for information, in my opinion "editor.foldingStrategy": "indentation" is not ideal solution since can affect other code like plain html or js that is not properly indented

blikblum avatar Sep 19 '20 10:09 blikblum

FWIW the lit-html plugin definitely supports folding html at this point. It's one of the few features that's preventing me from completely switching over to only using lit-plugin for our LitElement project

jjspace avatar Jun 15 '21 15:06 jjspace

FWIW the lit-html plugin definitely supports folding html at this point. It's one of the few features that's preventing me from completely switching over to only using lit-plugin for our LitElement project

Unfortunately is not true anymore with recent vscode.

I upgraded to to 1.79 and code folding stopped work even with lit-html installed. I downgraded to 1.76 and code folding works with lit-html and lit-plugin extensions installed alongside

(1.78 also did not work, i did not tested 1.77)

As a side note, intelisense completion performance is a lot worse with recent vscode. Not sure if related

blikblum avatar Jun 10 '23 21:06 blikblum

@blikblum The recent issues with lit-plugin are related to vscode 1.77 bumping to TS 5.0 which lit-analyzer is not compatible with. See https://github.com/runem/lit-analyzer/issues/302 and #299

jjspace avatar Jun 12 '23 15:06 jjspace

Code folding is not yet supported, but I've found a workaround. By accessing the command palette and typing Fold, you'll see multiple folding level options. One of these is create Folding Range From Selection, which has the shortcut Ctrl + k Ctrl + , on my machine.

ouweiya avatar Aug 12 '23 15:08 ouweiya