PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

python editor code-folding for def and class code blocks not working properly in release 17.2.3

Open vsfeedback opened this issue 3 years ago • 2 comments

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version] [regression] [worked-in:VS 2019] The python editor code-folding for def and class code blocks does not work properly in release 17.2.3 for me:

[-] def funcname():
x=3 y=4

when folded, collapses to

[+] def [...]

where [ ] = box around contents

In other words, the function name and arguments disappear completely, leaving the code-folding essentially useless for def blocks. For example, take a look at the included screenshot to see what I mean.

Same result occurs with class classname blocks: the classname itself is replaced by [...] leaving you with [+] class [...]. Again useless.

I've tried this with fresh VS 2022 17.2.3 installs on two Win10 computers, and same result on both of them. After install, I created a new python project and in the myfile.py file, I added the above def block only. With that simple project, code-folding was problematic as described above. So no fancy settings or odd project types required to reproduce this problem.

A friend of mine has VS 2022 17.0.2 on his Win10 laptop (similar type to mine), and python code-folding for def funcname(): works perfectly fine and as expected on his system: it leaves the top-level def funcname() statement followed by [...]

I should also point out that code-folding on for and if blocks works as it should, leaving the top line intact followed by [...]. Only def and class blocks are showing this faulty behavior of erasing the entire top line and replacing it with [...] (at least in my limited testing - there may be other block types that suffer this problem as well).

Your help in resolving this problem would be much appreciated.


Original Comments

Feedback Bot on 6/1/2022, 11:33 PM:

(private comment, text removed)


Original Solutions

(no solutions)

vsfeedback avatar Jun 08 '22 16:06 vsfeedback

duplicate of #7016

StellaHuang95 avatar Jun 08 '22 17:06 StellaHuang95

Since this is now the replacement for #7016, I would like to add that the actual command "Collapse to definitions" is nonfunctional in the edit menu as well

niwax avatar Jun 10 '22 08:06 niwax

Is this still a thing? It does not work on my computer either, nothing to collapse for python files (But for other programming languages)

Dabendorf avatar Nov 04 '22 14:11 Dabendorf

Hi @Dabendorf, yes it's in our backlog to fix. Filed another issue in pylance to track the issue. https://github.com/microsoft/pylance-release/issues/3580

StellaHuang95 avatar Nov 04 '22 23:11 StellaHuang95

In which version was this solved? Already in 2022.18.2? (because it isn't working on my computer anyway)

Dabendorf avatar Nov 19 '22 13:11 Dabendorf

Still broken?

VladisS-Vostok2000 avatar May 23 '23 16:05 VladisS-Vostok2000

Looks like it is fixed for me now. Did you actually find another bug or was waiting for the bug to disappear on my computer enough?

Dabendorf avatar May 25 '23 19:05 Dabendorf

Found another, thanks.

VladisS-Vostok2000 avatar May 25 '23 19:05 VladisS-Vostok2000

Ctrl+M+O not working for Python code (expand def only) in VS 2022, 17.7.7 (just updated)

viamo-sl avatar Dec 03 '23 11:12 viamo-sl

can't collapse C# code functions as well, missing the [+] 17.8.3

PGTBoos avatar Dec 12 '23 07:12 PGTBoos