WolframResearch / vscode-wolfram

Official Visual Studio Code extension for Wolfram Language
MIT License
112 stars 7 forks source link

Section folding #12

Closed hifismith closed 2 years ago

hifismith commented 2 years ago

Can sections and subsections be recognized and folded? In the screenshot I've used cmnd+K+0 to fold everything, but the sections and subsections are expanded.

image
bostick commented 2 years ago

Sure, I will add this in the next few days.

bostick commented 2 years ago

I've added foldingRange support in the latest push of this repo: https://github.com/WolframResearch/LSPServer.

You can test this by building the paclet from source, Otherwise, I will be making an update in the next few weeks, and your paclet will update automatically.

hifismith commented 2 years ago

Nice! Thanks. I'll have to try it when the update comes out.

hifismith commented 1 year ago

@bostick , it appears something has changed in the LSPServer. Section folding has a bug now. It's Christmas Eve so please don't work on this until you're back in the office.

This code shows the "Import" section declaration and then a function, which I've folded, followed by the initialization of variable 'sheets'

image

This "Import" section goes until line 470, but when I fold it, you'll see it only folds that first function.

image

A couple things stand out.

  1. Folding functions is a new feature I believe. It seems to be interfering with the section folding.
  2. The function folding is a nice feature that would be awesome to add to other large expression constructs like With, Block, Module, etc. For example, the next bit of code is a function encapsulated within a "With" expression. I am unable to fold it because of the encapsulation. It'd be nice to be able to fold the With statement: image