Skip to content

Commit

Permalink
output immediately when bytes are full
Browse files Browse the repository at this point in the history
  • Loading branch information
gptlang committed Feb 5, 2024
1 parent 043f6f7 commit 322f673
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions rplugin/python3/handlers/chat_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,9 @@ def _add_chat_messages(
buffer.decode("utf-8")
except UnicodeDecodeError:
continue
if "\n" in buffer.decode("utf-8"):
token = buffer.decode("utf-8").split("\n")[0]
buffer = buffer[len(token) + 1:]
self.nvim.exec_lua(
'require("CopilotChat.utils").log_info(...)', f"Token: {token}"
)
buffer_lines = cast(list[str], self.buffer.lines())
last_line_row = len(buffer_lines) - 1
last_line_col = len(buffer_lines[-1])

self.nvim.api.buf_set_text(
self.buffer.number,
last_line_row,
last_line_col,
last_line_row,
last_line_col,
[token],
)
if buffer:
token = buffer.decode("utf-8")
self.nvim.exec_lua(
'require("CopilotChat.utils").log_info(...)', f"Buffer: {buffer}"
'require("CopilotChat.utils").log_info(...)', f"Token: {token}"
)
buffer_lines = cast(list[str], self.buffer.lines())
last_line_row = len(buffer_lines) - 1
Expand All @@ -253,7 +235,7 @@ def _add_chat_messages(
last_line_col,
last_line_row,
last_line_col,
[buffer],
token.split("\n"),
)

def _add_end_separator(self, model: str, no_annoyance: bool = False):
Expand Down

0 comments on commit 322f673

Please sign in to comment.