Skip to content

Commit f190d9c

Browse files
committed
Always use callback is called after buffer#Valid()
1 parent 504c54e commit f190d9c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

autoload/OmniSharp/actions/buffer.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ set cpoptions&vim
1010
" SendBuffer: flag indicating that the buffer contents should be sent,
1111
" regardless of &modified status or b:changedtick
1212
function! OmniSharp#actions#buffer#Update(...) abort
13-
if !OmniSharp#buffer#Valid() | return | endif
1413
let opts = a:0 ? a:1 : {}
1514
let opts.Initializing = get(opts, 'Initializing', 0)
1615
let opts.SendBuffer = opts.Initializing || get(opts, 'SendBuffer', 0)
16+
let bufnr = get(opts, 'bufnr', bufnr('%'))
1717
let lasttick = get(b:, 'OmniSharp_UpdateChangeTick', -1)
18-
if opts.SendBuffer || b:changedtick != lasttick
18+
if OmniSharp#buffer#Valid(bufnr) && opts.SendBuffer || b:changedtick != lasttick
1919
let b:OmniSharp_UpdateChangeTick = b:changedtick
2020
if g:OmniSharp_server_stdio
2121
let requestOpts = {

autoload/OmniSharp/actions/diagnostics.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ function! OmniSharp#actions#diagnostics#StdioCheck(bufnr, Callback) abort
5555
" and does not need to be updated, the `/codecheck` request occurs
5656
" immediately.
5757
call OmniSharp#actions#buffer#Update({
58-
\ 'Callback': function('s:StdioCheck', [a:bufnr, a:Callback])
58+
\ 'Callback': function('s:StdioCheck', [a:bufnr, a:Callback]),
59+
\ 'bufnr': a:bufnr
5960
\})
6061
endfunction
6162

autoload/OmniSharp/buffer.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function! OmniSharp#buffer#Initialize(job, bufnr, command, opts) abort
1111
if has_key(OmniSharp#GetHost(a:bufnr), 'initializing') | return | endif
1212
let host.initializing = 1
1313
call OmniSharp#actions#buffer#Update({
14+
\ 'bufnr': a:bufnr,
1415
\ 'Callback': function('s:CBInitialize', [a:job, a:bufnr, host]),
1516
\ 'Initializing': 1
1617
\})
@@ -156,7 +157,7 @@ function! OmniSharp#buffer#Update(responseBody) abort
156157
endfunction
157158

158159
function! OmniSharp#buffer#Valid(...) abort
159-
let bufnr = bufnr(a:0 ? a:1 : '%')
160+
let bufnr = a:0 ? a:1 : bufnr('%')
160161
let bufname = fnamemodify(bufname(bufnr), ':p')
161162
let buftype = a:0 ? getbufvar(a:1, '&buftype') : &buftype
162163
return buftype !=# 'nofile' && bufname !=# ''

0 commit comments

Comments
 (0)