From 5cead869fb6ddc57594c0dc7e6e575f9427630c8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 22 Feb 2025 16:38:12 +0800 Subject: vim-patch:9.1.1135: 'suffixesadd' doesn't work with multiple items (#32573) Problem: 'suffixesadd' doesn't work with multiple items (after 9.1.1122). Solution: Don't concat multiple suffixes together. (zeertzjq) fixes: vim/vim#16694 closes: vim/vim#16699 https://github.com/vim/vim/commit/bf595ae4ac9ecc1e0620664177072926ed3679ff --- src/nvim/file_search.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/nvim/file_search.c') diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index c374322d22..8ca0676a0f 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -856,6 +856,7 @@ char *vim_findfile(void *search_ctx_arg) // Try without extra suffix and then with suffixes // from 'suffixesadd'. + len = file_path.size; char *suf = search_ctx->ffsc_tagfile ? "" : curbuf->b_p_sua; while (true) { // if file exists and we didn't already find it @@ -916,8 +917,8 @@ char *vim_findfile(void *search_ctx_arg) break; } assert(MAXPATHL >= file_path.size); - file_path.size += copy_option_part(&suf, file_path.data + file_path.size, - MAXPATHL - file_path.size, ","); + file_path.size = len + copy_option_part(&suf, file_path.data + len, + MAXPATHL - len, ","); } } } else { @@ -1515,20 +1516,20 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch } // When the file doesn't exist, try adding parts of 'suffixesadd'. + size_t NameBufflen = l; char *suffix = suffixes; while (true) { if ((os_path_exists(NameBuff) && (find_what == FINDFILE_BOTH - || ((find_what == FINDFILE_DIR) - == os_isdir(NameBuff))))) { - file_name = xmemdupz(NameBuff, l); + || ((find_what == FINDFILE_DIR) == os_isdir(NameBuff))))) { + file_name = xmemdupz(NameBuff, NameBufflen); goto theend; } if (*suffix == NUL) { break; } assert(MAXPATHL >= l); - l += copy_option_part(&suffix, NameBuff + l, MAXPATHL - l, ","); + NameBufflen = l + copy_option_part(&suffix, NameBuff + l, MAXPATHL - l, ","); } } } -- cgit