diff options
Diffstat (limited to 'src/nvim/memline.c')
-rw-r--r-- | src/nvim/memline.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 0c38f18739..cb58cbc86f 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -762,7 +762,7 @@ void ml_recover(bool checkext) directly = false; // count the number of matching swap files - len = recover_names(fname, false, 0, NULL); + len = recover_names(fname, false, NULL, 0, NULL); if (len == 0) { // no swap files found semsg(_("E305: No swap file found for %s"), fname); goto theend; @@ -772,7 +772,7 @@ void ml_recover(bool checkext) i = 1; } else { // several swap files found, choose // list the names of the swap files - (void)recover_names(fname, true, 0, NULL); + (void)recover_names(fname, true, NULL, 0, NULL); msg_putchar('\n'); msg_puts(_("Enter number of swap file to use (0 to quit): ")); i = get_number(false, NULL); @@ -781,7 +781,7 @@ void ml_recover(bool checkext) } } // get the swap file name that will be used - (void)recover_names(fname, false, i, &fname_used); + (void)recover_names(fname, false, NULL, i, &fname_used); } if (fname_used == NULL) { goto theend; // user chose invalid number. @@ -1200,13 +1200,15 @@ theend: /// - list the swap files for "vim -r" /// - count the number of swap files when recovering /// - list the swap files when recovering +/// - list the swap files for swapfilelist() /// - find the name of the n'th swap file when recovering /// /// @param fname base for swap file name -/// @param list when true, list the swap file names +/// @param do_list when true, list the swap file names +/// @param ret_list when not NULL add file names to it /// @param nr when non-zero, return nr'th swap file name /// @param fname_out result when "nr" > 0 -int recover_names(char *fname, int list, int nr, char **fname_out) +int recover_names(char *fname, bool do_list, list_T *ret_list, int nr, char **fname_out) { int num_names; char *(names[6]); @@ -1230,7 +1232,7 @@ int recover_names(char *fname, int list, int nr, char **fname_out) fname_res = fname; } - if (list) { + if (do_list) { // use msg() to start the scrolling properly msg(_("Swap files found:")); msg_putchar('\n'); @@ -1306,9 +1308,11 @@ int recover_names(char *fname, int list, int nr, char **fname_out) } } - // remove swapfile name of the current buffer, it must be ignored + // Remove swapfile name of the current buffer, it must be ignored. + // But keep it for swapfilelist(). if (curbuf->b_ml.ml_mfp != NULL - && (p = curbuf->b_ml.ml_mfp->mf_fname) != NULL) { + && (p = curbuf->b_ml.ml_mfp->mf_fname) != NULL + && ret_list == NULL) { for (int i = 0; i < num_files; i++) { // Do not expand wildcards, on Windows would try to expand // "%tmp%" in "%tmp%file" @@ -1333,7 +1337,7 @@ int recover_names(char *fname, int list, int nr, char **fname_out) *fname_out = xstrdup(files[nr - 1 + num_files - file_count]); dirp = ""; // stop searching } - } else if (list) { + } else if (do_list) { if (dir_name[0] == '.' && dir_name[1] == NUL) { if (fname == NULL) { msg_puts(_(" In current directory:\n")); @@ -1359,6 +1363,11 @@ int recover_names(char *fname, int list, int nr, char **fname_out) msg_puts(_(" -- none --\n")); } ui_flush(); + } else if (ret_list != NULL) { + for (int i = 0; i < num_files; i++) { + char *name = concat_fnames(dir_name, files[i], true); + tv_list_append_allocated_string(ret_list, name); + } } else { file_count += num_files; } |