commit cd7cf4bd16e79f3b8b28a8a86580d45b3cd151d4
parent 9269a1da355b760f5da66a5d2ee7eaad7399848d
Author: phanium <91544758+phanen@users.noreply.github.com>
Date: Wed, 27 Aug 2025 23:12:17 +0800
fix(extui): error on :call input('') (#35515)
Problem: Error on empty string prompt.
Solution: (prompt .. '\n'):gmatch('(.-)\n').
Diffstat:
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/runtime/lua/vim/_extui/cmdline.lua b/runtime/lua/vim/_extui/cmdline.lua
@@ -41,7 +41,7 @@ local promptlen = 0 -- Current length of the last line in the prompt.
---@param prompt string
local function set_text(content, prompt)
local lines = {} ---@type string[]
- for line in prompt:gmatch('[^\n]+') do
+ for line in (prompt .. '\n'):gmatch('(.-)\n') do
lines[#lines + 1] = fn.strtrans(line)
end
cmdbuff, promptlen, M.erow = '', #lines[#lines], M.srow + #lines - 1
diff --git a/test/functional/ui/cmdline2_spec.lua b/test/functional/ui/cmdline2_spec.lua
@@ -88,4 +88,13 @@ describe('cmdline2', function()
|
]])
end)
+
+ it('handles empty prompt', function()
+ feed(":call input('')<CR>")
+ screen:expect([[
+ |
+ {1:~ }|*12
+ ^ |
+ ]])
+ end)
end)