patch 9.1.1389: completion: still some issue when 'isexpand' contains a space
Problem: Cannot get completion startcol when space is not the first
trigger character (after v9.1.1383)
Solution: Detect the next comma followed by a space in the option string
and use in next compare loop (glepnir)
closes: #17311
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/insexpand.c b/src/insexpand.c
index 5f5a5b9..76fb8f3 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -3660,20 +3660,28 @@
}
else
{
- char_u *p = ise;
+ char_u *p = ise;
+ char_u *p_space = NULL;
+
cur_end = before_cursor + (int)STRLEN(before_cursor);
while (*p != NUL)
{
int len = 0;
- if (*p == ',' && *(p+1) == ' ' && (*(p+2) == ',' || *(p+2) == NUL))
+ if (p_space)
{
- part[0] = ' ';
- len = 1;
- p++;
+ len = p - p_space - 1;
+ memcpy(part, p_space + 1, len);
+ p_space = NULL;
}
else
+ {
+ char_u *next_comma = vim_strchr((*p == ',') ? p + 1 : p, ',');
+ if (next_comma && *(next_comma + 1) == ' ')
+ p_space = next_comma;
+
len = copy_option_part(&p, part, MAXPATHL, ",");
+ }
if (len > 0 && len <= col)
{