kassio/neoterm

Python REPL gives an error when sending code containing a string that ends with `'r'`

gboehl opened this issue · 1 comments

Describe the bug
If a line contains a string ending with 'r', 'R', "r" or "R" (that is, any string ending with the letter "R"), neoterm appends an additional ' or " to the end of the line when sending it to the repl. This (not surprisingly) creates a syntax error in python.

To Reproduce
Steps to reproduce the behavior:

  1. Opened a neoterm python REPL
  2. Send "r"
  3. receive
In [1]: "r"'
  Input In [1]
    "r"'
       ^
SyntaxError: unterminated string literal (detected at line 1)

Expected behavior
Something along the lines of

In [2]: "q"
Out[2]: 'q'

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

  • OS: Arch Linux
  • neoterm installed via Vundle
  • Add all the configuration you have for neoterm

let g:neoterm_default_mod='belowright'
let g:neoterm_size=12
let g:neoterm_autoscroll=1

- Vim or Neovim
- [ ] vim
- [x] neovim
- Version v0.6.1

Additional context

This really only seems to happen when r is the last member of a string (like in 'star'), not for any other letter or number.

I noticed that input 'r' get send as "r"' (with a ' at the end, but the original ' gets translated to ") while for "r" the REPL receives "r"" (with a " at the end).

Thanks for this nice piece of software!

This rather seems to be a problem with the newest version of IPython rather than neoterm. The terminal automatically adds another quotation mark when starting to type r'.

My current workaround is to set TerminalInteractiveShell.auto_match = True in the ipython_config, but thats not a nice solution:

https://ipython.readthedocs.io/en/stable/config/options/terminal.html#configtrait-TerminalInteractiveShell.auto_match

I'm leaving this open as I expect others to run into the same problem once they update IPython.