fix(messages): unwanted ext_messages newlines for confirm() #38045

Problem:  Newlines emitted with ext_messages intended to position
          the message/prompt on the message grid.
Solution: Don't emit these newlines with ext_messages, followup to 4260f73e.
This commit is contained in:
luukvbaal
2026-02-24 19:01:31 +01:00
committed by GitHub
parent 3115a18a80
commit 39c4e0f336
5 changed files with 7 additions and 12 deletions

View File

@@ -3779,7 +3779,7 @@ static char *console_dialog_alloc(const char *message, const char *buttons, bool
// Now allocate space for the strings // Now allocate space for the strings
confirm_msg = xmalloc((size_t)msg_len); confirm_msg = xmalloc((size_t)msg_len);
snprintf(confirm_msg, (size_t)msg_len, "\n%s\n", message); snprintf(confirm_msg, (size_t)msg_len, ui_has(kUIMessages) ? "%s" : "\n%s\n", message);
xfree(confirm_buttons); xfree(confirm_buttons);
confirm_buttons = xmalloc((size_t)button_len); confirm_buttons = xmalloc((size_t)button_len);

View File

@@ -213,7 +213,7 @@ describe('vim.ui_attach', function()
cmdline = { cmdline = {
{ content = { { '' } }, hl = 'MoreMsg', pos = 0, prompt = '[Y]es, (N)o, (C)ancel: ' }, { content = { { '' } }, hl = 'MoreMsg', pos = 0, prompt = '[Y]es, (N)o, (C)ancel: ' },
}, },
messages = { { content = { { '\nSave changes?\n', 6, 'MoreMsg' } }, kind = 'confirm' } }, messages = { { content = { { 'Save changes?', 6, 'MoreMsg' } }, kind = 'confirm' } },
}) })
feed('n') feed('n')
screen:expect_unchanged() screen:expect_unchanged()

View File

@@ -245,11 +245,9 @@ describe('cmdline2', function()
screen:try_resize(screen._width + 1, screen._height) screen:try_resize(screen._width + 1, screen._height)
screen:expect([[ screen:expect([[
| |
{1:~ }|*8 {1:~ }|*10
{3: }| {3: }|
|
{6:Ok?} | {6:Ok?} |
|
{6:[O]k: }^ | {6:[O]k: }^ |
]]) ]])
-- And resizing the next event loop iteration also works. -- And resizing the next event loop iteration also works.
@@ -257,11 +255,9 @@ describe('cmdline2', function()
screen:try_resize(screen._width, screen._height + 1) screen:try_resize(screen._width, screen._height + 1)
screen:expect([[ screen:expect([[
| |
{1:~ }|*9 {1:~ }|*11
{3: }| {3: }|
|
{6:Ok?} | {6:Ok?} |
|
{6:[O]k: }^ | {6:[O]k: }^ |
]]) ]])
end) end)

View File

@@ -710,12 +710,11 @@ describe('messages2', function()
feed('<CR>') feed('<CR>')
screen:expect([[ screen:expect([[
| |
{1:~ }|*7 {1:~ }|*8
{1:~ }{9:E5108: Lua: [string ":lua"]:1: foo}{4: }|
{3: }| {3: }|
|
{6:foo} | {6:foo} |
{6:bar} | {6:bar} |
|
{6:[O]k: }^ | {6:[O]k: }^ |
]]) ]])
end) end)

View File

@@ -51,7 +51,7 @@ describe('ui/ext_messages', function()
{1:~ }|*3 {1:~ }|*3
]], ]],
cmdline = { { content = { { '' } }, hl = 'MoreMsg', pos = 0, prompt = '[O]k: ' } }, cmdline = { { content = { { '' } }, hl = 'MoreMsg', pos = 0, prompt = '[O]k: ' } },
messages = { { content = { { '\ntest\n', 6, 'MoreMsg' } }, kind = 'confirm' } }, messages = { { content = { { 'test', 6, 'MoreMsg' } }, kind = 'confirm' } },
}) })
feed('<cr>') feed('<cr>')
screen:expect({ screen:expect({