feat: add auto_resize config for hover window

This commit is contained in:
JuanZoran
2023-03-15 11:44:01 +08:00
parent e5f0f2bf34
commit da8b037523
3 changed files with 8 additions and 11 deletions

View File

@ -128,7 +128,6 @@ function M:wait(tbl, name, timeout)
buffer[1] = ''
end
---Display Result in hover window
---@param _ TransData
---@param result TransResult
@ -148,8 +147,8 @@ function M:process(_, result)
local window = self.window
local display_size = Trans.util.display_size(self.buffer:lines(), opts.width)
if window and window:is_valid() then
-- win:adjust_height(opts.height)
display_size.width = math.min(opts.width, display_size.width + 6)
---@diagnostic disable-next-line: assign-type-mismatch
display_size.width = opts.auto_resize and math.min(opts.width, display_size.width + opts.padding) or nil
window:resize(display_size)
else
window = self:init_window {