Skip to content

Commit 67a49fa

Browse files
committed
Restore correct buffer settings when window focus changed
References: #350
1 parent 63e4570 commit 67a49fa

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

autoload/dispatch.vim

+7-6
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,11 @@ function! s:current_compiler(...) abort
361361
return get((empty(&l:makeprg) ? g: : b:), 'current_compiler', a:0 ? a:1 : '')
362362
endfunction
363363

364-
function! s:set_current_compiler(name) abort
365-
if empty(a:name)
364+
function! s:set_current_compiler(name, ...) abort
365+
if empty(a:name) && (!a:0 || a:1 ==# bufnr(''))
366366
unlet! b:current_compiler
367367
else
368-
let b:current_compiler = a:name
368+
call setbufvar(a:bufnr, 'current_compiler', a:name)
369369
endif
370370
endfunction
371371

@@ -925,6 +925,7 @@ function! dispatch#compile_command(bang, args, count, mods, ...) abort
925925
let compiler = get(b:, 'current_compiler', '')
926926
let after = ''
927927
let cd = s:cd_command()
928+
let bufnr = bufnr('')
928929
try
929930
call s:set_current_compiler(get(request, 'compiler', ''))
930931
let v:lnum = a:count > 0 ? a:count : 0
@@ -980,9 +981,9 @@ function! dispatch#compile_command(bang, args, count, mods, ...) abort
980981
finally
981982
exe s:doautocmd('QuickFixCmdPost dispatch-make')
982983
let v:lnum = lnum
983-
let &l:efm = efm
984-
let &l:makeprg = makeprg
985-
call s:set_current_compiler(compiler)
984+
call setbufvar(bufnr, '&efm', efm)
985+
call setbufvar(bufnr, '&makeprg', makeprg)
986+
call s:set_current_compiler(compiler, bufnr)
986987
if exists('cwd')
987988
execute cd dispatch#fnameescape(cwd)
988989
endif

0 commit comments

Comments
 (0)