Skip to content

Commit d826e9b

Browse files
committed
fix(input_window): disable dynamic height if min_height == max_height
1 parent 954123c commit d826e9b

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

lua/opencode/ui/input_window.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ local function get_winbar_height(windows)
3838
return 0
3939
end
4040

41+
local dynamic_height_enabled = config.ui.input.min_height ~= config.ui.input.max_height
42+
43+
---@return integer
4144
local function calculate_height(windows)
4245
local total_height = vim.api.nvim_get_option_value('lines', {})
46+
if not dynamic_height_enabled then
47+
return math.floor(total_height * config.ui.input.min_height)
48+
end
4349
local min_height = math.max(1, math.floor(total_height * config.ui.input.min_height))
4450
local max_height = math.max(min_height, math.floor(total_height * config.ui.input.max_height))
4551
local content_height = get_content_height(windows) + get_winbar_height(windows)
@@ -274,7 +280,6 @@ function M.setup(windows)
274280
if config.ui.position ~= 'current' then
275281
set_win_option('winfixbuf', true, windows)
276282
end
277-
set_win_option('winfixheight', true, windows)
278283
set_win_option('winfixwidth', true, windows)
279284

280285
M.update_dimensions(windows)
@@ -295,18 +300,21 @@ function M.update_dimensions(windows)
295300
end
296301

297302
function M.schedule_resize(windows)
303+
if not dynamic_height_enabled then
304+
return
305+
end
298306
windows = windows or state.windows
299307
if not M.mounted(windows) or M._resize_scheduled then
300308
return
301309
end
302310

303311
M._resize_scheduled = true
304-
vim.schedule(function()
312+
vim.defer_fn(function()
305313
M._resize_scheduled = false
306314
if M.mounted(windows) then
307315
M.update_dimensions(windows)
308316
end
309-
end)
317+
end, 1000 / 60) -- debounce to 60 FPS
310318
end
311319

312320
function M.refresh_placeholder(windows, input_lines)

0 commit comments

Comments
 (0)