diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2023-01-05 13:06:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-05 13:06:21 -0500 |
commit | 08ebf8d3a80c65b01d493ca84ad2ab7304a669f9 (patch) | |
tree | 77f73c6e88134d702ca275e43b45f5316ba5b47e /src/nvim/message.c | |
parent | 39d70fcafd6efa9d01b88bb90cab81c393040453 (diff) | |
parent | 628b717022815a431ea0b980444d6115c644f8c8 (diff) | |
download | rneovim-08ebf8d3a80c65b01d493ca84ad2ab7304a669f9.tar.gz rneovim-08ebf8d3a80c65b01d493ca84ad2ab7304a669f9.tar.bz2 rneovim-08ebf8d3a80c65b01d493ca84ad2ab7304a669f9.zip |
Merge #18706 execute Lua with "nvim -l"
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 041e5ed6c3..118d144617 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -3003,31 +3003,36 @@ static int do_more_prompt(int typed_char) } #if defined(MSWIN) -void os_errmsg(char *str) +/// Headless (no UI) error message handler. +static void do_msg(char *str, bool errmsg) { + static bool did_err = false; assert(str != NULL); wchar_t *utf16str; int r = utf8_to_utf16(str, -1, &utf16str); - if (r != 0) { + if (r != 0 && !did_err) { + did_err = true; fprintf(stderr, "utf8_to_utf16 failed: %d", r); - } else { - fwprintf(stderr, L"%ls", utf16str); + ELOG("utf8_to_utf16 failed: %d", r); + } else if (r == 0) { + if (errmsg) { + fwprintf(stderr, L"%ls", utf16str); + } else { + wprintf(L"%ls", utf16str); + } xfree(utf16str); } } -/// Give a message. To be used when the UI is not initialized yet. +void os_errmsg(char *str) +{ + do_msg(str, true); +} + +/// Headless (no UI) message handler. void os_msg(char *str) { - assert(str != NULL); - wchar_t *utf16str; - int r = utf8_to_utf16(str, -1, &utf16str); - if (r != 0) { - fprintf(stderr, "utf8_to_utf16 failed: %d", r); - } else { - wprintf(L"%ls", utf16str); - xfree(utf16str); - } + do_msg(str, false); } #endif // MSWIN |