Implement an indentation provider to support folding of docstrings, comments & multi line strings
See original GitHub issueWe might want to consider disabling the folding provider in this release due to a number of issues in VS Code:
- https://github.com/Microsoft/vscode/issues/50992
- https://github.com/Microsoft/vscode/issues/50991
- https://github.com/Microsoft/vscode/issues/50990
Came across this today and found it very annoying. Was unable to collapse a large python file, initially assumed it was an intermittent VSC issue, later looked into this and found that its worse than I suspected.
Basically us introducing a custom folding provider breaks the VSC default folding behavior we won't be able to collapse, any block of Python code
@brettcannon cc
Issue Analytics
- State:
- Created 5 years ago
- Reactions:84
- Comments:22 (5 by maintainers)
Top Results From Across the Web
Proper indentation for multiline strings? - python
Docstrings are treated specially: any indent of the first line is removed; the smallest common indent taken over all other non-blank lines is...
Read more >Proper Indentation for Python Multiline Strings - Finxter
Let's use an example of a long string and see the different methods we have for both creating a multiline string and properly...
Read more >black · PyPI
Single-character closing docstring quotes are no longer moved to their own line as this is invalid. This was a bug introduced in version...
Read more >VIM and Python – A Match Made in Heaven
Now you can easily hide portions of your code that you're not currently working on. The initial command, set foldmethod=indent , creates folds...
Read more >PEP 8 – Style Guide for Python Code
Use 4 spaces per indentation level. Continuation lines should align wrapped elements either vertically using Python's implicit line joining ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there any update or alternative solution for this issue?
I’ve been looking for this as well, and until there’s a better solution, we can use
# region
and# endregion
around the docstring to explicitly inform VS Code that it should be a foldable region. From my testings, it worked pretty well, the docstring was still identified correctly, and all other foldable regions remained intact.Another option is to use an extension such as https://github.com/zokugun/vscode-explicit-folding that allows us to manually define what should be used to delimit foldable regions, for example with a regex. A problem I’ve had with this one (although I haven’t experimented much) was that it seems to completely replace the foldable regions, and not just add to them, so when I was using it, the only foldable regions I had were the ones between
"""
s, that I manually defined. An example configuration for Python is provided on its readme.Example with
# region
and# endregion