Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm Code Folding/Outlining Generates Wrong Boundaries

Tags:

python

pycharm

I'm having a very frustrating issue with PyCharm in that it does not want to properly outline the code so that blocks fold correctly. I've looked all over the place and couldn't find any help with this particular problem. In a nutshell, PyCharm seems to decide on skewed block boundaries so that the blocks fold up on each other. It's quite irritating. Any thoughts?

Example of Incorrect Folding Behavior:

Code to be folded

Trying to collapse _get_thread_name yields this: enter image description here

Example of Correct Folding Behavior:

enter image description here enter image description here

like image 401
Brandon Braun Avatar asked Oct 14 '18 14:10

Brandon Braun


1 Answers

Finally!! I figured out how to remove the invalid folding regions. If you place your cursor on the line that starts an invalid folding block (line 106 in my first example), then right click anywhere in that line and select Folding -> Fold Selection / Remove Region and that will delete the incorrect folding annotation!

I still have no clue why they are generated in the first place, but at least this is a decent "fix".

like image 160
Brandon Braun Avatar answered Sep 26 '22 00:09

Brandon Braun