Work around bug on ancient Vim

Closes #226.
This commit is contained in:
Tim Pope 2015-06-29 17:46:45 -04:00
parent 09c80c6794
commit f456f04b65

View File

@ -219,10 +219,6 @@ if !exists('s:repls')
let s:repl_portfiles = {} let s:repl_portfiles = {}
endif endif
function! s:repl.user_ns() abort
return 'user'
endfunction
function! s:repl.path() dict abort function! s:repl.path() dict abort
return self.connection.path() return self.connection.path()
endfunction endfunction
@ -236,16 +232,6 @@ function! s:conn_try(connection, function, ...) abort
endtry endtry
endfunction endfunction
function! s:repl.eval(expr, options) dict abort
if has_key(a:options, 'ns') && a:options.ns !=# self.user_ns()
let error = self.preload(a:options.ns)
if !empty(error)
return error
endif
endif
return s:conn_try(self.connection, 'eval', a:expr, a:options)
endfunction
function! s:repl.message(payload, ...) dict abort function! s:repl.message(payload, ...) dict abort
if has_key(a:payload, 'ns') && a:payload.ns !=# self.user_ns() if has_key(a:payload, 'ns') && a:payload.ns !=# self.user_ns()
let ignored_error = self.preload(a:payload.ns) let ignored_error = self.preload(a:payload.ns)
@ -321,6 +307,20 @@ function! s:piggieback.eval(expr, options) abort
return call(s:repl.eval, [a:expr, options], self) return call(s:repl.eval, [a:expr, options], self)
endfunction endfunction
function! s:repl.user_ns() abort
return 'user'
endfunction
function! s:repl.eval(expr, options) dict abort
if has_key(a:options, 'ns') && a:options.ns !=# self.user_ns()
let error = self.preload(a:options.ns)
if !empty(error)
return error
endif
endif
return s:conn_try(self.connection, 'eval', a:expr, a:options)
endfunction
function! s:register_connection(conn, ...) abort function! s:register_connection(conn, ...) abort
call insert(s:repls, extend({'connection': a:conn, 'piggiebacks': []}, deepcopy(s:repl))) call insert(s:repls, extend({'connection': a:conn, 'piggiebacks': []}, deepcopy(s:repl)))
if a:0 && a:1 !=# '' if a:0 && a:1 !=# ''