microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.58k stars 29.03k forks source link

Code Folding issue #178211

Closed df99Github closed 1 year ago

df99Github commented 1 year ago

Type: Bug

The Code folding is not user friendly. If I collapse a method (java/apex), its collapsed till the next comment or else statement if there's an if condition in the method. Collapse should work based on the { } pair.

VS Code version: Code 1.76.2 (ee2b180d582a7f601fa6ecfdad8d9fd269ab1884, 2023-03-14T17:55:54.936Z) OS version: Windows_NT x64 10.0.19044 Modes: Sandboxed: No

Extensions (31) Extension|Author (truncated)|Version ---|---|--- salesforce-soql-editor|all|1.8.0 apex-pmd|chu|0.5.9 vscode-eslint|dba|2.4.0 xml|Dot|2.5.1 gitlens|eam|13.4.0 prettier-vscode|esb|9.10.4 lana|Fin|1.5.2 beautify|Hoo|1.5.0 compareit|in4|0.0.2 forcecode|Joh|4.0.5 remote-wsl|ms-|0.76.1 fix-json|oli|0.1.2 excalidraw-editor|pom|3.4.1 vscode-xml|red|0.24.0 LiveServer|rit|5.7.9 partial-diff|ryu|1.4.3 salesforce-vscode-slds|sal|1.4.8 salesforcedx-vscode|sal|57.6.0 salesforcedx-vscode-apex|sal|57.6.0 salesforcedx-vscode-apex-debugger|sal|57.6.0 salesforcedx-vscode-apex-replay-debugger|sal|57.6.0 salesforcedx-vscode-core|sal|57.6.0 salesforcedx-vscode-expanded|sal|57.6.0 salesforcedx-vscode-lightning|sal|57.6.0 salesforcedx-vscode-lwc|sal|57.6.0 salesforcedx-vscode-soql|sal|57.6.0 salesforcedx-vscode-visualforce|sal|57.6.0 intellicode-api-usage-examples|Vis|0.2.7 vscodeintellicode|Vis|1.2.30 gitblame|wad|10.1.0 material-theme|zhu|3.15.8
aeschli commented 1 year ago

Can you please provide a small sample code that shows the problem?

df99Github commented 1 year ago

Sure @aeschli , here you go:

global void finish(Database.BatchableContext BC)
{
    if(l_abortFlag)
    {
        return;
    }
    String emailSubject = 'Foo bar';
    String emailBody = 'Hello there, how are you?';
    List<KnowledgeArticleVersion> lstdraftArts = [SELECT URLName, Language
        FROM KnowledgeArticleVersion WHERE PublishStatus='Draft' 
        AND Id IN :setTranslatedArticleIds];
// Something which don't follow the indendation 
    if(!lstdraftArts.isEmpty()){
        //do something
    }
}

If I try to fold the method, if will fold the code till the comment, not the rest of the method.

aeschli commented 1 year ago

For most languages VS Code supports indentation based folding ranges.

To get folding ranges based on the language syntax, this needs to come from a language extension.

E.g. The for Java, the Java extension https://marketplace.visualstudio.com/items?itemName=redhat.java

I'm not familiar with Apex. I recommend filing an issue against the Apex extension you use to provide a folding range provider.