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.
This commit is contained in:
mamekoro
2024-12-08 20:52:27 +09:00
committed by GitHub
parent 365593534e
commit 1b97f8f954

View File

@@ -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")