Skip to content

Commit

Permalink
Always use callback is called after buffer#Valid()
Browse files Browse the repository at this point in the history
  • Loading branch information
nickspoons committed Oct 13, 2023
1 parent 504c54e commit f190d9c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions autoload/OmniSharp/actions/buffer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ set cpoptions&vim
" SendBuffer: flag indicating that the buffer contents should be sent,
" regardless of &modified status or b:changedtick
function! OmniSharp#actions#buffer#Update(...) abort
if !OmniSharp#buffer#Valid() | return | endif
let opts = a:0 ? a:1 : {}
let opts.Initializing = get(opts, 'Initializing', 0)
let opts.SendBuffer = opts.Initializing || get(opts, 'SendBuffer', 0)
let bufnr = get(opts, 'bufnr', bufnr('%'))
let lasttick = get(b:, 'OmniSharp_UpdateChangeTick', -1)
if opts.SendBuffer || b:changedtick != lasttick
if OmniSharp#buffer#Valid(bufnr) && opts.SendBuffer || b:changedtick != lasttick
let b:OmniSharp_UpdateChangeTick = b:changedtick
if g:OmniSharp_server_stdio
let requestOpts = {
Expand Down
3 changes: 2 additions & 1 deletion autoload/OmniSharp/actions/diagnostics.vim
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ function! OmniSharp#actions#diagnostics#StdioCheck(bufnr, Callback) abort
" and does not need to be updated, the `/codecheck` request occurs
" immediately.
call OmniSharp#actions#buffer#Update({
\ 'Callback': function('s:StdioCheck', [a:bufnr, a:Callback])
\ 'Callback': function('s:StdioCheck', [a:bufnr, a:Callback]),
\ 'bufnr': a:bufnr
\})
endfunction

Expand Down
3 changes: 2 additions & 1 deletion autoload/OmniSharp/buffer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function! OmniSharp#buffer#Initialize(job, bufnr, command, opts) abort
if has_key(OmniSharp#GetHost(a:bufnr), 'initializing') | return | endif
let host.initializing = 1
call OmniSharp#actions#buffer#Update({
\ 'bufnr': a:bufnr,
\ 'Callback': function('s:CBInitialize', [a:job, a:bufnr, host]),
\ 'Initializing': 1
\})
Expand Down Expand Up @@ -156,7 +157,7 @@ function! OmniSharp#buffer#Update(responseBody) abort
endfunction

function! OmniSharp#buffer#Valid(...) abort
let bufnr = bufnr(a:0 ? a:1 : '%')
let bufnr = a:0 ? a:1 : bufnr('%')
let bufname = fnamemodify(bufname(bufnr), ':p')
let buftype = a:0 ? getbufvar(a:1, '&buftype') : &buftype
return buftype !=# 'nofile' && bufname !=# ''
Expand Down

0 comments on commit f190d9c

Please sign in to comment.