Skip to content

Commit 68f8889

Browse files
committed
[hj] fix vertical window resizing bug
1 parent 97c2ae9 commit 68f8889

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

lua/rovo-dev/terminal.lua

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ end
151151
--- Configure common window options
152152
--- @param win_id number Window ID to configure
153153
--- @param config table Plugin configuration
154+
--- @param is_vertical boolean|nil Whether this is a vertical split (optional)
154155
--- @private
155-
local function configure_window_options(win_id, config)
156+
local function configure_window_options(win_id, config, is_vertical)
156157
if config.window.hide_numbers then
157158
vim.api.nvim_set_option_value('number', false, { win = win_id })
158159
vim.api.nvim_set_option_value('relativenumber', false, { win = win_id })
@@ -161,6 +162,13 @@ local function configure_window_options(win_id, config)
161162
if config.window.hide_signcolumn then
162163
vim.api.nvim_set_option_value('signcolumn', 'no', { win = win_id })
163164
end
165+
166+
-- Fix window size to prevent automatic resizing when other windows are closed/opened
167+
if is_vertical then
168+
vim.api.nvim_set_option_value('winfixwidth', true, { win = win_id })
169+
else
170+
vim.api.nvim_set_option_value('winfixheight', true, { win = win_id })
171+
end
164172
end
165173

166174
--- Generate buffer name for instance
@@ -210,6 +218,10 @@ local function create_split(position, config, existing_bufnr)
210218
else
211219
vim.cmd('resize ' .. math.floor(vim.o.lines * config.window.split_ratio))
212220
end
221+
222+
-- Configure window options including fixed size for splits
223+
local current_win = vim.api.nvim_get_current_win()
224+
configure_window_options(current_win, config, is_vertical)
213225
end
214226

215227
--- Set up function to force insert mode when entering the Rovo Dev window
@@ -341,8 +353,8 @@ local function create_new_instance(rovo_dev, config, git, instance_id)
341353
local buffer_name = generate_buffer_name(instance_id, config)
342354
vim.api.nvim_buf_set_name(new_bufnr, buffer_name)
343355

344-
-- Configure window options
345-
configure_window_options(win_id, config)
356+
-- Configure window options (floating windows don't need fixed size)
357+
configure_window_options(win_id, config, false)
346358

347359
-- Store buffer number for this instance
348360
rovo_dev.rovo_dev.instances[instance_id] = new_bufnr
@@ -368,7 +380,9 @@ local function create_new_instance(rovo_dev, config, git, instance_id)
368380

369381
-- Configure window options using helper function
370382
local current_win = vim.api.nvim_get_current_win()
371-
configure_window_options(current_win, config)
383+
local is_vertical = config.window.position:match('vsplit')
384+
or config.window.position:match('vertical')
385+
configure_window_options(current_win, config, is_vertical)
372386

373387
-- Store buffer number for this instance
374388
rovo_dev.rovo_dev.instances[instance_id] = vim.fn.bufnr('%')

0 commit comments

Comments
 (0)