jalvesaq / vimcmdline

Send code to command line interpreter
GNU General Public License v2.0
223 stars 38 forks source link

Python send paragraph sends extra blanks lines to repl #75

Closed blayz3r closed 3 years ago

blayz3r commented 5 years ago

Windows 10, python 3.7

image

jalvesaq commented 5 years ago

I think an extra blank line might be necessary if, for example, the paragraph is a function definition. I changed the code to add an extra blank line only if the last line is not a blank line yet. Is it OK now?

blayz3r commented 5 years ago

Still see it, does the fix work on your machine? I agree, it works the way you expect for a class or function but introduces extra lines for regular paragraphs.

jalvesaq commented 5 years ago

I never use the send paragraph function...

Could you, please, try changing the code in ftplugin/python_cmdline.vim (line 42) from

        if a:lines[len(a:lines)-1] == ''
            call VimCmdLineSendCmd(join(a:lines, b:cmdline_nl))
        else
            call VimCmdLineSendCmd(join(add(a:lines, ''), b:cmdline_nl))
        endif

to

        call VimCmdLineSendCmd(join(a:lines, b:cmdline_nl))

? Does it work?

blayz3r commented 5 years ago

Yep better. thanks.

blayz3r commented 5 years ago

Using :call PythonSourceLines(getline(1,3)) works fine but it looks like:

https://github.com/jalvesaq/vimcmdline/blob/804b3785441bd4a6559bdfb3ab9e7be8b3cae7bc/plugin/vimcmdline.vim#L320-L330

Adds the empty line before the loop breaks