mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
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().
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user