1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

Fix runner and repl (#3305)

This commit is contained in:
Wang Shidong 2020-01-26 22:15:55 +08:00 committed by GitHub
parent d1ba7d7cf2
commit e9403f914d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 7 deletions

View File

@ -153,8 +153,11 @@ endfunction
" @vimlint(EVL103, 0, a:data)
" @vimlint(EVL103, 0, a:event)
function! s:close() abort
if exists('s:job_id') && s:job_id != 0
" stop the job if it is running.
if exists('s:job_id') && s:job_id > 0
call s:JOB.stop(s:job_id)
let s:job_id = 0
endif

View File

@ -241,9 +241,14 @@ if has('nvim') && exists('*chanclose')
else
let lines = s:_out_data
endif
" if s:SYS.isWindows
" let lines = map(lines, 's:ICONV.iconv(v:val, "cp936", "utf-8")')
" endif
if !empty(lines)
let lines = map(lines, "substitute(v:val, ' $', '', 'g')")
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines)
if bufexists(s:bufnr)
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines)
endif
call s:VIM.win_set_cursor(s:winid, [s:VIM.buf_line_count(s:bufnr), 1])
endif
let s:lines += len(lines)
@ -266,7 +271,9 @@ if has('nvim') && exists('*chanclose')
endif
if !empty(lines)
let lines = map(lines, "substitute(v:val, ' $', '', 'g')")
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines)
if bufexists(s:bufnr)
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines)
endif
call s:VIM.win_set_cursor(s:winid, [s:VIM.buf_line_count(s:bufnr), 1])
endif
let s:lines += len(lines)
@ -275,7 +282,9 @@ if has('nvim') && exists('*chanclose')
endfunction
else
function! s:on_stdout(job_id, data, event) abort
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data)
if bufexists(s:bufnr)
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data)
endif
let s:lines += len(a:data)
call s:VIM.win_set_cursor(s:winid, [s:VIM.buf_line_count(s:bufnr), 1])
call s:update_statusline()
@ -283,7 +292,9 @@ else
function! s:on_stderr(job_id, data, event) abort
let s:status.has_errors = 1
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data)
if bufexists(s:bufnr)
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data)
endif
let s:lines += len(a:data)
call s:VIM.win_set_cursor(s:winid, [s:VIM.buf_line_count(s:bufnr), 1])
call s:update_statusline()
@ -295,7 +306,9 @@ function! s:on_exit(job_id, data, event) abort
let s:status.is_exit = 1
let s:status.exit_code = a:data
let done = ['', '[Done] exited with code=' . a:data . ' in ' . s:STRING.trim(reltimestr(s:end_time)) . ' seconds']
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, done)
if bufexists(s:bufnr)
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, done)
endif
call s:update_statusline()
endfunction
@ -319,7 +332,7 @@ function! SpaceVim#plugins#runner#status() abort
endfunction
function! SpaceVim#plugins#runner#close() abort
if s:status.is_exit == 0
if s:status.is_exit == 0 && s:job_id > 0
call s:JOB.stop(s:job_id)
endif
exe 'bd ' s:bufnr