Skip to content

Commit d80ee25

Browse files
committed
win_is_valid
1 parent 5b48d52 commit d80ee25

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lua/kide/tools/trans.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ M.translate_float = function(request)
142142
local l = vim.fn.strdisplaywidth(curlines[#curlines])
143143
if l > width and l < max_width then
144144
width = l
145-
vim.api.nvim_win_set_width(win, width)
145+
-- 判断 window 是否可用
146+
if vim.api.nvim_win_is_valid(win) then
147+
vim.api.nvim_win_set_width(win, width)
148+
end
146149
end
147150

148151
-- 判断 buffer 是否可用

0 commit comments

Comments
 (0)