Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code is refolded automatically when pasting #35

Open
steve-biggs-fox opened this issue Jun 29, 2021 · 2 comments
Open

Code is refolded automatically when pasting #35

steve-biggs-fox opened this issue Jun 29, 2021 · 2 comments

Comments

@steve-biggs-fox
Copy link

Consider the following code:

"""
Header line describing the program

License information etc
"""

class MyClass:

    def myMethod(self):
        pass

    def myOtherMethod(self):
        pass

When all is folded, it will be like this:

Header line describing the program

class MyClass:

I like to work with the header folded but the class open so I can see the methods (maybe some of the methods will be open too but that doesn't make any difference so let's ignore that for now), e.g. like this:

Header line describing the program

class MyClass:

    def myMethod(self):
    def myOtherMethod(self):

However, if I paste two or more lines between the folded header line and the open class, then the class re-folds itself, which I do not want.

Expected outcome after paste:

Header line describing the program

myStaticVariable = 1
myOtherStaticVariable = 2

class MyClass:

    def myMethod(self):
    def myOtherMethod(self):

Actual outcome after paste:

Header line describing the program

myStaticVariable = 1
myOtherStaticVariable = 2

class MyClass:

As noted above, it doesn't make any difference if methods within the class are open - the whole class is re-folded. Note also that pasting a single line works OK (i.e. class stays open) - it is only a problem when pasting two or more lines.

Also, there is a problem when typing in the lines manually. This happens when a new line is inserted. The problem is that the folded methods get messed up, e.g. the fold is shifted up or down so that the fold text is blank or the fold is only on the contents of the method but the name line is unfolded.

@kalekundert
Copy link
Owner

Do you have the FastFold plugin installed? If not, I think it will solve this problem.

@gegnew
Copy link

gegnew commented Jan 30, 2022

I have this problem as well, and FastFold doesn't seem to solve the issue. It also folds expanded snippets automatically, so that:

"test" + expand-mapping resolves to

def test_description():  # fold

instead of

def test_<description>():
    <snippet>

where < > are snippet placeholders.

This prevents placeholders from being used.

This (and the OP issue) appear to be "resolved" if you zR on the file before pasting or snippet-ing.

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

No branches or pull requests

3 participants