kassio / neoterm

Wrapper of some vim/neovim's :terminal functions.
Other
1.32k stars 117 forks source link

No newline on indented selection sent to python REPL #315

Closed erietz closed 3 years ago

erietz commented 3 years ago

Describe the bug

If a selection is sent to an ipython (or python) REPL whose last lines are indented, the code is not executed. One must go to the terminal and press <CR> for the code to be evaluated. A slight inconvenience.

To Reproduce

  1. Sent a visual selection of a multi-line piece of python code whose last line is indented via :'<,'>TREPLSendSelection
  2. Text is properly sent to a newly opened ipython REPL
  3. The text is not automatically executed

Expected behavior

One would expect the selected text that is sent to be evaluated. This is the case when passing code to a shell rather than a python REPL as shown in the following screenshots.

Screenshots/gifs

python repl: unexpected behavior Screen Shot 2021-01-07 at 1 34 54 PM

zsh repl: expected behavior Screen Shot 2021-01-07 at 1 35 10 PM

Versions (Issues without this information will take longer to be answered/solved):

Additional context This plugin is very nice!

echasnovski commented 3 years ago

I believe the reason here is a particular behavior of ipython REPL. If that code is typed manually, it still needs an empty line "confirmation" to run. Neoterm seems to just imitate the process of manual typing the exact sequence of symbols (which is an expected behavior for me at least). I overcome this by selecting and sending blocks with surrounding lines (for example, with vap and not vip for paragraph). In case of zsh REPL there is no need for an empty line "confirmation" when typing manually and that is why sent code is executed immediately.

erietz commented 3 years ago

vap does the trick

seb-mueller commented 3 years ago

Just to add since I was still struggling with this issue. I had to set let g:neoterm_bracketed_paste=1 to make it work (memomnic s for send), i.e. I've set nmap s <Plug>(neoterm-repl-send), so with the cursor within the paragraph, sap (send around paragraph) will do the trick! Also, as pointed out by @echasnovski , the inner paraprahp operation sip won't work.