The title may be confusing so I will explain it. I run python on replit.com (not sure if this is only an issue on replit.com) and sometimes when I hide then unhide code within a function it automatically puts code that's next to but not within the function inside the function. Sometimes it does this but other times it doesn't and I don't understand its reasoning. Let me show you an example:
def f(x): # Collapsed Function
# Comment (outside of function)
I open the function
def f(x): # Open Function
print("Function is open")
# Comment (outside of function)
Then I close it
def f(x): # Closed Function
Then I reopen it
def f(x): # Open Function
print("Function is open")
# Comment (Inside Function)
What's more odd is that the comment isn't indented yet the code acts as if the comment is within the function. This isn't the only occurrence. So here is my question: Why does this occur and how can I prevent this from happening again?