Skip to content

Commit

Permalink
fix: buffer is not 'modifiable' error
Browse files Browse the repository at this point in the history
fix #340
  • Loading branch information
jackMort committed Dec 14, 2023
1 parent 0ac7943 commit 9dfe972
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/chatgpt/flows/chat/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function Chat:init()
self.settings_open = false
self.system_role_open = false

self.is_streaming_response = false

self.prompt_lines = 1

self.display_mode = Config.options.popup_layout.default
Expand Down Expand Up @@ -150,7 +152,7 @@ function Chat:set_session(session)
end

function Chat:isBusy()
return self.spinner:is_running()
return self.spinner:is_running() or self.is_streaming_response
end

function Chat:add(type, text, usage)
Expand Down Expand Up @@ -247,9 +249,13 @@ function Chat:addAnswerPartial(text, state)
self.selectedIndex = self.selectedIndex + 1
vim.api.nvim_buf_set_lines(self.chat_window.bufnr, -1, -1, false, { "", "" })
Signs.set_for_lines(self.chat_window.bufnr, start_line, end_line, "chat")

self.is_streaming_response = false
end

if state == "START" then
self.is_streaming_response = true

self:stopSpinner()
self:set_lines(-2, -1, false, { "" })
vim.api.nvim_buf_set_option(self.chat_window.bufnr, "modifiable", true)
Expand Down

1 comment on commit 9dfe972

@joeldrotleff
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great! Thanks for fixing.

Another bug: looks like the 'buffer not modifiable' error also pops up if I hit to open the settings panel or to open the prompt panel while a response is streaming, it also leads to this error.

Please sign in to comment.