fix(messages): non-fast and append for "shell_*" kinds #38188

Problem:  vim.ui_attach() is unable to display streamed shell output,
          and will display it as individual messages.
          Unwanted newlines in "shell_ret" message.
Solution: Treat the "shell_*" kinds as non-fast and set msg_show->append
          for the streamed stdout/err messages.
          Remove leading newline from (translated) message with
          ext_messages, remove trailing newline altogether.
This commit is contained in:
luukvbaal
2026-03-10 00:24:01 +01:00
committed by GitHub
parent bffca6e26b
commit a81b059a45
35 changed files with 73 additions and 184 deletions

View File

@@ -3478,7 +3478,7 @@ void verbose_enter(void)
if (*p_vfile != NUL) {
msg_silent++;
}
// last_set_msg unsets p_verbose to avoid setting the verbose kind.
// Don't set the verbose kind if message continuity is wanted like with last_set_msg().
if (!msg_ext_skip_verbose) {
if (msg_ext_kind != verbose_kind) {
pre_verbose_kind = msg_ext_kind;

View File

@@ -700,9 +700,11 @@ int os_call_shell(char *cmd, int opts, char *extra_args)
if (!emsg_silent && exitcode != 0 && !(opts & kShellOptSilent)) {
msg_ext_set_kind("shell_ret");
msg_puts(_("\nshell returned "));
if (!ui_has(kUIMessages)) {
msg_putchar('\n');
}
msg_puts(_("shell returned "));
msg_outnum(exitcode);
msg_putchar('\n');
}
State = current_state;
@@ -1120,6 +1122,7 @@ static void out_data_append_to_screen(const char *output, size_t *count, int fd,
const char *p = output;
const char *end = output + *count;
msg_ext_set_kind(fd == STDERR_FILENO ? "shell_err" : "shell_out");
msg_ext_append = true;
while (p < end) {
if (*p == '\n' || *p == '\r' || *p == TAB || *p == BELL) {
msg_putchar_hl((uint8_t)(*p), fd == STDERR_FILENO ? HLF_SE : HLF_SO);

View File

@@ -4110,12 +4110,8 @@ msgstr "E358: 'langmap: Ekstra karakters na kommapunt: %s"
msgid "Vim: Error reading input, exiting...\n"
msgstr "Vim: Fout met lees van invoer, verlaat...\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"dop lewer "
msgid "shell returned "
msgstr "dop lewer "
#~ msgid ""
#~ "\n"

View File

@@ -4667,12 +4667,8 @@ msgstr ""
"No s'ha pogut executar la shell "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"la shell ha retornat "
msgid "shell returned "
msgstr "la shell ha retornat "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4747,12 +4747,8 @@ msgstr ""
"nelze spustit shell "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
" n<>vratov<6F> hodnota shellu "
msgid "shell returned "
msgstr " n<>vratov<6F> hodnota shellu "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4747,12 +4747,8 @@ msgstr ""
"nelze spustit shell "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
" n<>vratov<6F> hodnota shellu "
msgid "shell returned "
msgstr " n<>vratov<6F> hodnota shellu "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4430,12 +4430,8 @@ msgstr ""
"\n"
"Kan ikke udføre skallen sh\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"skal returnerede "
msgid "shell returned "
msgstr "skal returnerede "
msgid ""
"\n"

View File

@@ -53,12 +53,8 @@ msgstr ""
"Shell kann nicht ausf<73>hrt werden "
#: ../os/shell.c:450
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"Shell beendet "
msgid "shell returned "
msgstr "Shell beendet "
#: ../buffer.c:88
msgid "[Location List]"

View File

@@ -4445,9 +4445,7 @@ msgid ""
msgstr ""
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgid "shell returned "
msgstr ""
#: ../os_unix.c:465 ../os_unix.c:471

View File

@@ -4184,12 +4184,8 @@ msgstr ""
"\n"
"Ne eblas plenumi ŝelon sh\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"ŝelo liveris "
msgid "shell returned "
msgstr "ŝelo liveris "
msgid ""
"\n"

View File

@@ -4728,12 +4728,8 @@ msgstr ""
"No se pudo ejecutar el intérprete de órdenes "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"El intérprete de órdenes devolvió "
msgid "shell returned "
msgstr "El intérprete de órdenes devolvió "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4178,12 +4178,8 @@ msgstr "dlerror = %s"
msgid "Vim: Error reading input, exiting...\n"
msgstr "Vim: Virhe luettaessa syötettä, poistutaan...\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"kuoren palautusarvo "
msgid "shell returned "
msgstr "kuoren palautusarvo "
#~ msgid ""
#~ "\n"

View File

@@ -3921,12 +3921,8 @@ msgstr ""
"\n"
"Impossible d'ex<65>cuter le shell sh\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"le shell a retourn<72> "
msgid "shell returned "
msgstr "le shell a retourn<72> "
msgid ""
"\n"

View File

@@ -4476,12 +4476,8 @@ msgstr ""
"\n"
"N<> f<>idir an bhlaosc sh a rith\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"d'aisfhill an bhlaosc "
msgid "shell returned "
msgstr "d'aisfhill an bhlaosc "
msgid ""
"\n"

View File

@@ -4698,12 +4698,8 @@ msgstr ""
"Non riesco a eseguire shell "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"shell terminato con return-code "
msgid "shell returned "
msgstr "shell terminato con return-code "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4194,12 +4194,8 @@ msgstr ""
"\n"
"sh <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹ԤǤ<D4A4><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD><CDA4>֤<EFBFBD><D6A4>ޤ<EFBFBD><DEA4><EFBFBD> "
msgid "shell returned "
msgstr "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͤ<EFBFBD><CDA4>֤<EFBFBD><D6A4>ޤ<EFBFBD><DEA4><EFBFBD> "
msgid ""
"\n"

View File

@@ -5563,12 +5563,8 @@ msgstr "現在の %s言語: \"%s\""
msgid "E197: Cannot set language to \"%s\""
msgstr "E197: 言語を \"%s\" に設定できません"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"シェルが値を返しました "
msgid "shell returned "
msgstr "シェルが値を返しました "
msgid ""
"\n"

View File

@@ -4602,12 +4602,8 @@ msgstr ""
"Cannot execute shell "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"shell returned "
msgid "shell returned "
msgstr "shell returned "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4626,12 +4626,8 @@ msgstr ""
"Kan ikke kj<6B>re skall "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"skallet returnerte "
msgid "shell returned "
msgstr "skallet returnerte "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4622,9 +4622,7 @@ msgid ""
msgstr ""
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgid "shell returned "
msgstr ""
#: ../os_unix.c:465 ../os_unix.c:471

View File

@@ -4626,12 +4626,8 @@ msgstr ""
"Kan ikke kj<6B>re skall "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"skallet returnerte "
msgid "shell returned "
msgstr "skallet returnerte "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4591,12 +4591,8 @@ msgstr ""
"Nie mogę wykonać powłoki "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"powłoka zwróciła "
msgid "shell returned "
msgstr "powłoka zwróciła "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4780,12 +4780,8 @@ msgstr ""
"N<>o foi poss<73>vel executar o shell "
#: ../os/shell.c:450
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"o shell devolveu "
msgid "shell returned "
msgstr "o shell devolveu "
#: ../mark.c:673
msgid "No marks set"

View File

@@ -4641,12 +4641,8 @@ msgstr ""
"Невозможно запустить оболочку "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"Оболочка завершила работу "
msgid "shell returned "
msgstr "Оболочка завершила работу "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4631,12 +4631,8 @@ msgstr ""
"Ned<65> sa spusti<74> shell "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
" n<>vratov<6F> hodnota shellu "
msgid "shell returned "
msgstr " n<>vratov<6F> hodnota shellu "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4635,12 +4635,8 @@ msgstr ""
"Ned<65> sa spusti<74> shell "
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
" n<>vratov<6F> hodnota shellu "
msgid "shell returned "
msgstr " n<>vratov<6F> hodnota shellu "
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -4733,12 +4733,8 @@ msgstr ""
"\n"
"Командно окружење sh не може да се изврши\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"командно окружење је вратило "
msgid "shell returned "
msgstr "командно окружење је вратило "
msgid ""
"\n"

View File

@@ -2637,12 +2637,8 @@ msgstr ""
"\n"
"Kan inte köra skal sh\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"skal returnerade "
msgid "shell returned "
msgstr "skal returnerade "
msgid ""
"\n"

View File

@@ -4414,12 +4414,8 @@ msgstr "Şu anki %sdil: \"%s\""
msgid "E197: Cannot set language to \"%s\""
msgstr "E197: \"%s\" diline ayarlanamıyor"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"Program çıktı: "
msgid "shell returned "
msgstr "Program çıktı: "
msgid ""
"\n"

View File

@@ -4397,12 +4397,8 @@ msgstr "Мова (%s): «%s»"
msgid "E197: Cannot set language to \"%s\""
msgstr "E197: Не вдалося встановити мову «%s»"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"оболонка повернула: "
msgid "shell returned "
msgstr "оболонка повернула: "
msgid ""
"\n"

View File

@@ -3756,12 +3756,8 @@ msgstr ""
"\n"
"Không chạy được shell sh\n"
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"shell dừng làm việc "
msgid "shell returned "
msgstr "shell dừng làm việc "
msgid ""
"\n"

View File

@@ -5335,12 +5335,8 @@ msgid "Vim: Error reading input, exiting...\n"
msgstr "Vim读取输入时出错正在退出……\n"
#: ../os/shell.c:696
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"Shell 返回了 "
msgid "shell returned "
msgstr "Shell 返回了 "
#: ../os/shell.c:878
msgid ""

View File

@@ -4669,12 +4669,8 @@ msgstr ""
"不能執行 shell"
#: ../os/shell.c:439
msgid ""
"\n"
"shell returned "
msgstr ""
"\n"
"Shell 已返回"
msgid "shell returned "
msgstr "Shell 已返回"
#: ../os_unix.c:465 ../os_unix.c:471
msgid ""

View File

@@ -785,6 +785,10 @@ void ui_call_event(char *name, Array args)
"lua_error",
"lua_print",
"progress",
"shell_cmd",
"shell_err",
"shell_out",
"shell_ret",
NULL,
};

View File

@@ -439,12 +439,14 @@ describe('ui/ext_messages', function()
{
content = { { ('stdout%s\n'):format(t.is_os('win') and '\r' or ''), 'StdoutMsg' } },
kind = 'shell_out',
append = true,
},
{
content = { { ('stderr%s\n'):format(t.is_os('win') and '\r' or ''), 9, 'StderrMsg' } },
kind = 'shell_err',
append = true,
},
{ content = { { '\nshell returned 3\n' } }, kind = 'shell_ret' },
{ content = { { 'shell returned 3' } }, kind = 'shell_ret' },
},
})