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/lua/vim/_editor.lua | |
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/lua/vim/_editor.lua')
-rw-r--r-- | runtime/lua/vim/_editor.lua | 13 |
1 files changed, 4 insertions, 9 deletions
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 |