summaryrefslogtreecommitdiff
path: root/py/chat.py
diff options
context:
space:
mode:
authorcposture <cposture@126.com>2023-11-15 23:08:30 +0800
committercposture <cposture@126.com>2023-12-02 13:01:46 +0800
commit1ca4e82b0435c7d65f65e535271f958a1021a5b2 (patch)
tree64771c8307d3040ae779e03937f4eefe7d1fbc12 /py/chat.py
parentc190089fc11985bbaff51362d8a00fbfff133796 (diff)
downloadvim-ai-1ca4e82b0435c7d65f65e535271f958a1021a5b2.tar.gz
fix selection include extra content when the user is in visual mode
Diffstat (limited to 'py/chat.py')
-rw-r--r--py/chat.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/py/chat.py b/py/chat.py
index 6d88015..907e71a 100644
--- a/py/chat.py
+++ b/py/chat.py
@@ -52,6 +52,7 @@ initial_messages = parse_chat_messages(initial_prompt)
chat_content = vim.eval('trim(join(getline(1, "$"), "\n"))')
chat_messages = parse_chat_messages(chat_content)
+is_selection = vim.eval("l:is_selection")
messages = initial_messages + chat_messages
@@ -75,7 +76,7 @@ try:
printDebug("[chat] response: {}", resp)
return resp['choices'][0]['delta'].get('content', '')
text_chunks = map(map_chunk, response)
- render_text_chunks(text_chunks)
+ render_text_chunks(text_chunks, is_selection)
vim.command("normal! a\n\n>>> user\n\n")
vim.command("redraw")