@@ -262,15 +262,15 @@ function! s:GetVar(...) abort
262
262
endif
263
263
endfunction
264
264
265
- function ! s: CloseFloatingHoverAfterCursorMove (bufname , opened) abort
265
+ function ! s: CloseFloatingHoverAfterCursorMove (win_id , opened) abort
266
266
if getpos (' .' ) == a: opened
267
267
" Just after opening floating window, CursorMoved event is run.
268
268
" To avoid closing floating window immediately, check the cursor
269
269
" was really moved
270
270
return
271
271
endif
272
272
autocmd ! plugin - LC- neovim- close - hover
273
- let winnr = bufwinnr ( bufnr ( a: bufname ) )
273
+ let winnr = win_id2win ( a: win_id )
274
274
if winnr == -1
275
275
return
276
276
endif
@@ -279,7 +279,7 @@ endfunction
279
279
280
280
function ! s: CloseFloatingHoverAfterEnterAnotherWin (win_id) abort
281
281
let winnr = win_id2win (a: win_id )
282
- if winnr == 0
282
+ if winnr == -1
283
283
" Float window was already closed
284
284
autocmd ! plugin - LC- neovim- close - hover
285
285
return
@@ -302,13 +302,6 @@ function! s:OpenHoverPreview(bufname, lines, filetype) abort
302
302
if s: FLOAT_WINDOW_AVAILABLE
303
303
let pos = getpos (' .' )
304
304
305
- " Unlike preview window, :pclose does not close window. Instead, close
306
- " hover window automatically when cursor is moved.
307
- let call_after_move = printf (' <SID>CloseFloatingHoverAfterCursorMove("%s", %s)' , a: bufname , string (pos))
308
- augroup plugin - LC- neovim- close - hover
309
- execute ' autocmd CursorMoved,CursorMovedI,InsertEnter <buffer> call ' . call_after_move
310
- augroup END
311
-
312
305
" Calculate width and height and give margin to lines
313
306
let width = 0
314
307
for index in range (len (lines ))
@@ -371,7 +364,13 @@ function! s:OpenHoverPreview(bufname, lines, filetype) abort
371
364
wincmd p
372
365
373
366
if s: FLOAT_WINDOW_AVAILABLE
374
- execute ' autocmd WinEnter * call <SID>CloseFloatingHoverAfterEnterAnotherWin(' . float_win_id . ' )'
367
+ " Unlike preview window, :pclose does not close window. Instead, close
368
+ " hover window automatically when cursor is moved.
369
+ let call_after_move = printf (' <SID>CloseFloatingHoverAfterCursorMove(%d, %s)' , float_win_id, string (pos))
370
+ augroup plugin - LC- neovim- close - hover
371
+ execute ' autocmd CursorMoved,CursorMovedI,InsertEnter <buffer> call ' . call_after_move
372
+ execute ' autocmd WinEnter * call <SID>CloseFloatingHoverAfterEnterAnotherWin(' . float_win_id . ' )'
373
+ augroup END
375
374
endif
376
375
endfunction
377
376
0 commit comments