PyCharm Code Folding/Outlining Generates Wrong Boundaries

前端 未结 2 1854
旧时难觅i
旧时难觅i 2021-01-02 23:36

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 co

相关标签:
2条回答
  • 2021-01-02 23:57

    You can use

    # region FooRegion
      ...
      your-code-here
      ...
    # endregion
    

    This will create code folding regions manually like in visual studio style

    0 讨论(0)
  • 2021-01-03 00:00

    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".

    0 讨论(0)
提交回复
热议问题