New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Channel is wired with call command #3852
Comments
Do you mean |
Not terminal, I mean start a channel by |
timer_start, ch_open, or job_start return timer, channel, job. Those return value must be hold with set to variable since it will be removed by GC.
|
It's not problem of GC, the function works as expected when I wrap it in timer_start, but doesn't work when I send |
Could you please provide code that does not work? |
mini.vim: set nocompatible
filetype plugin indent on
syntax on
let s:activated = 0
function! s:getchar()
let ch = getchar()
return (type(ch) == 0 ? nr2char(ch) : ch)
endfunction
function! Start()
let s:activated = 1
while s:activated
let ch = s:getchar()
if ch ==# "\u26d4"
echom 'succeed'
break
endif
echo ch
endwhile
let s:activated = 0
endfunction
call timer_start(1000, {-> feedkeys("\u26d4", 'in')})
" start node server
let file = expand('<sfile>:h').'/server.js'
let cmd = ['node', file]
let options = {
\ 'noblock': 1,
\ 'in_mode': 'json',
\ 'out_mode': 'json',
\ 'err_mode': 'nl',
\ 'timeout': 3000,
\}
let job = job_start(cmd, options)
let status = ch_status(job)
if status !=# 'open'
echohl Error | echon 'Failed to server server' | echohl None
finish
endif
"call Start() server.js function send(arr) {
process.stdout.write(JSON.stringify(arr) + '\n')
}
send(['call', 'Start', []]) Save mini.vim and server.js in same folder, and run |
Thanks provide code. I understand what is your problem. This is known behavior. You can not use getchar() or input() in callback on channel. You can do with making wrapper.
|
Consider following code:
It works as expected, vim could receive
\u26d4
and exit the blocked while.But when the
call Start()
is called from channel by send['call', 'Start', []]
to vim, vim couldn't receive\u26d4
any more.One workaround is wrap the
Start
function with a timer, like:And call this function from channel.
The text was updated successfully, but these errors were encountered: