New folding strategy does not fold internally indented multiline strings #3877
Replies: 13 comments
-
@CaBazaga, thanks for reporting this. I'm curious why folding of indented sections of the doc string is desirable. Maybe there's a convention about doc string formatting that I'm not aware of related to indenting. Can you give me a real-world example where folding other than root level folding would make sense? |
Beta Was this translation helpful? Give feedback.
-
Hi @debonte thanks for the answer. First to mention the I should have said "multiline strings" rather than docstrings, it's just it was a docstring were I noticed the were no internally folding anymore. For the docstrings, or in general multiline strings, folding would be useful when that string is itself a formatted paragraph or doc that spawns for more than a few lines. Sometimes I use formating, markdown / restructured, on docstrings to auto generate doc with Sphinx or similar tools. Another example for multiline may be, for example a json, or schema, stored as a literal on a variable and written, for human readability convenience, not minimized. It's true that the issue of not folding dicts root level is much higher, I've never had a multiline string that expands so big, but internal, indented based, folding may fit useful. Multiline string folding is a feature I may live without but proven useful to me in the past and that I missed the same day I updated my VSCode. The issue with Dicts root level folding seem much more prior to me, may I should have written two separate ones. |
Beta Was this translation helpful? Give feedback.
-
Here is another example where code folding doesn't work as it did before... Can't fold multi-line function arguments (per Black formatting). I miss this. |
Beta Was this translation helpful? Give feedback.
-
@blaylockbk, please file a new issue. It's hard for us to track what is fixed vs. not if a single issue has many unrelated problems in it. |
Beta Was this translation helpful? Give feedback.
-
@CaBazaga, dict folding will be fixed in our next release. |
Beta Was this translation helpful? Give feedback.
-
@CaBazaga, we're going to wait for more feedback/up-votes before acting on the "indented multiline strings" issue. |
Beta Was this translation helpful? Give feedback.
-
Seems right to me, perfect. 👍 Also noticed the dicts now folds on the root level after latest update, thanks for it. 🎉 |
Beta Was this translation helpful? Give feedback.
-
I don't keep up with changes/updates. VSCode just updates things, and I assume everything will work as it already did. When I make a bunch of code then discard it, I like to leave it in place (indented) and place an explanation above it.
The current pylance collapsed I don't know what changes come in the updates but I do know I'd rather use the oldest version of pylance that supports this than the newest version that doesn't. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Got it. I don't know what issue people are having, to specify "dictionary". Here are what I see:
def function( # << not folded
vars, # << stopped folding in update == bad
): # << stopped folding in update == bad
pass # << foldable
from json import dumps # << not folded
from time import asctime # << folds in update == weird
""" A multiline string # << line_a: not folded
First indented line # << line_b: folded
Second indented line # << line_c: folds only from line_a in update == bad. should fold under line_b
""" # << line_z: I don't remember if this folded in the update
# Commented text # << not folded
# text only indented in the comment # << not folded
# text actually indented # << stopped folding in update
# sub indent of comment # << stopped folding in update
# Last comment, like a block # << not folded
dictionary = { # not folded
'one': 1, # << folded
'two': 2, # << folded
# comment # << folded
'three': 3, # << only folded under the root / dictionary == expected because it's not indented
# comment # << folded
'four': 4, # << only folded under root/dictionary in update == bad
'five': 5, # folded
'six': 6, # << only folded under root/dictionary in update == bad
} # << not folded
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the detailed examples @Irmitya!
When we recently fixed #2269 we chose to adopt TypeScript's folding behavior. It sounds like you would like us to enable "option 3" as described in this comment. Is that correct? Could you please add a comment on that issue with your preference?
Many languages support folding of groups of import lines. Not sure what else to say there. Obviously you can ignore it if that's not useful to you.
That's this issue. Thanks for upvoting. I'd love to see a real-world example where this is interesting. Either a code snippet or a link to code in some public repo.
Please file a new issue on folding of indented comments. A real-world example would be helpful there as well. If you'd like your indented dictionary item scenario to be considered as well, please file a separate issue on that. I'd have to see upvotes/feedback from more users to be convinced there. |
Beta Was this translation helpful? Give feedback.
-
I only use it as a multiline comment. I use it to comment out old code, that I either don't want to delete yet or I haven't gotten around to cleaning. Example "times" of when I would do this, is when I wrote some code, then concluded it's a failed venture or I decided to redo it. I don't want to use comments for any reason, such as that would require selecting the code specially to keep the indentation folding, only using comments for description texts and/or non-working code, I just prefer the string color here instead of comment's. |
Beta Was this translation helpful? Give feedback.
-
The only remaining request here is having folding nodes for indented portions within a multi-line string. Moving this issue to discussion as an enhancement request for comments and upvotes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Environment data
Expected behaviour
As previous version:
Expect to be able to fold dict declaration
Expected to be able to fold inside multiline string.
Actual behaviour
The dict, which may expand thousand of lines, is not foldable.
The multiline string is just root level foldable.
Code Snippet / Additional information
Only imports and root level of docstring are foldable while dict and internal of the dostring was before.
Beta Was this translation helpful? Give feedback.
All reactions