Skip to content

Commit

Permalink
fix: check if buffer is in chat window to validate chat being visible (
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
deathbeam and pre-commit-ci[bot] authored May 24, 2024
1 parent bac4dcc commit a38ae2f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/CopilotChat/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ local Chat = class(function(self, mark_ns, help, on_buf_create)
end, Overlay)

function Chat:visible()
return self.winnr and vim.api.nvim_win_is_valid(self.winnr)
return self.winnr
and vim.api.nvim_win_is_valid(self.winnr)
and vim.api.nvim_win_get_buf(self.winnr) == self.bufnr
end

function Chat:active()
Expand Down

0 comments on commit a38ae2f

Please sign in to comment.