@@ -99,24 +99,23 @@ describe('ui zoom state', function()
9999 end )
100100
101101 describe (' input_window.update_dimensions' , function ()
102- it (' uses default window_width when not zoomed' , function ()
102+ it (' does not change input window width' , function ()
103+ local original_width = vim .api .nvim_win_get_width (windows .input_win )
104+
103105 input_window .update_dimensions (windows )
104106
105- local expected_width = math.floor (config .ui .window_width * vim .o .columns )
106107 local actual_width = vim .api .nvim_win_get_width (windows .input_win )
107-
108- assert .equals (expected_width , actual_width )
108+ assert .equals (original_width , actual_width )
109109 end )
110110
111- it (' uses zoom_width when zoomed' , function ()
111+ it (' does not change input window width when zoomed' , function ()
112112 state .pre_zoom_width = 80
113+ local original_width = vim .api .nvim_win_get_width (windows .input_win )
113114
114115 input_window .update_dimensions (windows )
115116
116- local expected_width = math.floor (config .ui .zoom_width * vim .o .columns )
117117 local actual_width = vim .api .nvim_win_get_width (windows .input_win )
118-
119- assert .equals (expected_width , actual_width )
118+ assert .equals (original_width , actual_width )
120119 end )
121120
122121 it (' preserves zoom state after update_dimensions' , function ()
@@ -267,4 +266,51 @@ describe('ui zoom state', function()
267266 assert .is_nil (state .pre_zoom_width )
268267 end )
269268 end )
269+
270+ describe (' window width persistence' , function ()
271+ it (' saves width ratio when hiding windows' , function ()
272+ local custom_width = 100
273+ vim .api .nvim_win_set_width (windows .output_win , custom_width )
274+ ui .hide_visible_windows (windows )
275+
276+ local expected_ratio = custom_width / vim .o .columns
277+ assert .is_not_nil (state .last_window_width_ratio )
278+ assert .near (expected_ratio , state .last_window_width_ratio , 0.001 )
279+ end )
280+
281+ it (' does not save width in dialog mode (position=current)' , function ()
282+ local original_position = config .ui .position
283+ config .ui .position = ' current'
284+ state .last_window_width_ratio = nil
285+
286+ ui .hide_visible_windows (windows )
287+ assert .is_nil (state .last_window_width_ratio )
288+
289+ config .ui .position = original_position
290+ end )
291+
292+ it (' uses saved width ratio in output_window.update_dimensions' , function ()
293+ local saved_ratio = 0.6
294+ windows .saved_width_ratio = saved_ratio
295+
296+ output_window .update_dimensions (windows )
297+
298+ local expected_width = math.floor (saved_ratio * vim .o .columns )
299+ local actual_width = vim .api .nvim_win_get_width (windows .output_win )
300+ assert .equals (expected_width , actual_width )
301+ assert .is_nil (windows .saved_width_ratio )
302+ end )
303+
304+ it (' prefers saved width over zoom width' , function ()
305+ state .pre_zoom_width = 80
306+ local saved_ratio = 0.5
307+ windows .saved_width_ratio = saved_ratio
308+
309+ output_window .update_dimensions (windows )
310+
311+ local expected_width = math.floor (saved_ratio * vim .o .columns )
312+ local actual_width = vim .api .nvim_win_get_width (windows .output_win )
313+ assert .equals (expected_width , actual_width )
314+ end )
315+ end )
270316end )
0 commit comments