tweekmonster / impsort.vim

Sort and highlight Python imports in Vim
MIT License
37 stars 6 forks source link

Issues when folding a function #9

Closed petobens closed 8 years ago

petobens commented 8 years ago

I use this plugin to fold my python classes, functions and imports. However there seems to be a clash with Impsort. Consider the following .py file:

def bar():
    print('bar')
    import sys
    sys.exit()

As in the GIF, fold this function and then run :ImpSort. You will see that the whole function disappears. Thanks in advance for looking into this!

jul-13-2016 11-11-41

petobens commented 8 years ago

When using the following two functions:

def foo():
    import sys
    sys.exit()
    print('foo')

def bar():
    print('bar')
    import sys
    sys.exit()

and repeating the above procedure I get (as in the GIF)

    import sys
    import sys

jul-13-2016 11-16-02

tweekmonster commented 8 years ago

I know what's going on. The plugin uses a range of lines with the delete command. I think the range is based on lines that you see, not the actual line numbers. I'll see if there's a better way to go about it.

petobens commented 8 years ago

Awesome. Thanks!!

tweekmonster commented 8 years ago

I think it's fixed now. Let me know if you're still having problems with folds.

petobens commented 8 years ago

Seems to work great. Thank you!