@@ -1582,15 +1582,7 @@ function Sidebar:setup_window_navigation(container)
15821582end
15831583
15841584function Sidebar :resize ()
1585- for _ , container in pairs (self .containers ) do
1586- if container .winid and api .nvim_win_is_valid (container .winid ) then
1587- if self .is_in_full_view then
1588- api .nvim_win_set_width (container .winid , vim .o .columns - 1 )
1589- else
1590- api .nvim_win_set_width (container .winid , Config .get_window_width ())
1591- end
1592- end
1593- end
1585+ self :adjust_layout ()
15941586 self :render_result ()
15951587 self :render_input ()
15961588 self :render_selected_code ()
@@ -2921,15 +2913,14 @@ function Sidebar:create_input_container()
29212913 end
29222914
29232915 local function get_size ()
2924- if self :get_layout () == " vertical" then return {
2925- height = Config . windows . input . height ,
2926- } end
2927-
2928- local selected_code_container_height = self : get_selected_code_container_height ()
2916+ if self :get_layout () == " vertical" then
2917+ return {
2918+ height = Config . windows . input . height ,
2919+ }
2920+ end
29292921
29302922 return {
2931- width = " 40%" ,
2932- height = math.max (1 , api .nvim_win_get_height (self .containers .result .winid ) - selected_code_container_height ),
2923+ width = tostring (Config .windows .input .width_percentage ) .. " %" ,
29332924 }
29342925 end
29352926
@@ -3135,14 +3126,19 @@ end
31353126function Sidebar :get_result_container_width ()
31363127 if self :get_layout () == " vertical" then return math.floor (Config .windows .width / 100 * vim .o .columns ) end
31373128
3138- return math.max (1 , api .nvim_win_get_width (self .code .winid ))
3129+ local width = math.max (1 , api .nvim_win_get_width (self .code .winid ))
3130+ if Utils .is_valid_container (self .containers .input , true ) then
3131+ local input_width = math.floor (width * (Config .windows .input .width_percentage / 100 ))
3132+ return width - input_width
3133+ end
3134+ return width
31393135end
31403136
31413137function Sidebar :adjust_result_container_layout ()
31423138 local width = self :get_result_container_width ()
31433139 local height = self :get_result_container_height ()
31443140
3145- if self .is_in_full_view then width = vim .o .columns - 1 end
3141+ if self .is_in_full_view and self : get_layout () == " vertical " then width = vim .o .columns - 1 end
31463142
31473143 api .nvim_win_set_width (self .containers .result .winid , width )
31483144 api .nvim_win_set_height (self .containers .result .winid , height )
@@ -3265,6 +3261,18 @@ function Sidebar:adjust_selected_files_container_layout()
32653261 api .nvim_win_set_height (self .containers .selected_files .winid , win_height )
32663262end
32673263
3264+ function Sidebar :adjust_input_container_layout ()
3265+ if not Utils .is_valid_container (self .containers .input , true ) then return end
3266+
3267+ if self :get_layout () == " vertical" then
3268+ api .nvim_win_set_height (self .containers .input .winid , Config .windows .input .height )
3269+ else
3270+ local total_width = math.max (1 , api .nvim_win_get_width (self .code .winid ))
3271+ local input_width = math.floor (total_width * (Config .windows .input .width_percentage / 100 ))
3272+ api .nvim_win_set_width (self .containers .input .winid , input_width )
3273+ end
3274+ end
3275+
32683276function Sidebar :adjust_selected_code_container_layout ()
32693277 if not Utils .is_valid_container (self .containers .selected_code , true ) then return end
32703278
@@ -3493,9 +3501,10 @@ end
34933501
34943502function Sidebar :adjust_layout ()
34953503 self :adjust_result_container_layout ()
3504+ self :adjust_input_container_layout ()
34963505 self :adjust_todos_container_layout ()
34973506 self :adjust_selected_code_container_layout ()
34983507 self :adjust_selected_files_container_layout ()
34993508end
35003509
3501- return Sidebar
3510+ return Sidebar
0 commit comments