Skip to content

Region folding not working at last region, if region only contains indented code #3375

Closed as not planned

Description

Discussed in microsoft/vscode-python#19815

Originally posted by Roffelkopter5 September 12, 2022
I have a Python class with a lot of diffrent methods, wich I want to group into regions. For the first 5 regions the folding works perfectly normal, but after the the region PROPERTIES it just stops working.

Here is a stripped down version of my code.

# Bunch of imports


class Sprite:
    def __init__(self):
        ...

    # region MOTION

    def change_pos(self):
        ...

    # Some other functions

    def bounce_on_edge(self):
        ...

    # endregion

    # region LOOKS

    def set_image(self):
        ...

    # Some other functions

    def show(self):
        ...

    # endregion

    # region EVENTS

    def on_key(self):
        ...

    # Some other functions

    def clone(self):
        ...

    # endregion

    # region CONTROLS

    def wait(self):
        ...

    # Some other functions

    def repeat_until(self):
        ...

    # endregion

    # region PROPERTIES

    @property
    def image(self):
        ...

    # Some other functions

    @property
    def name(self):
        ...

    # endregion

    # region PRIVATE

    def _update(self):
        ...

    # Some other methods

    def _scale_and_rotate(self):
        ...
    # endregion

After further testing I noticed, that the problem does not occur espacially at the fith region, but on the last one. And the nature of the problem seems to lie in the fact that the region only contains indented Code. I don't know if this behaviour is intentional, or if there's an easy fix for it, but it's kind of annoying not being able to collapse the last region.

I hope I described the problem clearly and that my english is not too bad :)

Activity

  1. debonte commented on Sep 21, 2022

    @debonte
    Contributor

    Simplified form:

    class Sprite:
        # region PRIVATE
    
        def _update(self):
            ...
    
        # endregion

    This is a duplicate of #3290

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions