Allow ignoring responses at transport layer

Future versions may make this async.
This commit is contained in:
Tim Pope 2014-01-16 01:02:10 -05:00
parent fef85624d3
commit e6c1f9eac1
2 changed files with 5 additions and 8 deletions

View File

@ -48,7 +48,7 @@ function! s:nrepl_close() dict abort
if has_key(self, 'session')
try
unlet! g:fireplace_nrepl_sessions[self.session]
call self.message({'op': 'close'}, 'fireplace#nrepl#ignore')
call self.message({'op': 'close'}, 'ignore')
catch
finally
unlet self.session
@ -136,7 +136,7 @@ function! s:nrepl_eval(expr, ...) dict abort
let response = self.process(msg)
catch /^Vim:Interrupt$/
if has_key(msg, 'session')
call self.message({'op': 'interrupt', 'session': msg.session, 'interrupt-id': msg.id}, 'fireplace#nrepl#ignore')
call self.message({'op': 'interrupt', 'session': msg.session, 'interrupt-id': msg.id}, 'ignore')
endif
throw 'Clojure: Interrupt'
endtry
@ -194,9 +194,6 @@ function! fireplace#nrepl#callback(body, type, fn)
call call(a:fn, [response])
endfunction
function! fireplace#nrepl#ignore(...) abort
endfunction
function! s:nrepl_call(msg, ...) dict abort
let terms = a:0 ? a:1 : ['done']
let sels = a:0 > 1 ? a:2 : {}

View File

@ -103,10 +103,10 @@ endfunction
function! s:nrepl_transport_call(msg, terms, sels, ...) dict abort
let payload = nrepl#fireplace_connection#bencode(a:msg)
let response = self.dispatch('call', payload, a:terms, a:sels)
if a:0
return map(response, 'fireplace#nrepl#callback(v:val, "synchronous", a:1)')
else
if !a:0
return response
elseif a:1 !=# 'ignore'
return map(response, 'fireplace#nrepl#callback(v:val, "synchronous", a:1)')
endif
endfunction