|
1 | 1 | let s:save_cpo = &cpoptions |
2 | 2 | set cpoptions&vim |
3 | 3 |
|
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 |
6 | 8 | " 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, |
9 | 11 | " regardless of &modified status or b:changedtick |
10 | 12 | 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) |
14 | 16 | if bufname('%') ==# '' || OmniSharp#FugitiveCheck() | return | endif |
15 | 17 | let lasttick = get(b:, 'OmniSharp_UpdateChangeTick', -1) |
16 | | - if initializing || sendBuffer || b:changedtick != lasttick |
| 18 | + if opts.SendBuffer || b:changedtick != lasttick |
17 | 19 | let b:OmniSharp_UpdateChangeTick = b:changedtick |
18 | 20 | 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 |
22 | 24 | \} |
23 | | - call OmniSharp#stdio#Request('/updatebuffer', opts) |
| 25 | + call OmniSharp#stdio#Request('/updatebuffer', requestOpts) |
24 | 26 | else |
25 | 27 | if !OmniSharp#IsServerRunning() | return | endif |
26 | 28 | call OmniSharp#py#Eval('updateBuffer()') |
27 | 29 | call OmniSharp#py#CheckForError() |
28 | | - if has_key(cb, 'Callback') |
29 | | - call cb.Callback() |
| 30 | + if has_key(opts, 'Callback') |
| 31 | + call opts.Callback() |
30 | 32 | endif |
31 | 33 | endif |
32 | 34 | endif |
|
0 commit comments