Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not clear lists when jumping to definitions (and enable async for Neovim) #1922

Merged
merged 2 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion autoload/go/def.vim
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ function! go#def#Jump(mode) abort

call extend(cmd, ["definition", fname . ':#' . go#util#OffsetCursor()])

if go#util#has_job()
if go#util#has_job() || has('nvim')
let l:spawn_args = {
\ 'cmd': cmd,
\ 'complete': function('s:jump_to_declaration_cb', [a:mode, bin_name]),
\ 'for': '_',
\ }

if &modified
Expand Down
29 changes: 29 additions & 0 deletions autoload/go/def_test.vim
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,33 @@ func! Test_jump_to_declaration_godef() abort
endtry
endfunc

func! Test_Jump_leaves_lists() abort
try
let filename = 'def/jump.go'
let l:tmp = gotest#load_fixture(l:filename)

let expected = [{'lnum': 10, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'quux'}]

call setloclist(winnr(), copy(expected), 'r' )
call setqflist(copy(expected), 'r' )

let l:bufnr = bufnr('%')
call cursor(6, 3)
call go#def#Jump('')

let start = reltime()
while bufnr('%') == l:bufnr && reltimefloat(reltime(start)) < 10
sleep 100m
endwhile

let actual = getloclist(winnr())
call gotest#assert_quickfix(actual, expected)

let actual = getqflist()
call gotest#assert_quickfix(actual, expected)
finally
call delete(l:tmp, 'rf')
endtry
endfunc

" vim: sw=2 ts=2 et
7 changes: 7 additions & 0 deletions autoload/go/job.vim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ endfunction
" See statusline.vim.
" 'for':
" The g:go_list_type_command key to use to get the error list type to use.
" Errors will not be handled when the value is '_'.
" Defaults to '_job'
" 'errorformat':
" The errorformat string to use when parsing errors. Defaults to
Expand Down Expand Up @@ -184,6 +185,10 @@ function! go#job#Options(args)
let cbs.close_cb = function('s:close_cb', [], state)

function state.show_errors(job, exit_status, data)
if self.for == '_'
return
endif

let l:winid = win_getid(winnr())
" Always set the active window to the window that was active when the job
" was started. Among other things, this makes sure that the correct
Expand Down Expand Up @@ -225,6 +230,8 @@ function! go#job#Options(args)
return
endif

" only open the error window if user was still in the window from which
" the job was started.
if self.winid == l:winid
call go#list#Window(l:listtype, len(errors))
if !self.bang
Expand Down