Skip to content

Commit a38ae2f

Browse files
fix: check if buffer is in chat window to validate chat being visible (#330)
* fix: check if buffer is in chat window to validate chat being visible This prevents someone replacing buffer in copilot chat window with other buffer and chat not being able to recover * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bac4dcc commit a38ae2f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lua/CopilotChat/chat.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ local Chat = class(function(self, mark_ns, help, on_buf_create)
6161
end, Overlay)
6262

6363
function Chat:visible()
64-
return self.winnr and vim.api.nvim_win_is_valid(self.winnr)
64+
return self.winnr
65+
and vim.api.nvim_win_is_valid(self.winnr)
66+
and vim.api.nvim_win_get_buf(self.winnr) == self.bufnr
6567
end
6668

6769
function Chat:active()

0 commit comments

Comments
 (0)