Skip to content

Commit 761406e

Browse files
committed
Use dict instead of optional buffer#Update() args
1 parent 2743348 commit 761406e

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

autoload/OmniSharp/actions/buffer.vim

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
let s:save_cpo = &cpoptions
22
set cpoptions&vim
33

4-
" Optional arguments:
5-
" - callback: funcref to be called after the response is returned (synchronously
4+
" Synchronize the buffer contents with the server. By default, contents are only
5+
" sent when there have been changes since the last run.
6+
" Optional argument: A dict containing the following optional items:
7+
" Callback: funcref to be called after the response is returned (synchronously
68
" or asynchronously)
7-
" - initializing: flag indicating that this is the first request for this buffer
8-
" - sendBuffer: flag indicating that the buffer contents should be sent,
9+
" Initializing: flag indicating that this is the first request for this buffer
10+
" SendBuffer: flag indicating that the buffer contents should be sent,
911
" regardless of &modified status or b:changedtick
1012
function! OmniSharp#actions#buffer#Update(...) abort
11-
let cb = a:0 && type(a:1) == type(function('tr')) ? { 'Callback': a:1 } : {}
12-
let initializing = a:0 > 1 && a:2 is 1
13-
let sendBuffer = initializing || (a:0 > 2 ? a:3 : 0)
13+
let opts = a:0 ? a:1 : {}
14+
let opts.Initializing = get(opts, 'Initializing', 0)
15+
let opts.SendBuffer = opts.Initializing || get(opts, 'SendBuffer', 0)
1416
if bufname('%') ==# '' || OmniSharp#FugitiveCheck() | return | endif
1517
let lasttick = get(b:, 'OmniSharp_UpdateChangeTick', -1)
16-
if initializing || sendBuffer || b:changedtick != lasttick
18+
if opts.SendBuffer || b:changedtick != lasttick
1719
let b:OmniSharp_UpdateChangeTick = b:changedtick
1820
if g:OmniSharp_server_stdio
19-
let opts = {
20-
\ 'ResponseHandler': function('s:StdioUpdateRH', [cb]),
21-
\ 'Initializing': initializing
21+
let requestOpts = {
22+
\ 'ResponseHandler': function('s:StdioUpdateRH', [opts]),
23+
\ 'Initializing': opts.Initializing
2224
\}
23-
call OmniSharp#stdio#Request('/updatebuffer', opts)
25+
call OmniSharp#stdio#Request('/updatebuffer', requestOpts)
2426
else
2527
if !OmniSharp#IsServerRunning() | return | endif
2628
call OmniSharp#py#Eval('updateBuffer()')
2729
call OmniSharp#py#CheckForError()
28-
if has_key(cb, 'Callback')
29-
call cb.Callback()
30+
if has_key(opts, 'Callback')
31+
call opts.Callback()
3032
endif
3133
endif
3234
endif

autoload/OmniSharp/actions/signature.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function! s:StdioSignatureHelpRH(Callback, seq, opts, response) abort
9797
if has_key(a:opts, 'ForCompleteMethod') && !g:OmniSharp_want_snippet
9898
" Because of our 'falsified' request with an extra '(', re-synchronise the
9999
" server's version of the buffer with the actual buffer contents.
100-
call OmniSharp#actions#buffer#Update(0, 0, 1)
100+
call OmniSharp#actions#buffer#Update({'SendBuffer': 1})
101101
endif
102102
call a:Callback(a:response.Body)
103103
endfunction

autoload/OmniSharp/buffer.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ function! OmniSharp#buffer#Initialize(job, bufnr, command, opts) abort
1010
let a:job.pending_requests[a:bufnr][a:command] = a:opts
1111
if has_key(OmniSharp#GetHost(a:bufnr), 'initializing') | return | endif
1212
let host.initializing = 1
13-
let Callback = function('s:CBInitialize', [a:job, a:bufnr, host])
14-
call OmniSharp#actions#buffer#Update(Callback, 1)
13+
call OmniSharp#actions#buffer#Update({
14+
\ 'Callback': function('s:CBInitialize', [a:job, a:bufnr, host]),
15+
\ 'Initializing': 1
16+
\})
1517
endfunction
1618

1719
function! s:CBInitialize(job, bufnr, host) abort

ftplugin/cs/OmniSharp.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ endif
1515
augroup OmniSharp_FileType
1616
autocmd! * <buffer>
1717

18-
autocmd BufEnter,BufLeave <buffer>
18+
autocmd BufEnter <buffer>
19+
\ if !pumvisible() |
20+
\ call OmniSharp#actions#buffer#Update({'SendBuffer': 1}) |
21+
\ endif
22+
autocmd BufLeave <buffer>
1923
\ if !pumvisible() |
2024
\ call OmniSharp#actions#buffer#Update() |
2125
\ endif

0 commit comments

Comments
 (0)