Skip to content

Commit

Permalink
Merge pull request #2266 from bhcleek/lsp/originating-winid
Browse files Browse the repository at this point in the history
lsp: set winid before calling handlers
  • Loading branch information
bhcleek authored May 5, 2019
2 parents df3d5dd + a2eb741 commit 7db9eec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions autoload/go/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,27 @@ function! s:newlsp() abort
try
let l:handler = self.handlers[l:response.id]

let l:winid = win_getid(winnr())
" Always set the active window to the window that was active when
" the request was sent. Among other things, this makes sure that
" the correct window's location list will be populated when the
" list type is 'location' and the user has moved windows since
" sending the reques.
call win_gotoid(l:handler.winid)

if has_key(l:response, 'error')
call l:handler.requestComplete(0)
if has_key(l:handler, 'error')
call call(l:handler.error, [l:response.error.message])
else
call go#util#EchoError(l:response.error.message)
endif
call win_gotoid(l:winid)
return
endif
call l:handler.requestComplete(1)
call call(l:handler.handleResult, [l:response.result])
call win_gotoid(l:winid)
finally
call remove(self.handlers, l:response.id)
endtry
Expand Down

0 comments on commit 7db9eec

Please sign in to comment.