@@ -84,8 +84,7 @@ describe('input_window', function()
8484 output_lines = lines
8585 end
8686
87- output_window .clear = function ()
88- end
87+ output_window .clear = function () end
8988
9089 vim .system = function (cmd , opts , callback )
9190 vim .schedule (function ()
@@ -358,4 +357,73 @@ describe('input_window', function()
358357 state .windows = nil
359358 end )
360359 end )
360+
361+ describe (' auto-show when hidden' , function ()
362+ local input_buf , output_buf , input_win , output_win
363+
364+ before_each (function ()
365+ input_buf = vim .api .nvim_create_buf (false , true )
366+ output_buf = vim .api .nvim_create_buf (false , true )
367+ input_win = vim .api .nvim_open_win (input_buf , true , {
368+ relative = ' editor' ,
369+ width = 80 ,
370+ height = 10 ,
371+ row = 0 ,
372+ col = 0 ,
373+ })
374+ output_win = vim .api .nvim_open_win (output_buf , false , {
375+ relative = ' editor' ,
376+ width = 80 ,
377+ height = 10 ,
378+ row = 11 ,
379+ col = 0 ,
380+ })
381+
382+ state .windows = {
383+ input_buf = input_buf ,
384+ input_win = input_win ,
385+ output_buf = output_buf ,
386+ output_win = output_win ,
387+ }
388+ end )
389+
390+ after_each (function ()
391+ pcall (vim .api .nvim_win_close , input_win , true )
392+ pcall (vim .api .nvim_win_close , output_win , true )
393+ pcall (vim .api .nvim_buf_delete , input_buf , { force = true })
394+ pcall (vim .api .nvim_buf_delete , output_buf , { force = true })
395+ state .windows = nil
396+ input_window ._hidden = false
397+ end )
398+
399+ it (' should auto-show when set_content is called with non-empty content while hidden' , function ()
400+ input_window ._hidden = true
401+ pcall (vim .api .nvim_win_close , input_win , true )
402+ state .windows .input_win = nil
403+
404+ input_window .set_content (' test content' )
405+
406+ assert .is_false (input_window ._hidden )
407+ end )
408+
409+ it (' should not auto-show when set_content is called with empty content while hidden' , function ()
410+ input_window ._hidden = true
411+ pcall (vim .api .nvim_win_close , input_win , true )
412+ state .windows .input_win = nil
413+
414+ input_window .set_content (' ' )
415+
416+ assert .is_true (input_window ._hidden )
417+ end )
418+
419+ it (' should auto-show when _append_to_input is called while hidden' , function ()
420+ input_window ._hidden = true
421+ pcall (vim .api .nvim_win_close , input_win , true )
422+ state .windows .input_win = nil
423+
424+ input_window ._append_to_input (' appended content' )
425+
426+ assert .is_false (input_window ._hidden )
427+ end )
428+ end )
361429end )
0 commit comments