Skip to content

Commit bc644cd

Browse files
m4dd0cdeathbeam
authored andcommitted
fix(validation): Ensure If the erminal buffer is excluded from #buffers and #buffer
This prevents unsolicited text from being included in the CopilotChat context window.
1 parent a89f5f1 commit bc644cd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lua/CopilotChat/utils.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,15 @@ function M.kv_list(tbl)
210210
end
211211

212212
--- Check if a buffer is valid
213+
--- Check if the buffer is not a terminal
213214
---@param bufnr number? The buffer number
214215
---@return boolean
215216
function M.buf_valid(bufnr)
216-
return bufnr and vim.api.nvim_buf_is_valid(bufnr) and vim.api.nvim_buf_is_loaded(bufnr) or false
217+
return bufnr
218+
and vim.api.nvim_buf_is_valid(bufnr)
219+
and vim.api.nvim_buf_is_loaded(bufnr)
220+
and vim.bo[bufnr].buftype ~= 'terminal'
221+
or false
217222
end
218223

219224
--- Check if file paths are the same

0 commit comments

Comments
 (0)