Skip to content

Commit 7875178

Browse files
committed
closed
1 parent 2c54f88 commit 7875178

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lua/kide/tools/ai.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,21 @@ M.translate_float = function(request)
149149
style = "minimal", -- 最小化样式
150150
border = "rounded", -- 窗口边框样式
151151
}
152-
local buf = vim.api.nvim_create_buf(false, true)
153-
vim.api.nvim_buf_set_keymap(buf, "n", "q", "<cmd>q<CR>", { noremap = true, silent = true })
152+
local buf = vim.api.nvim_create_buf(false, false)
154153
local win = vim.api.nvim_open_win(buf, true, opts)
155154
vim.wo[win].number = false -- 不显示行号
156155

156+
local closed = false
157+
vim.keymap.set("n", "q", function()
158+
closed = true
159+
vim.api.nvim_win_close(win, true)
160+
end, { noremap = true, silent = true, buffer = buf })
161+
157162
local curlines = 0
158163
local callback = function(data)
164+
if closed then
165+
return
166+
end
159167
-- 判断是否换行符
160168
if data == "\n" then
161169
curlines = 0

0 commit comments

Comments
 (0)