Skip to content

Commit ba9e9b5

Browse files
jerdna-regeizprabirshrestha
authored andcommitted
Fix float position with g:lsp_preview_keep_focus=0 (#419)
1 parent d848083 commit ba9e9b5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

autoload/lsp/ui/vim/output.vim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,8 @@ function! lsp#ui#vim#output#preview(data) abort
202202
let l:bufferlines = line('$')
203203
let l:maxwidth = max(map(getline(1, '$'), 'strdisplaywidth(v:val)'))
204204

205-
if g:lsp_preview_keep_focus
206-
" restore focus to the previous window
207-
call win_gotoid(l:current_window_id)
208-
endif
205+
" restore focus to the previous window
206+
call win_gotoid(l:current_window_id)
209207

210208
echo ''
211209

@@ -216,6 +214,11 @@ function! lsp#ui#vim#output#preview(data) abort
216214
endif
217215
doautocmd User lsp_float_opened
218216
endif
217+
218+
if !g:lsp_preview_keep_focus
219+
" set the focus to the preview window
220+
call win_gotoid(s:winid)
221+
endif
219222
return ''
220223
endfunction
221224

0 commit comments

Comments
 (0)