From f76aa3fdc4ac5f46145db8937bf10c04fa7c97dc Mon Sep 17 00:00:00 2001 From: Michael Buckley Date: Tue, 4 Jun 2024 11:21:27 -0400 Subject: Fix print_info_message issue I ran into an issue when first using this plugin where the print_info_message function wasn't working correctly due to vim misinterpreting the sequence in `vim.command("normal \\")` as a series of individual characters rather than a single literal Escape character. This resulted in the characters 'c>' being inserted into the active buffer at the cursor location because the 's' in '' was being interpreted as a normal mode 's', causing it to enter insert mode, and none of the info messages were being echoed properly. This was frustrating as it was not easy to figure out why my commands weren't working initially (turns out I hadn't configured my billing plan correctly, d'oh). Fix this by using a more robust way of sending the character to vim via `vim.command('call feedkeys("\")')`. The usage of double quotes inside the feedkeys() call is important because it causes vim to treat the sequence as a proper escape sequence rather than a series of individual characters (see :h feedkeys). --- py/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'py/utils.py') diff --git a/py/utils.py b/py/utils.py index 963377d..d1f960b 100644 --- a/py/utils.py +++ b/py/utils.py @@ -231,7 +231,7 @@ def openai_request(url, data, options): def print_info_message(msg): vim.command("redraw") - vim.command("normal \\") + vim.command('call feedkeys("\")') vim.command("echohl ErrorMsg") vim.command(f"echomsg '{msg}'") vim.command("echohl None") -- cgit v1.2.3