Skip to content

Commit

Permalink
Move bracketed paste to its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
kassio committed Sep 25, 2020
1 parent 11a1215 commit 018f662
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions autoload/neoterm/repl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,23 @@ endfunction

function! g:neoterm.repl.exec(command) abort
let l:ft_exec = printf('neoterm#repl#%s#exec', &filetype)
if g:neoterm_bracketed_paste
let a:command[0] = "\x1b[200~" . a:command[0]
let a:command[-1] = a:command[-1] . "\x1b[201~"
endif
let l:command = s:bracketed_paste(a:command)

try
let ExecByFiletype = function(l:ft_exec)
call ExecByFiletype(a:command)
call ExecByFiletype(l:command)
catch /^Vim\%((\a\+)\)\=:E117/
call g:neoterm.repl.instance().exec(add(a:command, g:neoterm_eof))
call g:neoterm.repl.instance().exec(add(l:command, g:neoterm_eof))
endtry
endfunction

function! s:bracketed_paste(command)
let l:command = a:command

if g:neoterm_bracketed_paste
let l:command[0] = "\x1b[200~" . l:command[0]
let l:command[-1] = l:command[-1] . "\x1b[201~"
else
return l:command
endif
endfunction

2 comments on commit 018f662

@sencer
Copy link

@sencer sencer commented on 018f662 Sep 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change causes the following error when sending lines to ipython

Error detected while processing function neoterm#repl#opfunc[8]..5[6]..neoterm#repl#python#exec[5]..<SNR>71_ipython_command_for:
line    1:
E712: Argument of filter() must be a List or Dictionary

@kassio
Copy link
Owner Author

@kassio kassio commented on 018f662 Sep 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, thanks for fixing it.

Please sign in to comment.