@@ -210,52 +210,102 @@ def test_languageClient_registerHandlers(nvim):
210
210
# assertRetry(lambda: len(nvim.funcs.getqflist()) == 0)
211
211
212
212
213
- def test_textDocument_hover_float_window (nvim ):
214
- if not nvim .funcs .exists ('*nvim_open_win' ):
215
- pytest .skip ('Neovim 0.3.0 or earlier does not support floating window' )
216
-
217
- def _open_float_window ():
218
- nvim .funcs .cursor (13 , 19 )
219
- pos = nvim .funcs .getpos ('.' )
220
- nvim .funcs .LanguageClient_textDocument_hover ()
221
- time .sleep (1 )
222
- return pos
213
+ def _open_float_window (nvim ):
214
+ nvim .funcs .cursor (13 , 19 )
215
+ pos = nvim .funcs .getpos ('.' )
216
+ nvim .funcs .LanguageClient_textDocument_hover ()
217
+ time .sleep (1 )
218
+ return pos
219
+
220
+
221
+ def test_textDocument_hover_float_window_closed_on_cursor_moved (nvim ):
222
+ if not nvim .funcs .exists ("*nvim_open_win" ):
223
+ pytest .skip ("Neovim 0.3.0 or earlier does not support floating window" )
223
224
224
225
nvim .command ("edit! {}" .format (PATH_INDEXJS ))
225
226
time .sleep (1 )
226
227
227
228
buf = nvim .current .buffer
228
229
229
- pos = _open_float_window ()
230
+ pos = _open_float_window (nvim )
230
231
231
232
float_buf = next (
232
- b for b in nvim .buffers if b .name .endswith (' __LanguageClient__' ))
233
+ b for b in nvim .buffers if b .name .endswith (" __LanguageClient__" ))
233
234
234
235
# Check if float window is open
235
236
float_winnr = nvim .funcs .bufwinnr (float_buf .number )
236
237
assert float_winnr > 0
237
238
238
239
# Check if cursor is not moved
239
240
assert buf .number == nvim .current .buffer .number
240
- assert pos == nvim .funcs .getpos ('.' )
241
+ assert pos == nvim .funcs .getpos ("." )
241
242
242
243
# Move cursor to left
243
244
nvim .funcs .cursor (13 , 17 )
244
245
245
246
# Check float window buffer was closed by CursorMoved
246
247
assert all (
247
- b for b in nvim .buffers if not b .name .endswith ('__LanguageClient__' ))
248
+ b for b in nvim .buffers if not b .name .endswith ("__LanguageClient__" ))
249
+
250
+
251
+ def test_textDocument_hover_float_window_closed_on_entering_window (nvim ):
252
+ if not nvim .funcs .exists ("*nvim_open_win" ):
253
+ pytest .skip ("Neovim 0.3.0 or earlier does not support floating window" )
254
+
255
+ nvim .command ("edit! {}" .format (PATH_INDEXJS ))
256
+ time .sleep (1 )
248
257
249
258
win_id = nvim .funcs .win_getid ()
250
- nvim .command ('split' )
251
- assert win_id != nvim .funcs .win_getid ()
259
+ nvim .command ("split" )
260
+ try :
261
+ assert win_id != nvim .funcs .win_getid ()
252
262
253
- _open_float_window ()
263
+ _open_float_window (nvim )
264
+ assert win_id != nvim .funcs .win_getid ()
254
265
255
- # Move to another window
256
- nvim .funcs .win_gotoid (win_id )
257
- assert win_id == nvim .funcs .win_getid ()
266
+ # Move to another window
267
+ nvim .funcs .win_gotoid (win_id )
268
+ assert win_id == nvim .funcs .win_getid ()
258
269
259
- # Check float window buffer was closed by WinEnter
260
- assert all (
261
- b for b in nvim .buffers if not b .name .endswith ('__LanguageClient__' ))
270
+ # Check float window buffer was closed by BufEnter
271
+ assert all (
272
+ b for b in nvim .buffers
273
+ if not b .name .endswith ("__LanguageClient__" ))
274
+ finally :
275
+ nvim .command ("close!" )
276
+
277
+
278
+ def test_textDocument_hover_float_window_closed_on_switching_to_buffer (nvim ):
279
+ if not nvim .funcs .exists ("*nvim_open_win" ):
280
+ pytest .skip ("Neovim 0.3.0 or earlier does not support floating window" )
281
+
282
+ # Create a new buffer
283
+ nvim .command ("enew!" )
284
+
285
+ another_bufnr = nvim .current .buffer .number
286
+
287
+ try :
288
+ nvim .command ("edit! {}" .format (PATH_INDEXJS ))
289
+ time .sleep (1 )
290
+
291
+ source_bufnr = nvim .current .buffer .number
292
+
293
+ _open_float_window (nvim )
294
+
295
+ float_buf = next (
296
+ b for b in nvim .buffers if b .name .endswith ("__LanguageClient__" ))
297
+ float_winnr = nvim .funcs .bufwinnr (float_buf .number )
298
+ assert float_winnr > 0
299
+
300
+ assert nvim .current .buffer .number == source_bufnr
301
+
302
+ # Move to another buffer within the same window
303
+ nvim .command ("buffer {}" .format (another_bufnr ))
304
+ assert nvim .current .buffer .number == another_bufnr
305
+
306
+ # Check float window buffer was closed by BufEnter
307
+ assert all (
308
+ b for b in nvim .buffers
309
+ if not b .name .endswith ("__LanguageClient__" ))
310
+ finally :
311
+ nvim .command ("bdelete! {}" .format (another_bufnr ))
0 commit comments