In the case of if-elif-else constructs, classes, class methods, loops, etc., there is an option to collapse a code block using the arrows on the left. However, this functionality is missing for the match/case construct. It seems logical to me that such an option should exist for all logical blocks, so it's strange that I don't have it. The question is whether this option is missing just for me, or if it's generally not available for match/case? If the problem is on my end, how can I resolve it?
The box for Show code folding arrows is checked in the settings. All plugins are up to date, and snap reports that there are no updates available. Ubuntu version: 22.04
Pattern matching came to Python with 3.10, but Pycharm does currently not support code-folding for it in the way it does for if-else blocks.
According to
the devs are currently working on it, hopefully we will get to enjoy it in the coming updates. In the meantime you could define regions in your code to get the desired behaviour. If your code is this
match string:
case a:
print("a")
case b:
print("b")
You can define a region for each case, which can then be folded
match string:
#region Folded A
case a:
print("a")
#endregion Folded A
case b:
print("b")
After clicking on the fold arrow it will look like this
match string:
Folded A
case b:
print("b")