patch 9.1.1135: 'suffixesadd' doesn't work with multiple items
Problem: 'suffixesadd' doesn't work with multiple items
(after 9.1.1122).
Solution: Don't concat multiple suffixes together.
(zeertzjq)
fixes: #16694
closes: #16699
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/findfile.c b/src/findfile.c
index ccb3ef8..2bd1e7e 100644
--- a/src/findfile.c
+++ b/src/findfile.c
@@ -1082,6 +1082,7 @@
* Try without extra suffix and then with suffixes
* from 'suffixesadd'.
*/
+ len = file_path.length;
if (search_ctx->ffsc_tagfile)
suf = (char_u *)"";
else
@@ -1164,8 +1165,8 @@
// Not found or found already, try next suffix.
if (*suf == NUL)
break;
- file_path.length += copy_option_part(&suf, file_path.string + file_path.length,
- MAXPATHL - file_path.length, ",");
+ file_path.length = len + copy_option_part(&suf,
+ file_path.string + len, MAXPATHL - len, ",");
}
}
}
@@ -1872,6 +1873,7 @@
if (first == TRUE)
{
int l;
+ int NameBufflen;
int run;
size_t rel_fnamelen = 0;
char_u *suffix;
@@ -1912,6 +1914,7 @@
// When the file doesn't exist, try adding parts of
// 'suffixesadd'.
+ NameBufflen = l;
suffix = suffixes;
for (;;)
{
@@ -1920,12 +1923,13 @@
|| ((find_what == FINDFILE_DIR)
== mch_isdir(NameBuff))))
{
- file_name = vim_strnsave(NameBuff, l);
+ file_name = vim_strnsave(NameBuff, NameBufflen);
goto theend;
}
if (*suffix == NUL)
break;
- l += copy_option_part(&suffix, NameBuff + l, MAXPATHL - l, ",");
+ NameBufflen = l + copy_option_part(&suffix, NameBuff + l,
+ MAXPATHL - l, ",");
}
}
}