Skip to content

Commit b4f710f

Browse files
use callbag share for stream and avoid directly using s:Stream (#996)
Returns a shared version of callbag when calling lsp#stream so that there is a refcount to avoid accidental unsubscriptions and new subscribers will auto subscribe.
1 parent ea78f5c commit b4f710f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

autoload/lsp.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ function! s:on_notification(server_name, id, data, event) abort
789789
if has_key(a:data, 'request')
790790
let l:stream_data['request'] = a:data['request']
791791
endif
792-
call s:Stream(1, l:stream_data) " notify stream before callbacks
792+
call lsp#stream(1, l:stream_data) " notify stream before callbacks
793793

794794
if lsp#client#is_server_instantiated_notification(a:data)
795795
if has_key(l:response, 'method')
@@ -816,7 +816,7 @@ function! s:on_request(server_name, id, request) abort
816816
call lsp#log_verbose('<---', 's:on_request', a:id, a:request)
817817

818818
let l:stream_data = { 'server': a:server_name, 'request': a:request }
819-
call s:Stream(1, l:stream_data) " notify stream before callbacks
819+
call lsp#stream(1, l:stream_data) " notify stream before callbacks
820820

821821
if a:request['method'] ==# 'workspace/applyEdit'
822822
call lsp#utils#workspace_edit#apply_workspace_edit(a:request['params']['edit'])
@@ -985,7 +985,7 @@ endfunction
985985
" call lsp#stream(1, { 'command': 'DocumentFormat' })
986986
function! lsp#stream(...) abort
987987
if a:0 == 0
988-
return s:Stream
988+
return lsp#callbag#share(s:Stream)
989989
else
990990
call s:Stream(a:1, a:2)
991991
endif
@@ -1171,7 +1171,7 @@ endfunction
11711171

11721172
function! lsp#_new_command() abort
11731173
let s:last_command_id += 1
1174-
call s:Stream(1, { 'command': 1 })
1174+
call lsp#stream(1, { 'command': 1 })
11751175
return s:last_command_id
11761176
endfunction
11771177

0 commit comments

Comments
 (0)