Fix sending interrupt commands after SIGINT

Via @benmoss.  Closes #182.
This commit is contained in:
Tim Pope 2014-10-21 15:16:58 -04:00
parent eeccb69a2f
commit 97758acc16

View File

@ -147,11 +147,14 @@ function! s:nrepl_eval(expr, ...) dict abort
endif endif
try try
let response = self.process(msg) let response = self.process(msg)
catch /^Vim:Interrupt$/ finally
if has_key(msg, 'session') if !exists('response')
call self.message({'op': 'interrupt', 'session': msg.session, 'interrupt-id': msg.id}, 'ignore') let session = get(msg, 'session', self.session)
if !empty(session)
call self.message({'op': 'interrupt', 'session': session, 'interrupt-id': msg.id}, 'ignore')
endif endif
throw 'Clojure: Interrupt' throw 'Clojure: Interrupt'
endif
endtry endtry
if has_key(response, 'ns') && !has_key(options, 'ns') if has_key(response, 'ns') && !has_key(options, 'ns')
let self.ns = response.ns let self.ns = response.ns
@ -175,7 +178,12 @@ function! s:extract_last_stacktrace(nrepl, session) abort
endif endif
endif endif
let format_st = '(symbol (str "\n\b" (apply str (interleave (repeat "\n") (map str (.getStackTrace *e)))) "\n\b\n"))' let format_st = '(symbol (str "\n\b" (apply str (interleave (repeat "\n") (map str (.getStackTrace *e)))) "\n\b\n"))'
let stacktrace = split(get(split(a:nrepl.process({'op': 'eval', 'code': '['.format_st.' *3 *2 *1]', 'ns': 'user', 'session': a:session}).value[0], "\n\b\n"), 1, ""), "\n") let response = a:nrepl.process({'op': 'eval', 'code': '['.format_st.' *3 *2 *1]', 'ns': 'user', 'session': a:session})
try
let stacktrace = split(get(split(response.value[0], "\n\b\n"), 1, ""), "\n")
catch
throw string(response)
endtry
call a:nrepl.message({'op': 'eval', 'code': '(*1 1)', 'ns': 'user', 'session': a:session}) call a:nrepl.message({'op': 'eval', 'code': '(*1 1)', 'ns': 'user', 'session': a:session})
call a:nrepl.message({'op': 'eval', 'code': '(*2 2)', 'ns': 'user', 'session': a:session}) call a:nrepl.message({'op': 'eval', 'code': '(*2 2)', 'ns': 'user', 'session': a:session})
call a:nrepl.message({'op': 'eval', 'code': '(*3 3)', 'ns': 'user', 'session': a:session}) call a:nrepl.message({'op': 'eval', 'code': '(*3 3)', 'ns': 'user', 'session': a:session})