aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_editor.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-07 19:50:00 +0800
committerGitHub <noreply@github.com>2025-03-07 19:50:00 +0800
commitc8b64b7a43975d6f4efa30999c82ae8180f16a4b (patch)
tree77af6212f1edbd28f7633e0392e987ca655d17e7 /runtime/lua/vim/_editor.lua
parent5d08b65ac2f65eecc1e48e0e2007e5fed0d8de86 (diff)
downloadrneovim-c8b64b7a43975d6f4efa30999c82ae8180f16a4b.tar.gz
rneovim-c8b64b7a43975d6f4efa30999c82ae8180f16a4b.tar.bz2
rneovim-c8b64b7a43975d6f4efa30999c82ae8180f16a4b.zip
fix(lua): always use vim.inspect() for :lua= (#32715)
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r--runtime/lua/vim/_editor.lua27
1 files changed, 16 insertions, 11 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 975f3fea4a..e29d8f1c30 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -1142,6 +1142,21 @@ do
end
end
+--- @param inspect_strings boolean use vim.inspect() for strings
+function vim._print(inspect_strings, ...)
+ local msg = {}
+ for i = 1, select('#', ...) do
+ local o = select(i, ...)
+ if not inspect_strings and type(o) == 'string' then
+ table.insert(msg, o)
+ else
+ table.insert(msg, vim.inspect(o, { newline = '\n', indent = ' ' }))
+ end
+ end
+ print(table.concat(msg, '\n'))
+ return ...
+end
+
--- "Pretty prints" the given arguments and returns them unmodified.
---
--- Example:
@@ -1155,17 +1170,7 @@ end
--- @param ... any
--- @return any # given arguments.
function vim.print(...)
- local msg = {}
- for i = 1, select('#', ...) do
- local o = select(i, ...)
- if type(o) == 'string' then
- table.insert(msg, o)
- else
- table.insert(msg, vim.inspect(o, { newline = '\n', indent = ' ' }))
- end
- end
- print(table.concat(msg, '\n'))
- return ...
+ return vim._print(false, ...)
end
--- Translates keycodes.