Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit6b13962

Browse files
committed
fix#29, refine#30, cleanup only both exit_cb and close_cb is called
1 parent215c681 commit6b13962

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

‎autoload/neovim_rpc.vim‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func! neovim_rpc#jobstart(cmd,...)
6767
letl:opts=a:1
6868
endif
6969

70+
letl:opts['_close']=0
71+
letl:opts['_exit']=0
72+
7073
letl:real_opts= {'mode':'raw'}
7174
ifhas_key(l:opts,'detach')&&l:opts['detach']
7275
letl:real_opts['stoponexit']=''
@@ -79,6 +82,7 @@ func! neovim_rpc#jobstart(cmd,...)
7982
letl:real_opts['err_cb']=function('neovim_rpc#_on_stderr')
8083
endif
8184
letl:real_opts['exit_cb']=function('neovim_rpc#_on_exit')
85+
letl:real_opts['close_cb']=function('neovim_rpc#_on_close')
8286

8387
letl:job=job_start(a:cmd,l:real_opts)
8488
letl:jobid=ch_info(l:job)['id']
@@ -139,13 +143,27 @@ endfunc
139143
func!neovim_rpc#_on_exit(job,status)
140144
letl:jobid=ch_info(a:job)['id']
141145
letl:opts=g:_neovim_rpc_jobs[l:jobid]['opts']
142-
unletg:_neovim_rpc_jobs[l:jobid]
146+
letl:opts['_exit']=1
147+
" cleanup when both close_cb and exit_cb is called
148+
ifl:opts['_close']&&l:opts['_exit']
149+
unletg:_neovim_rpc_jobs[l:jobid]
150+
endif
143151
ifhas_key(l:opts,'on_exit')
144152
" convert to neovim style function call
145153
callcall(l:opts['on_exit'],[l:jobid,a:status,'exit'],l:opts)
146154
endif
147155
endfunc
148156

157+
func!neovim_rpc#_on_close(job)
158+
letl:jobid=ch_info(a:job)['id']
159+
letl:opts=g:_neovim_rpc_jobs[l:jobid]['opts']
160+
letl:opts['_close']=1
161+
" cleanup when both close_cb and exit_cb is called
162+
ifl:opts['_close']&&l:opts['_exit']
163+
unletg:_neovim_rpc_jobs[l:jobid]
164+
endif
165+
endfunc
166+
149167
func!neovim_rpc#_callback()
150168
executes:py .' neovim_rpc_server.process_pending_requests()'
151169
endfunc

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp