From 1b97f8f954d74c46061bf289b6cea9232484c12c Mon Sep 17 00:00:00 2001 From: mamekoro <86554319+mamekoro@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:52:27 +0900 Subject: [PATCH] fix: set window height only when cfg.position is bottom or top (#14) According to `:help topleft` and `:help botright`, these commands creates a window with the full height of the Vim window when used with `vnew`, so we don't need to update the `height` variable when using these commands. --- lua/docs-view.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/docs-view.lua b/lua/docs-view.lua index bf01f3d..37151f7 100644 --- a/lua/docs-view.lua +++ b/lua/docs-view.lua @@ -65,16 +65,16 @@ M.toggle = function() width = vim.api.nvim_win_get_height(prev_win) elseif cfg.position == "left" then vim.api.nvim_command("topleft vnew") - height = vim.api.nvim_win_get_height(prev_win) else vim.api.nvim_command("botright vnew") - height = vim.api.nvim_win_get_height(prev_win) end win = vim.api.nvim_get_current_win() buf = vim.api.nvim_get_current_buf() - vim.api.nvim_win_set_height(win, math.ceil(height)) + if cfg.position == "bottom" or cfg.position == "top" then + vim.api.nvim_win_set_height(win, math.ceil(height)) + end vim.api.nvim_win_set_width(win, math.ceil(width)) vim.api.nvim_buf_set_name(buf, "Docs View")