Skip to content

Commit

Permalink
fix: ensure help window width is an int
Browse files Browse the repository at this point in the history
Problem:

The help window causes an error when calling `vim.api.nvim_open_win`
because the width being passed is not an integer.

Neovim's `vim.api.nvim_open_win` function requires that the width and
height be specified in whole integers.

The width is being calculated through a division operation causing it to
potentially be a number that is not an int.

Solution:

Floor the calculation of the help window width so the width is always
rounded down to the nearest integer and can thus be used with
`vim.api.nvim_open_win`.
  • Loading branch information
PriceHiller authored and NTBBloodbath committed Mar 18, 2024
1 parent b97d394 commit af7b2ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lua/rest-nvim/result/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function help.open()
end

-- Help window sizing and positioning
local width = vim.api.nvim_win_get_width(winnr) / 2
local width = math.floor(vim.api.nvim_win_get_width(winnr) / 2)
local height = 8

local col = vim.api.nvim_win_get_width(winnr) - width - 4
Expand Down

0 comments on commit af7b2ea

Please sign in to comment.