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

VSCode Import Folding #15218

Closed
TylerYep opened this issue Jan 25, 2021 · 11 comments
Closed

VSCode Import Folding #15218

TylerYep opened this issue Jan 25, 2021 · 11 comments
Labels
area-editor-* User-facing catch-all feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities

Comments

@TylerYep
Copy link

Currently, there is no way to collapse a large page of Python imports because VSCode's default folding is indentation-based.

However, there should be a way to create a custom folding rule so that Python imports at the top of the page can be collapsed.

Ideally, there would also be a setting to automatically collapse imports whenever a python file is opened.

Thanks!

@TylerYep TylerYep added triage-needed Needs assignment to the proper sub-team feature-request Request for new features or functionality labels Jan 25, 2021
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jan 25, 2021
@karthiknadig
Copy link
Member

Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.

@nfx
Copy link

nfx commented Feb 14, 2021

@karthiknadig this is standard behavior for IntelliJ and for VSCode-GoLang.

@nfx
Copy link

nfx commented Feb 17, 2021

@greazer, @joyceerhl, @rchiodo I think this is a good issue to put on editor roadmap.

@melMass
Copy link

melMass commented Aug 12, 2021

Region is quite nice and easy to extend (configuration based)
So you can do:

#region imports <- This is foldable
from functools import lru_cache
#endregion

@HappyCuppy
Copy link

HappyCuppy commented Oct 5, 2021

Region is quite nice and easy to extend (configuration based) So you can do:

#region imports <- This is foldable
from functools import lru_cache
#endregion

I wasn't able to get this to work with Python (works fine for me with JS with the provided config example, though). What's your config for it for Python?

@melMass
Copy link

melMass commented Oct 5, 2021

Region is quite nice and easy to extend (configuration based) So you can do:

#region imports <- This is foldable
from functools import lru_cache
#endregion

I wasn't able to get this to work with Python (works fine for me with JS with the provided config example, though). What's your config for it for Python?

It should be working by default:
https://github.com/maptz/maptz.vscode.extensions.customfolding/blob/de39a96ae09341d31a299120b074bb821ec9a44e/src/config/DefaultConfiguration.ts#L138

@nfx
Copy link

nfx commented Oct 7, 2021

@melMass i don't want to install any third party extensions and modify the code in order to achieve pretty standard functionality - import folding, so that's why i'm raising this as a feature request

@melMass
Copy link

melMass commented Oct 7, 2021

@melMass i don't want to install any third party extensions and modify the code in order to achieve pretty standard functionality - import folding, so that's why i'm raising this as a feature request

I was answering to HappyCuppy.

@luabud
Copy link
Member

luabud commented Jan 28, 2022

Import folding is now working on the latest release of Pylance. The only missing bit is supporting a setting to automatically do it for Python files.

@luabud
Copy link
Member

luabud commented Jan 29, 2022

And I just found out we actually respect "editor.foldingImportsByDefault": true. When you flip it for the first time you may need to wait a bit for the Python and Pylance extensions to activate and do its magic, but it works 😊

@luabud luabud closed this as completed Jan 29, 2022
@TylerYep
Copy link
Author

Thank you!! This is so awesome :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-editor-* User-facing catch-all feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

6 participants