Skip to content

Conversation

Catgolin
Copy link

Currently, in Python, when we have type-hints in the definition of a function, the folding occurs on the first colon.

Folding the following function:

def some_function(arg: ArgType) -> ReturnType:
    # Stuff
    pass

will result in only showing
def some_function(arg:...

Just updating the rule of the parser to check if the colon is at the end of the line fixes the issue, allowing to show the full function definition, def some_function(arg: ArgType) -> ReturnType: which is far more appreciable in my opinion.
I believe the only cases in Python where we have a colon that is not at the end of the line is the situation described above, where we are hinting the type of a parameter, and the definition of entries in a dictionary, so this modification should not break anything (but I might be mistaken).
The only case I could think of that breaks this is if we add a comment after the colon at the end of the line, but I don't think this really causes an issue.

Make foldings in Python happen only when colon is at the end on the line (to prevent folding in the middle of the definition of a function while using type-hints)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant