Skip to content

Commit

Permalink
feat: add buffer validation for chat window
Browse files Browse the repository at this point in the history
Add validate() method to Chat class that ensures the window buffer stays in
sync. This prevents potential issues where the window could show incorrect
buffer content by validating and resetting the buffer if needed.
  • Loading branch information
deathbeam committed Nov 21, 2024
1 parent fc1cece commit e4e6993
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lua/CopilotChat/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ function Chat:create()
return bufnr
end

function Chat:validate()
Overlay.validate(self)
if
self.winnr
and vim.api.nvim_win_is_valid(self.winnr)
and vim.api.nvim_win_get_buf(self.winnr) ~= self.bufnr
then
vim.api.nvim_win_set_buf(self.winnr, self.bufnr)
end
end

function Chat:visible()
return self.winnr
and vim.api.nvim_win_is_valid(self.winnr)
Expand Down

0 comments on commit e4e6993

Please sign in to comment.