From d86d4bacc14bc6ab51b3173f3644d703f53ffbde Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Thu, 12 Jun 2025 11:57:17 +0200 Subject: [PATCH] fix(messages): make swapfile attention message part of prompt (#34414) Problem: The swapfile attention message is not repeated after clearing the screen. After clearing the screen `msg_scrolled` is reset without clearing other related variables, causing an assert. Solution: Make the attention message part of the confirm prompt. Call `msg_reset_scroll()`. --- src/nvim/drawscreen.c | 4 +- src/nvim/memline.c | 158 ++++++++---------- src/nvim/po/af.po | 8 +- src/nvim/po/ca.po | 6 +- src/nvim/po/cs.cp1250.po | 8 +- src/nvim/po/cs.po | 8 +- src/nvim/po/da.po | 8 +- src/nvim/po/de.po | 8 +- src/nvim/po/en_GB.po | 4 +- src/nvim/po/eo.po | 8 +- src/nvim/po/es.po | 8 +- src/nvim/po/fi.po | 8 +- src/nvim/po/fr.po | 8 +- src/nvim/po/ga.po | 8 +- src/nvim/po/it.po | 8 +- src/nvim/po/ja.euc-jp.po | 8 +- src/nvim/po/ja.po | 8 +- src/nvim/po/ko.UTF-8.po | 8 +- src/nvim/po/nb.po | 8 +- src/nvim/po/nl.po | 8 +- src/nvim/po/no.po | 8 +- src/nvim/po/pl.UTF-8.po | 8 +- src/nvim/po/pt_BR.po | 8 +- src/nvim/po/ru.po | 8 +- src/nvim/po/sk.cp1250.po | 8 +- src/nvim/po/sr.po | 8 +- src/nvim/po/sv.po | 8 +- src/nvim/po/tr.po | 8 +- src/nvim/po/uk.po | 8 +- src/nvim/po/vi.po | 8 +- src/nvim/po/zh_CN.UTF-8.po | 8 +- src/nvim/po/zh_TW.UTF-8.po | 8 +- .../swapfile_preserve_recover_spec.lua | 39 ++--- 33 files changed, 152 insertions(+), 283 deletions(-) diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index cc890489bf..12647758a7 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -255,7 +255,7 @@ void screenclear(void) compute_cmdrow(); msg_row = cmdline_row; // put cursor on last line for messages msg_col = 0; - msg_scrolled = 0; // can't scroll back + msg_reset_scroll(); // can't scroll back msg_didany = false; msg_didout = false; if (HL_ATTR(HLF_MSG) > 0 && msg_use_grid() && msg_grid.chars) { @@ -500,7 +500,7 @@ int update_screen(void) } // if the screen was scrolled up when displaying a message, scroll it down - if ((msg_scrolled || msg_grid_invalid) && !cmdline_number_prompt()) { + if (msg_scrolled || msg_grid_invalid) { clear_cmdline = true; int valid = MAX(Rows - msg_scrollsize(), 0); if (msg_grid.chars) { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 058fdce99f..1054e40190 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1402,7 +1402,10 @@ int recover_names(char *fname, bool do_list, list_T *ret_list, int nr, char **fn msg_puts(". "); msg_puts(path_tail(files[i])); msg_putchar('\n'); - swapfile_info(files[i]); + StringBuilder msg = KV_INITIAL_VALUE; + swapfile_info(files[i], &msg); + msg_outtrans(msg.items, 0, false); + kv_destroy(msg); } } else { msg_puts(_(" -- none --\n")); @@ -1500,7 +1503,7 @@ void swapfile_dict(const char *fname, dict_T *d) /// Loads info from swapfile `fname`, and displays it to the user. /// /// @return timestamp (0 when unknown). -static time_t swapfile_info(char *fname) +static time_t swapfile_info(char *fname, StringBuilder *msg) { assert(fname != NULL); ZeroBlock b0; @@ -1515,18 +1518,17 @@ static time_t swapfile_info(char *fname) #ifdef UNIX // print name of owner of the file if (os_get_uname((uv_uid_t)file_info.stat.st_uid, uname, B0_UNAME_SIZE) == OK) { - msg_puts(_(" owned by: ")); - msg_outtrans(uname, 0, false); - msg_puts(_(" dated: ")); + kv_printf(*msg, "%s%s", _(" owned by: "), uname); + kv_printf(*msg, _(" dated: ")); } else { - msg_puts(_(" dated: ")); + kv_printf(*msg, _(" dated: ")); } #else msg_puts(_(" dated: ")); #endif x = file_info.stat.st_mtim.tv_sec; char ctime_buf[100]; // hopefully enough for every language - msg_puts(os_ctime_r(&x, ctime_buf, sizeof(ctime_buf), true)); + kv_printf(*msg, "%s", os_ctime_r(&x, ctime_buf, sizeof(ctime_buf), true)); } // print the original file name @@ -1534,56 +1536,56 @@ static time_t swapfile_info(char *fname) if (fd >= 0) { if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) { if (strncmp(b0.b0_version, "VIM 3.0", 7) == 0) { - msg_puts(_(" [from Vim version 3.0]")); + kv_printf(*msg, _(" [from Vim version 3.0]")); } else if (ml_check_b0_id(&b0) == FAIL) { - msg_puts(_(" [does not look like a Nvim swap file]")); + kv_printf(*msg, _(" [does not look like a Nvim swap file]")); } else if (!ml_check_b0_strings(&b0)) { - msg_puts(_(" [garbled strings (not nul terminated)]")); + kv_printf(*msg, _(" [garbled strings (not nul terminated)]")); } else { - msg_puts(_(" file name: ")); + kv_printf(*msg, _(" file name: ")); if (b0.b0_fname[0] == NUL) { - msg_puts(_("[No Name]")); + kv_printf(*msg, _("[No Name]")); } else { - msg_outtrans(b0.b0_fname, 0, false); + kv_printf(*msg, "%s", b0.b0_fname); } - msg_puts(_("\n modified: ")); - msg_puts(b0.b0_dirty ? _("YES") : _("no")); + kv_printf(*msg, _("\n modified: ")); + kv_printf(*msg, b0.b0_dirty ? _("YES") : _("no")); if (*(b0.b0_uname) != NUL) { - msg_puts(_("\n user name: ")); - msg_outtrans(b0.b0_uname, 0, false); + kv_printf(*msg, _("\n user name: ")); + kv_printf(*msg, "%s", b0.b0_uname); } if (*(b0.b0_hname) != NUL) { if (*(b0.b0_uname) != NUL) { - msg_puts(_(" host name: ")); + kv_printf(*msg, _(" host name: ")); } else { - msg_puts(_("\n host name: ")); + kv_printf(*msg, _("\n host name: ")); } - msg_outtrans(b0.b0_hname, 0, false); + kv_printf(*msg, "%s", b0.b0_hname); } if (char_to_long(b0.b0_pid) != 0) { - msg_puts(_("\n process ID: ")); - msg_outnum((int)char_to_long(b0.b0_pid)); + kv_printf(*msg, _("\n process ID: ")); + kv_printf(*msg, "%d", (int)char_to_long(b0.b0_pid)); if ((proc_running = swapfile_proc_running(&b0, fname))) { - msg_puts(_(" (STILL RUNNING)")); + kv_printf(*msg, _(" (STILL RUNNING)")); } } if (b0_magic_wrong(&b0)) { - msg_puts(_("\n [not usable on this computer]")); + kv_printf(*msg, _("\n [not usable on this computer]")); } } } else { - msg_puts(_(" [cannot be read]")); + kv_printf(*msg, _(" [cannot be read]")); } close(fd); } else { - msg_puts(_(" [cannot be opened]")); + kv_printf(*msg, _(" [cannot be opened]")); } - msg_putchar('\n'); + kv_printf(*msg, "\n"); return x; } @@ -3245,50 +3247,47 @@ char *get_file_in_dir(char *fname, char *dname) return retval; } -/// Print the ATTENTION message: info about an existing swapfile. +/// Build the ATTENTION message: info about an existing swapfile. /// /// @param buf buffer being edited /// @param fname swapfile name -static void attention_message(buf_T *buf, char *fname) +/// @param fhname swapfile name, home replaced +/// @param msg string buffer, emitted as either a regular or confirm message +static void attention_message(buf_T *buf, char *fname, char *fhname, StringBuilder *msg) { assert(buf->b_fname != NULL); - no_wait_return++; emsg(_("E325: ATTENTION")); - msg_puts(_("\nFound a swap file by the name \"")); - msg_home_replace(fname); - msg_puts("\"\n"); - const time_t swap_mtime = swapfile_info(fname); - msg_puts(_("While opening file \"")); - msg_outtrans(buf->b_fname, 0, false); - msg_puts("\"\n"); + kv_printf(*msg, _("Found a swap file by the name \"")); + kv_printf(*msg, "%s\"\n", fhname); + const time_t swap_mtime = swapfile_info(fname, msg); + kv_printf(*msg, (_("While opening file \""))); + kv_printf(*msg, "%s\"\n", buf->b_fname); FileInfo file_info; if (!os_fileinfo(buf->b_fname, &file_info)) { - msg_puts(_(" CANNOT BE FOUND")); + kv_printf(*msg, _(" CANNOT BE FOUND")); } else { - msg_puts(_(" dated: ")); + kv_printf(*msg, _(" dated: ")); time_t x = file_info.stat.st_mtim.tv_sec; char ctime_buf[50]; - msg_puts(os_ctime_r(&x, ctime_buf, sizeof(ctime_buf), true)); + kv_printf(*msg, "%s", os_ctime_r(&x, ctime_buf, sizeof(ctime_buf), true)); if (swap_mtime != 0 && x > swap_mtime) { - msg_puts(_(" NEWER than swap file!\n")); + kv_printf(*msg, _(" NEWER than swap file!\n")); } } // Some of these messages are long to allow translation to // other languages. - msg_puts(_("\n(1) Another program may be editing the same file. If this is" - " the case,\n be careful not to end up with two different" - " instances of the same\n file when making changes." - " Quit, or continue with caution.\n")); - msg_puts(_("(2) An edit session for this file crashed.\n")); - msg_puts(_(" If this is the case, use \":recover\" or \"nvim -r ")); - msg_outtrans(buf->b_fname, 0, false); - msg_puts(_("\"\n to recover the changes (see \":help recovery\").\n")); - msg_puts(_(" If you did this already, delete the swap file \"")); - msg_outtrans(fname, 0, false); - msg_puts(_("\"\n to avoid this message.\n")); - cmdline_row = msg_row; - no_wait_return--; + kv_printf(*msg, _("\n(1) Another program may be editing the same file. If this is" + " the case,\n be careful not to end up with two different" + " instances of the same\n file when making changes." + " Quit, or continue with caution.\n")); + kv_printf(*msg, _("(2) An edit session for this file crashed.\n")); + kv_printf(*msg, _(" If this is the case, use \":recover\" or \"nvim -r ")); + kv_printf(*msg, "%s", buf->b_fname); + kv_printf(*msg, (_("\"\n to recover the changes (see \":help recovery\").\n"))); + kv_printf(*msg, _(" If you did this already, delete the swap file \"")); + kv_printf(*msg, "%s", fname); + kv_printf(*msg, _("\"\n to avoid this message.\n")); } /// Trigger the SwapExists autocommands. @@ -3462,8 +3461,11 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ proc_running = 0; // Set by attention_message..swapfile_info. if (choice == SEA_CHOICE_NONE) { + no_wait_return++; // Show info about the existing swapfile. - attention_message(buf, fname); + StringBuilder msg = KV_INITIAL_VALUE; + char *fhname = home_replace_save(NULL, fname); + attention_message(buf, fname, fhname, &msg); // We don't want a 'q' typed at the more-prompt // interrupt loading a file. @@ -3472,40 +3474,26 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_ // If vimrc has "simalt ~x" we don't want it to // interfere with the prompt here. flush_buffers(FLUSH_TYPEAHEAD); - } - if (swap_exists_action != SEA_NONE && choice == SEA_CHOICE_NONE) { - const char *const sw_msg_1 = _("Swap file \""); - const char *const sw_msg_2 = _("\" already exists!"); + if (swap_exists_action != SEA_NONE) { + kv_printf(msg, _("Swap file \"")); + kv_printf(msg, "%s", fhname); + kv_printf(msg, _("\" already exists!")); + char *run_but = _("&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Abort"); + char *but = _("&Open Read-Only\n&Edit anyway\n&Recover\n&Delete it\n&Quit\n&Abort"); + choice = (sea_choice_T)do_dialog(VIM_WARNING, _("VIM - ATTENTION"), msg.items, + proc_running ? run_but : but, 1, NULL, false); - const size_t fname_len = strlen(fname); - const size_t sw_msg_1_len = strlen(sw_msg_1); - const size_t sw_msg_2_len = strlen(sw_msg_2); - - const size_t name_len = sw_msg_1_len + fname_len + sw_msg_2_len + 5; - - char *const name = xmalloc(name_len); - memcpy(name, sw_msg_1, sw_msg_1_len + 1); - home_replace(NULL, fname, name + sw_msg_1_len, fname_len, true); - xstrlcat(name, sw_msg_2, name_len); - int dialog_result - = do_dialog(VIM_WARNING, - _("VIM - ATTENTION"), - name, - proc_running - ? _("&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Abort") - : _("&Open Read-Only\n&Edit anyway\n&Recover\n&Delete it\n&Quit\n&Abort"), - 1, NULL, false); - - if (proc_running && dialog_result >= 4) { // compensate for missing "Delete it" button - dialog_result++; + choice += proc_running && choice >= 4; + // pretend screen didn't scroll, need redraw anyway + msg_reset_scroll(); + } else { + msg_outtrans(msg.items, 0, false); } - choice = (sea_choice_T)dialog_result; - xfree(name); - - // pretend screen didn't scroll, need redraw anyway - msg_reset_scroll(); + no_wait_return--; + kv_destroy(msg); + xfree(fhname); } switch (choice) { diff --git a/src/nvim/po/af.po b/src/nvim/po/af.po index 3d537a51f2..38faefb1dd 100644 --- a/src/nvim/po/af.po +++ b/src/nvim/po/af.po @@ -3575,12 +3575,8 @@ msgstr "E317: wyser blok id verkeerd 2" msgid "E325: ATTENTION" msgstr "E325: LET OP" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Het 'n ruiller gevind met die naam \"" +msgid "Found a swap file by the name \"" +msgstr "Het 'n ruiller gevind met die naam \"" msgid "While opening file \"" msgstr "Tydens oopmaak van ler \"" diff --git a/src/nvim/po/ca.po b/src/nvim/po/ca.po index 2162f13592..3c3737e76f 100644 --- a/src/nvim/po/ca.po +++ b/src/nvim/po/ca.po @@ -3976,10 +3976,8 @@ msgid "E325: ATTENTION" msgstr "E325: ATENCI" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "\nS'ha trobat un fitxer d'intercanvi amb nom \"" +msgid "Found a swap file by the name \"" +msgstr "S'ha trobat un fitxer d'intercanvi amb nom \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/cs.cp1250.po b/src/nvim/po/cs.cp1250.po index 4939a150ac..2f6e72bc44 100644 --- a/src/nvim/po/cs.cp1250.po +++ b/src/nvim/po/cs.cp1250.po @@ -4036,12 +4036,8 @@ msgid "E325: ATTENTION" msgstr "E325: POZOR" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Nalezen odkldac soubor se jmnem \"" +msgid "Found a swap file by the name \"" +msgstr "Nalezen odkldac soubor se jmnem \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/cs.po b/src/nvim/po/cs.po index 9cb552c6de..f6b062de70 100644 --- a/src/nvim/po/cs.po +++ b/src/nvim/po/cs.po @@ -4036,12 +4036,8 @@ msgid "E325: ATTENTION" msgstr "E325: POZOR" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Nalezen odkldac soubor se jmnem \"" +msgid "Found a swap file by the name \"" +msgstr "Nalezen odkldac soubor se jmnem \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/da.po b/src/nvim/po/da.po index 8a7bffdd53..1e6e6b354a 100644 --- a/src/nvim/po/da.po +++ b/src/nvim/po/da.po @@ -3636,12 +3636,8 @@ msgstr "E773: Symlink-løkke for \"%s\"" msgid "E325: ATTENTION" msgstr "E325: OBS" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Fandt en swap-fil ved navn \"" +msgid "Found a swap file by the name \"" +msgstr "Fandt en swap-fil ved navn \"" msgid "While opening file \"" msgstr "Ved åbning af filen \"" diff --git a/src/nvim/po/de.po b/src/nvim/po/de.po index 0eb72b9565..fdca801ab1 100644 --- a/src/nvim/po/de.po +++ b/src/nvim/po/de.po @@ -3399,12 +3399,8 @@ msgid "E325: ATTENTION" msgstr "E325: ACHTUNG" #: ../memline.c:3179 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Auslagerungsdatei mit folgendem Namen gefunden: \"" +msgid "Found a swap file by the name \"" +msgstr "Auslagerungsdatei mit folgendem Namen gefunden: \"" #: ../memline.c:3183 msgid "While opening file \"" diff --git a/src/nvim/po/en_GB.po b/src/nvim/po/en_GB.po index f93dcad206..9c786d106f 100644 --- a/src/nvim/po/en_GB.po +++ b/src/nvim/po/en_GB.po @@ -3817,9 +3817,7 @@ msgid "E325: ATTENTION" msgstr "" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" +msgid "Found a swap file by the name \"" msgstr "" #: ../memline.c:3226 diff --git a/src/nvim/po/eo.po b/src/nvim/po/eo.po index 4033ff8a43..d46af684a0 100644 --- a/src/nvim/po/eo.po +++ b/src/nvim/po/eo.po @@ -3504,12 +3504,8 @@ msgstr "E773: Buklo de simbolaj ligiloj por \"%s\"" msgid "E325: ATTENTION" msgstr "E325: ATENTO" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Trovis permutodosieron .swp kun la nomo \"" +msgid "Found a swap file by the name \"" +msgstr "Trovis permutodosieron .swp kun la nomo \"" msgid "While opening file \"" msgstr "Dum malfermo de dosiero \"" diff --git a/src/nvim/po/es.po b/src/nvim/po/es.po index b67c275bf3..4990558546 100644 --- a/src/nvim/po/es.po +++ b/src/nvim/po/es.po @@ -4035,12 +4035,8 @@ msgid "E325: ATTENTION" msgstr "E325: ATENCIÓN" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Se ha encontrado un archivo de intercambio con el nombre \"" +msgid "Found a swap file by the name \"" +msgstr "Se ha encontrado un archivo de intercambio con el nombre \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/fi.po b/src/nvim/po/fi.po index e1700d61ff..5ff05353c9 100644 --- a/src/nvim/po/fi.po +++ b/src/nvim/po/fi.po @@ -3633,12 +3633,8 @@ msgstr "E773: Symlinkkisilmukka kohteelle %s" msgid "E325: ATTENTION" msgstr "E325: HUOMAA" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Swap-tiedosto löytyi: \"" +msgid "Found a swap file by the name \"" +msgstr "Swap-tiedosto löytyi: \"" msgid "While opening file \"" msgstr "Avattaessa tiedostoa " diff --git a/src/nvim/po/fr.po b/src/nvim/po/fr.po index 900f5bde03..13bbb4fada 100644 --- a/src/nvim/po/fr.po +++ b/src/nvim/po/fr.po @@ -3213,12 +3213,8 @@ msgstr "E773: cycle de liens symboliques avec \"%s\"" msgid "E325: ATTENTION" msgstr "E325: ATTENTION" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Trouv un fichier d'change nomm \"" +msgid "Found a swap file by the name \"" +msgstr "Trouv un fichier d'change nomm \"" msgid "While opening file \"" msgstr "Lors de l'ouverture du fichier \"" diff --git a/src/nvim/po/ga.po b/src/nvim/po/ga.po index 902bf9fae1..2d4635fbc6 100644 --- a/src/nvim/po/ga.po +++ b/src/nvim/po/ga.po @@ -3667,12 +3667,8 @@ msgstr "E773: Ciogal i naisc shiombalacha le haghaidh \"%s\"" msgid "E325: ATTENTION" msgstr "E325: AIRE" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Fuarthas comhad babhtla darbh ainm \"" +msgid "Found a swap file by the name \"" +msgstr "Fuarthas comhad babhtla darbh ainm \"" msgid "While opening file \"" msgstr "Agus an comhad seo oscailt: \"" diff --git a/src/nvim/po/it.po b/src/nvim/po/it.po index 5caaa3c1f0..6b3c87cd3d 100644 --- a/src/nvim/po/it.po +++ b/src/nvim/po/it.po @@ -4001,12 +4001,8 @@ msgid "E325: ATTENTION" msgstr "E325: ATTENZIONE" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Trovato uno swap file di nome \"" +msgid "Found a swap file by the name \"" +msgstr "Trovato uno swap file di nome \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/ja.euc-jp.po b/src/nvim/po/ja.euc-jp.po index 02bd36efbb..dc7d30546c 100644 --- a/src/nvim/po/ja.euc-jp.po +++ b/src/nvim/po/ja.euc-jp.po @@ -3438,12 +3438,8 @@ msgstr "E773: \"%s\" msgid "E325: ATTENTION" msgstr "E325: " -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"̾ǥåץե򸫤Ĥޤ \"" +msgid "Found a swap file by the name \"" +msgstr "̾ǥåץե򸫤Ĥޤ \"" msgid "While opening file \"" msgstr "Υե򳫤Ƥ \"" diff --git a/src/nvim/po/ja.po b/src/nvim/po/ja.po index 8d417d222a..04b13c4529 100644 --- a/src/nvim/po/ja.po +++ b/src/nvim/po/ja.po @@ -5061,12 +5061,8 @@ msgstr "E773: \"%s\" のシンボリックリンクがループになってい msgid "E325: ATTENTION" msgstr "E325: 注意" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"次の名前でスワップファイルを見つけました \"" +msgid "Found a swap file by the name \"" +msgstr "次の名前でスワップファイルを見つけました \"" msgid "While opening file \"" msgstr "次のファイルを開いている最中 \"" diff --git a/src/nvim/po/ko.UTF-8.po b/src/nvim/po/ko.UTF-8.po index 66463713d7..cf59c321fb 100644 --- a/src/nvim/po/ko.UTF-8.po +++ b/src/nvim/po/ko.UTF-8.po @@ -3916,12 +3916,8 @@ msgid "E325: ATTENTION" msgstr "E325: 주목" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Found a swap file by the name \"" +msgid "Found a swap file by the name \"" +msgstr "Found a swap file by the name \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/nb.po b/src/nvim/po/nb.po index 6f10dcc232..8d50a00f4d 100644 --- a/src/nvim/po/nb.po +++ b/src/nvim/po/nb.po @@ -3937,12 +3937,8 @@ msgid "E325: ATTENTION" msgstr "E325: VIKTIG" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Fant en swapfil ved navn \"" +msgid "Found a swap file by the name \"" +msgstr "Fant en swapfil ved navn \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/nl.po b/src/nvim/po/nl.po index 75d516a67d..7609deae85 100644 --- a/src/nvim/po/nl.po +++ b/src/nvim/po/nl.po @@ -3943,12 +3943,8 @@ msgid "E325: ATTENTION" msgstr "E325: OPGELET" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Er is een wisselbestand aangetroffen met de naam \"" +msgid "Found a swap file by the name \"" +msgstr "Er is een wisselbestand aangetroffen met de naam \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/no.po b/src/nvim/po/no.po index 6f10dcc232..8d50a00f4d 100644 --- a/src/nvim/po/no.po +++ b/src/nvim/po/no.po @@ -3937,12 +3937,8 @@ msgid "E325: ATTENTION" msgstr "E325: VIKTIG" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Fant en swapfil ved navn \"" +msgid "Found a swap file by the name \"" +msgstr "Fant en swapfil ved navn \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/pl.UTF-8.po b/src/nvim/po/pl.UTF-8.po index 521edb383d..e20a808d6e 100644 --- a/src/nvim/po/pl.UTF-8.po +++ b/src/nvim/po/pl.UTF-8.po @@ -3909,12 +3909,8 @@ msgid "E325: ATTENTION" msgstr "E325: UWAGA" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Znalazłem plik wymiany o nazwie \"" +msgid "Found a swap file by the name \"" +msgstr "Znalazłem plik wymiany o nazwie \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/pt_BR.po b/src/nvim/po/pt_BR.po index 4e7225fc9c..b19a52127b 100644 --- a/src/nvim/po/pt_BR.po +++ b/src/nvim/po/pt_BR.po @@ -584,12 +584,8 @@ msgid "E325: ATTENTION" msgstr "E325: ATENO" #: ../memline.c:3181 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Foi encontrado um arquivo de troca de nome \"" +msgid "Found a swap file by the name \"" +msgstr "Foi encontrado um arquivo de troca de nome \"" #: ../memline.c:3185 msgid "While opening file \"" diff --git a/src/nvim/po/ru.po b/src/nvim/po/ru.po index 90dc5b2d8e..fc38f94597 100644 --- a/src/nvim/po/ru.po +++ b/src/nvim/po/ru.po @@ -3946,12 +3946,8 @@ msgid "E325: ATTENTION" msgstr "E325: ВНИМАНИЕ" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Обнаружен своп-файл с именем \"" +msgid "Found a swap file by the name \"" +msgstr "Обнаружен своп-файл с именем \"" # С маленькой буквы, чтобы соответствовало по стилю соседним сообщениям. #: ../memline.c:3226 diff --git a/src/nvim/po/sk.cp1250.po b/src/nvim/po/sk.cp1250.po index 394b5aff01..4a862abd31 100644 --- a/src/nvim/po/sk.cp1250.po +++ b/src/nvim/po/sk.cp1250.po @@ -3934,12 +3934,8 @@ msgid "E325: ATTENTION" msgstr "E325: POZOR" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Njden odkladac sbor s menom \"" +msgid "Found a swap file by the name \"" +msgstr "Njden odkladac sbor s menom \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/src/nvim/po/sr.po b/src/nvim/po/sr.po index 79b6747921..b4cc417650 100644 --- a/src/nvim/po/sr.po +++ b/src/nvim/po/sr.po @@ -4021,12 +4021,8 @@ msgstr "E773: Symlink петља за \"%s\"" msgid "E325: ATTENTION" msgstr "E325: ПАЖЊА" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Пронађена је swap датотека под именом \"" +msgid "Found a swap file by the name \"" +msgstr "Пронађена је swap датотека под именом \"" msgid "While opening file \"" msgstr "Док се отварала датотекa \"" diff --git a/src/nvim/po/sv.po b/src/nvim/po/sv.po index 285dadb595..96bc4c655a 100644 --- a/src/nvim/po/sv.po +++ b/src/nvim/po/sv.po @@ -6135,12 +6135,8 @@ msgid "E325: ATTENTION" msgstr "E325: LYSTRING" #: ../memline.c:3175 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Hittade en vxlingsfil med namnet \"" +msgid "Found a swap file by the name \"" +msgstr "Hittade en vxlingsfil med namnet \"" #: ../memline.c:3179 msgid "While opening file \"" diff --git a/src/nvim/po/tr.po b/src/nvim/po/tr.po index e73c033a4e..4503bfc4af 100644 --- a/src/nvim/po/tr.po +++ b/src/nvim/po/tr.po @@ -3917,12 +3917,8 @@ msgstr "E773: \"%s\" için sembol bağı döngüsü" msgid "E325: ATTENTION" msgstr "E325: DİKKAT" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Şu adla bir takas dosyası bulundu: \"" +msgid "Found a swap file by the name \"" +msgstr "Şu adla bir takas dosyası bulundu: \"" msgid "While opening file \"" msgstr "şu dosya açılırken: \"" diff --git a/src/nvim/po/uk.po b/src/nvim/po/uk.po index 25b31dac9b..c0c239b136 100644 --- a/src/nvim/po/uk.po +++ b/src/nvim/po/uk.po @@ -5078,12 +5078,8 @@ msgstr "E773: Циклічні символьні посилання «%s»" msgid "E325: ATTENTION" msgstr "E325: УВАГА" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Знайдено файл обміну з назвою \"" +msgid "Found a swap file by the name \"" +msgstr "Знайдено файл обміну з назвою \"" msgid "While opening file \"" msgstr "При відкритті файлу \"" diff --git a/src/nvim/po/vi.po b/src/nvim/po/vi.po index b976d39647..acecdee093 100644 --- a/src/nvim/po/vi.po +++ b/src/nvim/po/vi.po @@ -3004,12 +3004,8 @@ msgstr "E317: Giá trị của cái chỉ (pointer) khối số 2 không đúng" msgid "E325: ATTENTION" msgstr "E325: CHÚ Ý" -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"Tìm thấy một tập tin trao đổi (swap) với tên \"" +msgid "Found a swap file by the name \"" +msgstr "Tìm thấy một tập tin trao đổi (swap) với tên \"" msgid "While opening file \"" msgstr "Khi mở tập tin: \"" diff --git a/src/nvim/po/zh_CN.UTF-8.po b/src/nvim/po/zh_CN.UTF-8.po index 3593175572..b75308695e 100644 --- a/src/nvim/po/zh_CN.UTF-8.po +++ b/src/nvim/po/zh_CN.UTF-8.po @@ -4741,12 +4741,8 @@ msgid "E325: ATTENTION" msgstr "E325: 注意" #: ../memline.c:3073 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"发现交换文件 \"" +msgid "Found a swap file by the name \"" +msgstr "发现交换文件 \"" #: ../memline.c:3077 msgid "While opening file \"" diff --git a/src/nvim/po/zh_TW.UTF-8.po b/src/nvim/po/zh_TW.UTF-8.po index 04e11a9193..578464bbe3 100644 --- a/src/nvim/po/zh_TW.UTF-8.po +++ b/src/nvim/po/zh_TW.UTF-8.po @@ -3977,12 +3977,8 @@ msgid "E325: ATTENTION" msgstr "E325: 注意" #: ../memline.c:3222 -msgid "" -"\n" -"Found a swap file by the name \"" -msgstr "" -"\n" -"找到暫存檔 \"" +msgid "Found a swap file by the name \"" +msgstr "找到暫存檔 \"" #: ../memline.c:3226 msgid "While opening file \"" diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index 99a364d0e7..114f86980b 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -186,6 +186,8 @@ pcall(vim.cmd.edit, 'Xtest_swapredraw.lua') foreground = Screen.colors.NvimDarkGrey3, background = Screen.colors.NvimLightGrey3, }, + [107] = { foreground = Screen.colors.NvimLightGrey2, bold = true }, + [108] = { foreground = Screen.colors.NvimLightBlue }, }) exec(init) command('autocmd! nvim.swapfile') -- Delete the default handler (which skips the dialog). @@ -322,11 +324,6 @@ pcall(vim.cmd.edit, 'Xtest_swapredraw.lua') command('preserve') -- Make sure the swap file exists. local screen = Screen.new(75, 18) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg - }) - local nvim1 = n.new_session(true) set_session(nvim1) screen:attach() @@ -335,13 +332,18 @@ pcall(vim.cmd.edit, 'Xtest_swapredraw.lua') feed(':split Xfile1\n') -- The default SwapExists handler does _not_ skip this prompt. screen:expect({ - any = pesc('{1:[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: }^'), + any = pesc('{6:[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: }^'), }) feed('q') + screen:expect([[ + ^ | + {1:~ }|*16 + | + ]]) feed(':') screen:expect([[ ^ | - {0:~ }|*16 + {1:~ }|*16 : | ]]) nvim1:close() @@ -354,16 +356,16 @@ pcall(vim.cmd.edit, 'Xtest_swapredraw.lua') command('set more') command('au bufadd * let foo_w = wincol()') feed(':e Xfile1') - screen:expect({ any = pesc('{1:-- More --}^') }) + screen:expect({ any = pesc('{6:-- More --}^') }) feed('') screen:expect({ - any = pesc('{1:[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: }^'), + any = pesc('{6:[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: }^'), }) feed('q') command([[echo 'hello']]) screen:expect([[ ^ | - {0:~ }|*16 + {1:~ }|*16 hello | ]]) nvim2:close() @@ -373,11 +375,6 @@ pcall(vim.cmd.edit, 'Xtest_swapredraw.lua') --- @param on_swapfile_running fun(screen: any) Called after swapfile ("STILL RUNNING") prompt. local function test_swapfile_after_reboot(swapexists, on_swapfile_running) local screen = Screen.new(75, 30) - screen:set_default_attr_ids({ - [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText - [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg - [2] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg - }) exec(init) if not swapexists then @@ -437,8 +434,8 @@ pcall(vim.cmd.edit, 'Xtest_swapredraw.lua') feed(':edit Xswaptest') screen:expect({ any = table.concat({ - pesc('{2:E325: ATTENTION}'), - pesc('{1:[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: }^'), + '{9:E325: ATTENTION}', + pesc('{6:[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: }^'), }, '.*'), }) @@ -450,10 +447,10 @@ pcall(vim.cmd.edit, 'Xtest_swapredraw.lua') test_swapfile_after_reboot(false, function(screen) screen:expect({ any = table.concat({ - pesc('{2:E325: ATTENTION}'), - '\n process ID: %d* %(STILL RUNNING%)', - '\nWhile opening file "Xswaptest"', - pesc('{1:[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: }^'), + '{9:E325: ATTENTION}', + '{6: process ID: %d* %(STILL RUNNING%)}', + '{6:While opening file "Xswaptest"}', + pesc('{6:[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: }^'), }, '.*'), }) end)