Skip to content
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

Automatically collapse "import" block in files. #20802

Closed
MartinSGill opened this issue Feb 17, 2017 · 8 comments
Closed

Automatically collapse "import" block in files. #20802

MartinSGill opened this issue Feb 17, 2017 · 8 comments
Assignees
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues
Milestone

Comments

@MartinSGill
Copy link

On larger projects you can end up with 10 or more lines of "import ... ;" statements at the top of a file.

It would be really great if vscode could detect if the there's a huge block of import statements at the top of a file and treat them as a collapsible region, and automatically collapse that region when you open a file.

At it's simplest I would define an "import block" as

  1. The only lines above the first "import" statement are comments or empty lines
  2. Line matches "^import\b"
  3. Line is an empty line
  4. Line is a comment
  5. The end of the block is the first non-empty, non-comment line that does not match "^import\b"

It might also be worth having a minimum size before imports are treated as a block/region. E.g. 3 or more lines.

@aeschli
Copy link
Contributor

aeschli commented Feb 21, 2017

Right now folding is purely indentation based. What you are asking is language aware folding.
That's #3422

@aeschli aeschli closed this as completed Feb 21, 2017
@mjbvz mjbvz assigned mjbvz and unassigned aeschli Mar 2, 2017
@mjbvz mjbvz added typescript Typescript support issues feature-request Request for new features or functionality javascript JavaScript support issues labels Mar 2, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Mar 2, 2017

Reopening to track the TypeScript/JavaScript specific part of this request from #21632

@mjbvz mjbvz reopened this Mar 2, 2017
@testerez
Copy link

I wonder if it could be achieved by an extension...

@mjbvz
Copy link
Collaborator

mjbvz commented Mar 26, 2018

Depends on microsoft/TypeScript#22419

@mjbvz mjbvz added this to the April 2018 milestone Mar 26, 2018
@mjbvz mjbvz modified the milestones: April 2018, May 2018 Apr 3, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented May 7, 2018

e628e8e marks TS imports as foldable (you also need to be using a typescript build from master to actually test this)

@aeschli Is there an existing bug tracking auto collapsing FoldingRangeKind.Imports for all languages?

@aeschli
Copy link
Contributor

aeschli commented May 8, 2018

We have #40338 to think about configuring the initial collapse state.

@mjbvz
Copy link
Collaborator

mjbvz commented May 10, 2018

Thanks @aeschli. Folding of imports is now in vscode with d8e5520

Initial folding state is language independent so I'm assigning this issue over to you now. Let me know if there is any js/ts specific work that needs to be done

@mjbvz mjbvz assigned aeschli and unassigned mjbvz May 10, 2018
@aeschli aeschli modified the milestones: May 2018, Backlog May 29, 2018
@aeschli
Copy link
Contributor

aeschli commented May 29, 2018

duplicate of #40338

@aeschli aeschli closed this as completed May 29, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

4 participants