diff options
author | luukvbaal <luukvbaal@gmail.com> | 2024-11-17 19:21:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-17 10:21:50 -0800 |
commit | e025f5a5b30a1ef92e88fed0f0c548d2240d30c0 (patch) | |
tree | 9ae569b85a6f1506a402556e44b6b6a81485efbc /runtime | |
parent | 6ea45031d5841d3227c545f213d0903b951e40be (diff) | |
download | rneovim-e025f5a5b30a1ef92e88fed0f0c548d2240d30c0.tar.gz rneovim-e025f5a5b30a1ef92e88fed0f0c548d2240d30c0.tar.bz2 rneovim-e025f5a5b30a1ef92e88fed0f0c548d2240d30c0.zip |
fix(messages): proper multiline Lua print() messages #31205
Problem: Separate message emitted for each newline present in Lua
print() arguments.
Solution: Make msg_multiline() handle NUL bytes. Refactor print() to use
msg_multiline(). Refactor vim.print() to use print().
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/ui.txt | 1 | ||||
-rw-r--r-- | runtime/lua/vim/_editor.lua | 13 |
2 files changed, 5 insertions, 9 deletions
diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 4ee8121034..4e8253c47a 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -796,6 +796,7 @@ must handle. "echomsg" |:echomsg| message "echoerr" |:echoerr| message "lua_error" Error in |:lua| code + "lua_print" |print()| from |:lua| code "rpc_error" Error response from |rpcrequest()| "return_prompt" |press-enter| prompt after a multiple messages "quickfix" Quickfix navigation message diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index b4a1e0fc15..44f17b3f85 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -1151,21 +1151,16 @@ end --- @param ... any --- @return any # given arguments. function vim.print(...) - if vim.in_fast_event() then - print(...) - return ... - end - + local msg = {} for i = 1, select('#', ...) do local o = select(i, ...) if type(o) == 'string' then - vim.api.nvim_out_write(o) + table.insert(msg, o) else - vim.api.nvim_out_write(vim.inspect(o, { newline = '\n', indent = ' ' })) + table.insert(msg, vim.inspect(o, { newline = '\n', indent = ' ' })) end - vim.api.nvim_out_write('\n') end - + print(table.concat(msg, '\n')) return ... end |