Skip to content

Collapsible/expandable Functions, Regions, Comment blocks, and Comment based help blocks #1336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Shane091490 opened this issue May 28, 2018 · 17 comments · Fixed by #1355
Closed
Labels
Issue-Enhancement A feature request (enhancement).

Comments

@Shane091490
Copy link

Summary of the new feature

As a user I want to be able to collapse and expand Functions, Regions, Comment blocks, and Comment based help blocks. This helps me goto the section/region of code that I want to work on without having to scroll through thousands of lines of code to find the section I need.

I really like all the features in VS code however without this feature it is a deal breaker for me, I would rather use PS ISE or VS Community as they have this feature and makes my work much easier. I don't like having to scroll thru thousands of lines of code to find the section I need. I designed my tool with regions but I can't use them with VS code,

@rjmholt
Copy link
Contributor

rjmholt commented May 29, 2018

I believe VSCode recently introduced various folding features:

There are a number of similar user asks here:

There is currently some other work prioritised, but it looks like there are a few related pieces of functionality here that we should look into soon.

@TylerLeonhardt
Copy link
Member

I'm going to dupe this to #1276 😄

@TylerLeonhardt
Copy link
Member

Actually this has the most info, so I'll make this the main one.

@TylerLeonhardt TylerLeonhardt added Issue-Enhancement A feature request (enhancement). Area-General labels May 29, 2018
@Shane091490
Copy link
Author

@rjmholt I have looked at the links you posted however those shortcuts don't work with powershell which is my primary language I should have been a little more clear. I'm looking for the equivalent shortcut to "fold" as you call it, all regions in my code like in powershell ISE it's Ctrl-M.

@TylerLeonhardt
Copy link
Member

@Shane091490 You are correct. This is work we need to do to support this Folding Provider. We'll get to this as soon as we can!

@rkeithhill
Copy link
Contributor

rkeithhill commented May 29, 2018

@Shane091490 FYI, you can already fold/unfold all regions in VSCode using Ctrl+K Ctrl+8 and Ctrl+K Ctrl+9.

glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 9, 2018
@glennsarti
Copy link
Contributor

@tylerl0706 I've started a WIP PR for adding this. Will work on it when I can.

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Jun 9, 2018

Exciting!! We really need this 🎉 thank you so much

glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 10, 2018
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 13, 2018
Previously the Powershell extension used the default VSCode indentation based
folding regions.  This commit adds the skeleton for a syntax aware, client-side
folding provider as per the API introduced in VSCode 1.23.0

* The client side detection uses the PowerShell Textmate grammar file and the
  vscode-text node module to parse the text file into tokens which will be
  matched in later commits.

* However due to the way vscode imports the vscode-textmate module we can't
  simply just import it, instead we need to use file based require statements
  microsoft/vscode#46281

* This also means it's difficult to use any typings exposed in that module.  As
  we only need one interface, this is replicated verbatim in the provider class
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 13, 2018
This commit adds detection of text regions bounded by braces { } and brackets
( ).  This provides syntax aware folding for functions, arrays and hash tables.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 13, 2018
This commit adds detection of text regions composed of single and double
quoted here strings;  @' '@ and @" "@.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 13, 2018
This commit adds syntax aware folding for comment regions

* Contiguous blocks of line comments `# ....`

* Function defintion blocks `<# ... #>`

* Region bound comments `# region ...  # endregion`
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 13, 2018
Previously the syntax folding was available for all users.  However as this is
a new feautre which depends on the grammar file which has been unreliable, it
was decided to hide this feature behind a flag.  The commit adds the logic to
only active the syntax folding if the "syntax-folding" feature flag is set in
the "powershell.developer.featureFlags" setting.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 13, 2018
This commit fixes a minor tslint error in a comment line.
@glennsarti
Copy link
Contributor

@tylerl0706 No longer WIP :-)

@mpearon
Copy link

mpearon commented Jun 13, 2018

@glennsarti Just catching up here - but does this mean there is a PowerShell folding provider available now?

@rjmholt
Copy link
Contributor

rjmholt commented Jun 13, 2018

@mpearon The PR is close to being merged: #1355

glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 14, 2018
Previously the Powershell extension used the default VSCode indentation based
folding regions.  This commit adds the skeleton for a syntax aware, client-side
folding provider as per the API introduced in VSCode 1.23.0

* The client side detection uses the PowerShell Textmate grammar file and the
  vscode-text node module to parse the text file into tokens which will be
  matched in later commits.

* However due to the way vscode imports the vscode-textmate module we can't
  simply just import it, instead we need to use file based require statements
  microsoft/vscode#46281

* This also means it's difficult to use any typings exposed in that module.  As
  we only need one interface, this is replicated verbatim in the provider class
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 14, 2018
This commit adds detection of text regions bounded by braces { } and parentheses
( ).  This provides syntax aware folding for functions, arrays and hash tables.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 14, 2018
This commit adds detection of text regions composed of single and double
quoted here strings;  @' '@ and @" "@.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 14, 2018
This commit adds syntax aware folding for comment regions

* Contiguous blocks of line comments `# ....`

* Block comments `<# ... #>`

* Region bound comments `# region ...  # endregion`
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 14, 2018
Previously the syntax folding was available for all users.  However as this is
a new feautre which depends on the grammar file which has been unreliable, it
was decided to hide this feature behind a flag.  The commit adds the logic to
only active the syntax folding if the "syntax-folding" feature flag is set in
the "powershell.developer.featureFlags" setting.
@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Jun 18, 2018

@mpearon. Not yet. You will need to wait for the next release or wait for #1355 to be merged and then grab a CI build from AppVeyor.

Then you'll be able to add the feature flag and have this feature.

@glennsarti
Copy link
Contributor

glennsarti commented Jun 19, 2018

@mpearon If you really really want to try it, you can get an "in-progress" build e.g. https://ci.appveyor.com/project/PowerShell/vscode-powershell-cs82i/build/1.7.0-insiders-148/artifacts

And yes, you'll need to add the appropriate feature flag (syntax-folding) to your workspace settings.

glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 19, 2018
Previously the Powershell extension used the default VSCode indentation based
folding regions.  This commit adds the skeleton for a syntax aware, client-side
folding provider as per the API introduced in VSCode 1.23.0

* The client side detection uses the PowerShell Textmate grammar file and the
  vscode-text node module to parse the text file into tokens which will be
  matched in later commits.

* However due to the way vscode imports the vscode-textmate module we can't
  simply just import it, instead we need to use file based require statements
  microsoft/vscode#46281

* This also means it's difficult to use any typings exposed in that module.  As
  we only need one interface, this is replicated verbatim in the file, but not
  exported

* Logging is added to help diagnose potential issues
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 19, 2018
This commit adds detection of text regions bounded by braces { } and parentheses
( ).  This provides syntax aware folding for functions, arrays and hash tables.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 19, 2018
This commit adds detection of text regions composed of single and double
quoted here strings;  @' '@ and @" "@.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 19, 2018
This commit adds syntax aware folding for comment regions

* Contiguous blocks of line comments `# ....`

* Block comments `<# ... #>`

* Region bound comments `# region ...  # endregion`
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 19, 2018
Previously the syntax folding was available for all users.  However as this is
a new feautre which depends on the grammar file which has been unreliable, it
was decided to hide this feature behind a flag.  The commit adds the logic to
only active the syntax folding if the "syntax-folding" feature flag is set in
the "powershell.developer.featureFlags" setting.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 19, 2018
Previously there were no tests to verify the folding provider.  Due to the
provider depending on 3rd party libraries (vscode-textmate and PowerShell
grammar file) these tests will provide a degree of detection if breaking changes
occur.
@mpearon
Copy link

mpearon commented Jun 19, 2018

@glennsarti Awesome! Grabbing the build now. :)

@mpearon
Copy link

mpearon commented Jun 19, 2018

@glennsarti It's working beautifully! A bit of an oddity, though - possibly expected in its current state.
HereStrings are not breaking parent or adjacent folds, but the HereStrings themselves are not folding.
herestring

@glennsarti
Copy link
Contributor

@mpearon Huh... Odd..

I've added the comments to the PR. Probably best to raise issues for PRs that are yet-to-be-merged in the PR itself.

glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 20, 2018
Previously the Powershell extension used the default VSCode indentation based
folding regions.  This commit adds the skeleton for a syntax aware, client-side
folding provider as per the API introduced in VSCode 1.23.0

* The client side detection uses the PowerShell Textmate grammar file and the
  vscode-text node module to parse the text file into tokens which will be
  matched in later commits.

* However due to the way vscode imports the vscode-textmate module we can't
  simply just import it, instead we need to use file based require statements
  microsoft/vscode#46281

* This also means it's difficult to use any typings exposed in that module.  As
  we only need one interface, this is replicated verbatim in the file, but not
  exported

* Logging is added to help diagnose potential issues
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 20, 2018
This commit adds detection of text regions bounded by braces { } and parentheses
( ).  This provides syntax aware folding for functions, arrays and hash tables.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 20, 2018
This commit adds detection of text regions composed of single and double
quoted here strings;  @' '@ and @" "@.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 20, 2018
This commit adds syntax aware folding for comment regions

* Contiguous blocks of line comments `# ....`

* Block comments `<# ... #>`

* Region bound comments `# region ...  # endregion`
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 20, 2018
Previously the syntax folding was available for all users.  However as this is
a new feautre which depends on the grammar file which has been unreliable, it
was decided to hide this feature behind a flag.  The commit adds the logic to
only active the syntax folding if the "syntax-folding" feature flag is set in
the "powershell.developer.featureFlags" setting.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 20, 2018
Previously there were no tests to verify the folding provider.  Due to the
provider depending on 3rd party libraries (vscode-textmate and PowerShell
grammar file) these tests will provide a degree of detection if breaking changes
occur.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 20, 2018
Previously there were no tests to verify the folding provider.  Due to the
provider depending on 3rd party libraries (vscode-textmate and PowerShell
grammar file) these tests will provide a degree of detection if breaking changes
occur.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 28, 2018
Previously the syntax folding was available for all users.  However it was able
to be configured or turned off.  This commit adds a new `codeFolding` settings
section, with the syntax folding feature enabled by default.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 28, 2018
Previously there were no tests to verify the folding provider.  Due to the
provider depending on 3rd party libraries (vscode-textmate and PowerShell
grammar file) these tests will provide a degree of detection if breaking changes
occur.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 29, 2018
Previously the Powershell extension used the default VSCode indentation based
folding regions.  This commit adds the skeleton for a syntax aware, client-side
folding provider as per the API introduced in VSCode 1.23.0

* The client side detection uses the PowerShell Textmate grammar file and the
  vscode-text node module to parse the text file into tokens which will be
  matched in later commits.

* However due to the way vscode imports the vscode-textmate module we can't
  simply just import it, instead we need to use file based require statements
  microsoft/vscode#46281

* This also means it's difficult to use any typings exposed in that module.  As
  we only need one interface, this is replicated verbatim in the file, but not
  exported

* Logging is added to help diagnose potential issues
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 29, 2018
This commit adds detection of text regions bounded by braces { } and parentheses
( ).  This provides syntax aware folding for functions, arrays and hash tables.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 29, 2018
This commit adds detection of text regions composed of single and double
quoted here strings;  @' '@ and @" "@.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 29, 2018
This commit adds syntax aware folding for comment regions

* Contiguous blocks of line comments `# ....`

* Block comments `<# ... #>`

* Region bound comments `# region ...  # endregion`
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 29, 2018
Previously the syntax folding was available for all users.  However it was able
to be configured or turned off.  This commit adds a new `codeFolding` settings
section, with the syntax folding feature enabled by default.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jun 29, 2018
Previously there were no tests to verify the folding provider.  Due to the
provider depending on 3rd party libraries (vscode-textmate and PowerShell
grammar file) these tests will provide a degree of detection if breaking changes
occur.
TylerLeonhardt pushed a commit that referenced this issue Jul 2, 2018
* (GH-1336) Add syntax aware folding provider

Previously the Powershell extension used the default VSCode indentation based
folding regions.  This commit adds the skeleton for a syntax aware, client-side
folding provider as per the API introduced in VSCode 1.23.0

* The client side detection uses the PowerShell Textmate grammar file and the
  vscode-text node module to parse the text file into tokens which will be
  matched in later commits.

* However due to the way vscode imports the vscode-textmate module we can't
  simply just import it, instead we need to use file based require statements
  microsoft/vscode#46281

* This also means it's difficult to use any typings exposed in that module.  As
  we only need one interface, this is replicated verbatim in the file, but not
  exported

* Logging is added to help diagnose potential issues

* (GH-1336) Add syntax folding for braces and parentheses

This commit adds detection of text regions bounded by braces { } and parentheses
( ).  This provides syntax aware folding for functions, arrays and hash tables.

* (GH-1336) Add syntax folding for here strings

This commit adds detection of text regions composed of single and double
quoted here strings;  @' '@ and @" "@.

* (GH-1336) Add syntax folding for comments

This commit adds syntax aware folding for comment regions

* Contiguous blocks of line comments `# ....`

* Block comments `<# ... #>`

* Region bound comments `# region ...  # endregion`

* (GH-1336) Add integration tests for the Folding Provider

Previously there were no tests to verify the folding provider.  Due to the
provider depending on 3rd party libraries (vscode-textmate and PowerShell
grammar file) these tests will provide a degree of detection if breaking changes
occur.

* (maint) Modify tslint configuration for test files

Previously tslint was raising errors in Travis CI saying that the excluded test
fixtures directory was not included in the project.  This was by design however
it appears to be a known bug palantir/tslint#3793.

This commit removes the exclude for test files from linting and adds a tslint
directive in the default index.ts file.  A tslint directive is used instead of
solving the issue because this is the default testing file for VS Code extesions
and shouldn't really be modified unless absolutely necessary.  In this instance
it was safer for a tslint directive.

* (GH-1336) Add Code Folding settings and enable by default

Previously the syntax folding was available for all users.  However it was able
to be configured or turned off.  This commit adds a new `codeFolding` settings
section, with the syntax folding feature enabled by default.

* add copyright headers
rjmholt pushed a commit that referenced this issue Jul 11, 2018
* (GH-1336) Add syntax aware folding provider

Previously the Powershell extension used the default VSCode indentation based
folding regions.  This commit adds the skeleton for a syntax aware, client-side
folding provider as per the API introduced in VSCode 1.23.0

* The client side detection uses the PowerShell Textmate grammar file and the
  vscode-text node module to parse the text file into tokens which will be
  matched in later commits.

* However due to the way vscode imports the vscode-textmate module we can't
  simply just import it, instead we need to use file based require statements
  microsoft/vscode#46281

* This also means it's difficult to use any typings exposed in that module.  As
  we only need one interface, this is replicated verbatim in the file, but not
  exported

* Logging is added to help diagnose potential issues

* (GH-1336) Add syntax folding for braces and parentheses

This commit adds detection of text regions bounded by braces { } and parentheses
( ).  This provides syntax aware folding for functions, arrays and hash tables.

* (GH-1336) Add syntax folding for here strings

This commit adds detection of text regions composed of single and double
quoted here strings;  @' '@ and @" "@.

* (GH-1336) Add syntax folding for comments

This commit adds syntax aware folding for comment regions

* Contiguous blocks of line comments `# ....`

* Block comments `<# ... #>`

* Region bound comments `# region ...  # endregion`

* (GH-1336) Add integration tests for the Folding Provider

Previously there were no tests to verify the folding provider.  Due to the
provider depending on 3rd party libraries (vscode-textmate and PowerShell
grammar file) these tests will provide a degree of detection if breaking changes
occur.

* (maint) Modify tslint configuration for test files

Previously tslint was raising errors in Travis CI saying that the excluded test
fixtures directory was not included in the project.  This was by design however
it appears to be a known bug palantir/tslint#3793.

This commit removes the exclude for test files from linting and adds a tslint
directive in the default index.ts file.  A tslint directive is used instead of
solving the issue because this is the default testing file for VS Code extesions
and shouldn't really be modified unless absolutely necessary.  In this instance
it was safer for a tslint directive.

* (GH-1336) Add Code Folding settings and enable by default

Previously the syntax folding was available for all users.  However it was able
to be configured or turned off.  This commit adds a new `codeFolding` settings
section, with the syntax folding feature enabled by default.

* add copyright headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants