-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
[folding] language-aware folding #3422
Comments
Another issue I don't see in that list is user-configured folding like this example from C#: #region Public methods
...
#endregion In the PowerShell extension we would like to provide this same sort of feature the same syntax as what C# uses which, in PowerShell, looks like a "special" comment. |
PowerShell block comment folding is weird in the Insider build 0.10.10. |
Now I understand. It's the indentation level. Language-aware folding ftw! |
Yeah, I think for VSCode to give the best experience for code-folding they're definitely going to need help from the various language extensions/services. |
Either that or we're going to have to tweak the PowerShell syntax definition to jive with their folding model a little better. May need some pointers from Martin about what we can do to improve folding if the tmLanguage definition is a factor. |
@rkeithhill For the moment there's nothing you can tweek on your side until we allow languages to control code folding. |
As another example, Ant build.xml files can have large text blocks where the content doesn't adhere to indentation of the XML. Such as
|
the same thing happens with PHP heredoc. Also, sections in INI files cannot get folded by indentation |
I'm probably way out of my depth here... User-controlled folding - with "regions" - seems fairly straight-forward to define. The editor needs to only be language aware enough to know how each language shows comments. Then if a comment starts with "region" or "endregion" such as... #region ... #endregion You treat the content in-between as a region. It seems like creating a list of all supported language comment syntaxes is the only thing necessary. |
Definitely need this resolved for PowerShell |
Atom's code folding based on indentation. But the next release (1.25) new parsing system Tree-sitter is added. I tried roughly and it's ok on small files. Update: Seem like VSCode team plan to work on their own https://code.visualstudio.com/updates/v1_21#_folding |
I saw that a new experimental API was introduced in VS Code 1.21. Thank you for looking into this. Are there any plans to give control as to which line is shown after the content is folded? For example, in VS Code, the source files look like this at the top: /*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ Current folding behaviour: /*--------------------------------------------------------------------------------------------- ... Proposed folding behaviour: ... * Copyright (c) Microsoft Corporation. All rights reserved. ... export interface FoldingRange {
/**
* The start line number
*/
startLine: number;
/**
* The end line number
*/
endLine: number;
/**
* The line to show when the region is folded. If this is
* unspecified, then startLine will be shown.
*/
visibleLine?: number;
/**
* The actual color value for this folding range.
*/
type?: FoldingRangeType | string;
} |
Hello, |
@SunOfHomeBoy Please file a separate issue with the VSCode version and the sample code. |
Hello, |
Thanks @pr-yemibedu, correct. |
The cold foldering section of the interactive playground still says that code folding is based on indentation and doesn't mention the new language aware folding. It probably should be reworded. |
Seem like it's could be done as extension now https://code.visualstudio.com/updates/v1_23#_folding-provider-api |
Any news on |
So the API is now available, so language extensions can add language aware folding. I reopened #37494 to continue the discussion. |
The current implementation of folding uses an indentation based folding strategy that is unaware of the language it works on. Knowledge on the underlying language allows us to solve the following requests:
The text was updated successfully, but these errors were encountered: