Dart-code: Add import folding (language aware)

Created on 27 Mar 2020  路  6Comments  路  Source: Dart-Code/Dart-Code

IntelliJ has import folding and it's super nice when working in a file with a lot of imports. It acts like block folding in VSCode but it also works on lists of imports.

Would it be possible for us to get import folding using the VSCode folding provider API?

https://code.visualstudio.com/updates/v1_23#_folding-provider-api

is question

Most helpful comment

Do you get any folding at all? I noticed you need to hover your mouse in the gutter before the folding icons appear.

All 6 comments

This should already work, implemented in #578 (shipped in v2.13 -> https://dartcode.org/releases/v2-13/#improved-folding).

I tested and it seems to work ok for me:

Screenshot 2020-03-28 at 11 10 26

Is it a specific file you don't see it in? Are you on a recent Dart SDK and haven't disabled dart.analysisServerFolding or changed editor.foldingStrategy?

I'm on v3.8.1 and I don't have it in any of my files and never have. This is my global settings file

{
    "workbench.colorTheme": "Atom One Dark",
    "editor.fontFamily": "FiraCode-Retina",
    "editor.fontLigatures": true,
    "editor.fontSize": 14,
    "explorer.confirmDelete": false,
    "git.enableSmartCommit": true,
    "explorer.confirmDragAndDrop": false,
    "dart.debugExternalLibraries": false,
    "dart.debugSdkLibraries": false,
    "[jsonc]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[json]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    }
}

Do you get any folding at all? I noticed you need to hover your mouse in the gutter before the folding icons appear.

Oh my goodness it was actually there. Somehow I missed it even when I was looking for it explicitly. Is there any way to have the import fields collapsed in all files by default?

Yeah, it caught me out too :)

Is there any way to have the import fields collapsed in all files by default?

Not that I know of. I don't think there are even VS Code APIs for extensions to expand/collapse specific ranges like that. It wouldn't be a bad feature for TypeScript either though =)

Screenshot 2020-03-30 at 11 01 44

They go all the way to line 89!

No problem! I'm comfortable keeping this closed. Thanks Dan.

Was this page helpful?
0 / 5 - 0 ratings