Skip to content

Commit

Permalink
lsp: set winid before calling handlers
Browse files Browse the repository at this point in the history
Set the active window to the window that was active when the request was
made before processing the response so that handlers can set the correct
statusline, use the correct location list, etc.
  • Loading branch information
bhcleek committed May 5, 2019
1 parent df3d5dd commit a2eb741
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 a2eb741

Please sign in to comment.