microsoft / vscode

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

Code folding not working properly when code indentation is not as expected. #108718

Closed umairkhan-dev closed 4 years ago

umairkhan-dev commented 4 years ago

Issue Type: Bug

Consider the following code.

<?php
$a = 10;
if (true)
    switch ($a) {
        case 10:
            echo '$a is 5';
            break;

        case 15:
            echo '
<h1>Code folding of SWITCH and current CASE not working. May be due to indentation.</h1>
';

        case 20:
            echo <<<HERE
<h1>Code folding of SWITCH and current CASE not working. May be due to indentation.</h1>
HERE;
            break;

        default:
            # code...
            break;
    } else {
    # code...
}

Try folding switch, case 15: or case 20:. Also see bmewburn/vscode-intelephense#1454

VSCode Code Folding

VS Code version: Code 1.50.1 (d2e414d9e4239a252d1ab117bd7067f125afd80a, 2020-10-13T15:06:15.712Z) OS version: Windows_NT x64 10.0.19041

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (4 x 3193)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.91GB (3.96GB free)| |Process Argv|--crash-reporter-id a1ca6bf5-7e7a-4d10-9ace-479aaf22cc58| |Screen Reader|no| |VM|0%|
Extensions (32) Extension|Author (truncated)|Version ---|---|--- vscode-intelephense-client|bme|1.5.4 path-intellisense|chr|2.3.0 bracket-pair-colorizer-2|Coe|0.2.0 vscode-mysql-client2|cwe|2.5.9 whitespace-plus|dav|0.0.5 gitlens|eam|10.2.2 vscode-html-css|ecm|0.2.3 prettier-vscode|esb|5.7.1 php-debug|fel|1.13.0 auto-complete-tag|for|0.1.0 shell-format|fox|7.0.1 vscode-pull-request-github|Git|0.20.1 gc-excelviewer|Gra|3.0.40 minify|Hoo|0.4.3 code-eol|jef|1.0.11 intellij-idea-keybindings|k--|0.2.41 sftp|lix|1.12.9 git-graph|mhu|1.26.0 dotenv|mik|1.0.1 vscode-apache|mrm|1.2.0 php-docblocker|nei|2.1.0 gremlins|nho|0.24.0 es6-css-minify|olb|3.3.2 phpstorm-snippets|phi|1.1.1 vscode-php-getters-setters|php|1.2.3 git-file-history|pom|1.0.1 vscode-css-peek|pra|4.0.0 phpdoc-comment-vscode-plugin|rex|1.3.0 code-spell-checker|str|1.9.2 vscode-icons|vsc|11.0.0 vscode-todo-highlight|way|1.0.4 JavaScriptSnippets|xab|1.8.0
vscodebot[bot] commented 4 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

umairkhan-dev commented 4 years ago

Thanks Bot. But it seems that its not duplicate.

aeschli commented 4 years ago

For most languages the folding strategy is based purely on the indentation of lines. A folding region starts when a line has a smaller indent than one or more following lines, and ends when there is a line with the same or smaller indent.

However, language extensions can provide language aware folding providers. Please check out PHP extensions. From a quick glance in the marketplace it seem PHP intelephense offers that in the premium edition.