forked from aniani/vim
patch 9.0.1961: 'listchars' completion misses "multispace" and "leadmultispace"
Problem: Cmdline completion for 'listchars' fields doesn't include "multispace" and "leadmultispace" (after 9.0.1958). Solution: Include "multispace" and "leadmultispace" in lcstab. closes: #13225 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
committed by
Christian Brabandt
parent
f7f746b167
commit
1f025b01e2
160
src/screen.c
160
src/screen.c
@@ -4693,6 +4693,8 @@ static struct charstab lcstab[] =
|
|||||||
#else
|
#else
|
||||||
{NULL, "conceal"},
|
{NULL, "conceal"},
|
||||||
#endif
|
#endif
|
||||||
|
{NULL, "multispace"},
|
||||||
|
{NULL, "leadmultispace"},
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -4706,7 +4708,7 @@ static struct charstab lcstab[] =
|
|||||||
static char *
|
static char *
|
||||||
set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
|
set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
|
||||||
{
|
{
|
||||||
int round, i, len, len2, entries;
|
int round, i, len, entries;
|
||||||
char_u *p, *s;
|
char_u *p, *s;
|
||||||
int c1 = 0, c2 = 0, c3 = 0;
|
int c1 = 0, c2 = 0, c3 = 0;
|
||||||
char_u *last_multispace = NULL; // Last occurrence of "multispace:"
|
char_u *last_multispace = NULL; // Last occurrence of "multispace:"
|
||||||
@@ -4784,10 +4786,82 @@ set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
|
|||||||
for (i = 0; i < entries; ++i)
|
for (i = 0; i < entries; ++i)
|
||||||
{
|
{
|
||||||
len = (int)STRLEN(tab[i].name);
|
len = (int)STRLEN(tab[i].name);
|
||||||
if (STRNCMP(p, tab[i].name, len) == 0
|
if (!(STRNCMP(p, tab[i].name, len) == 0
|
||||||
&& p[len] == ':'
|
&& p[len] == ':'
|
||||||
&& p[len + 1] != NUL)
|
&& p[len + 1] != NUL))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (is_listchars && strcmp(tab[i].name, "multispace") == 0)
|
||||||
{
|
{
|
||||||
|
s = p + len + 1;
|
||||||
|
if (round == 0)
|
||||||
|
{
|
||||||
|
// Get length of lcs-multispace string in first round
|
||||||
|
last_multispace = p;
|
||||||
|
multispace_len = 0;
|
||||||
|
while (*s != NUL && *s != ',')
|
||||||
|
{
|
||||||
|
c1 = get_encoded_char_adv(&s);
|
||||||
|
if (char2cells(c1) > 1)
|
||||||
|
return e_invalid_argument;
|
||||||
|
++multispace_len;
|
||||||
|
}
|
||||||
|
if (multispace_len == 0)
|
||||||
|
// lcs-multispace cannot be an empty string
|
||||||
|
return e_invalid_argument;
|
||||||
|
p = s;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int multispace_pos = 0;
|
||||||
|
|
||||||
|
while (*s != NUL && *s != ',')
|
||||||
|
{
|
||||||
|
c1 = get_encoded_char_adv(&s);
|
||||||
|
if (p == last_multispace)
|
||||||
|
lcs_chars.multispace[multispace_pos++] = c1;
|
||||||
|
}
|
||||||
|
p = s;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_listchars && strcmp(tab[i].name, "leadmultispace") == 0)
|
||||||
|
{
|
||||||
|
s = p + len + 1;
|
||||||
|
if (round == 0)
|
||||||
|
{
|
||||||
|
// get length of lcs-leadmultispace string in first
|
||||||
|
// round
|
||||||
|
last_lmultispace = p;
|
||||||
|
lead_multispace_len = 0;
|
||||||
|
while (*s != NUL && *s != ',')
|
||||||
|
{
|
||||||
|
c1 = get_encoded_char_adv(&s);
|
||||||
|
if (char2cells(c1) > 1)
|
||||||
|
return e_invalid_argument;
|
||||||
|
++lead_multispace_len;
|
||||||
|
}
|
||||||
|
if (lead_multispace_len == 0)
|
||||||
|
// lcs-leadmultispace cannot be an empty string
|
||||||
|
return e_invalid_argument;
|
||||||
|
p = s;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int multispace_pos = 0;
|
||||||
|
|
||||||
|
while (*s != NUL && *s != ',')
|
||||||
|
{
|
||||||
|
c1 = get_encoded_char_adv(&s);
|
||||||
|
if (p == last_lmultispace)
|
||||||
|
lcs_chars.leadmultispace[multispace_pos++] = c1;
|
||||||
|
}
|
||||||
|
p = s;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
c2 = c3 = 0;
|
c2 = c3 = 0;
|
||||||
s = p + len + 1;
|
s = p + len + 1;
|
||||||
c1 = get_encoded_char_adv(&s);
|
c1 = get_encoded_char_adv(&s);
|
||||||
@@ -4826,89 +4900,9 @@ set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (i == entries)
|
if (i == entries)
|
||||||
{
|
|
||||||
len = (int)STRLEN("multispace");
|
|
||||||
len2 = (int)STRLEN("leadmultispace");
|
|
||||||
if (is_listchars
|
|
||||||
&& STRNCMP(p, "multispace", len) == 0
|
|
||||||
&& p[len] == ':'
|
|
||||||
&& p[len + 1] != NUL)
|
|
||||||
{
|
|
||||||
s = p + len + 1;
|
|
||||||
if (round == 0)
|
|
||||||
{
|
|
||||||
// Get length of lcs-multispace string in first round
|
|
||||||
last_multispace = p;
|
|
||||||
multispace_len = 0;
|
|
||||||
while (*s != NUL && *s != ',')
|
|
||||||
{
|
|
||||||
c1 = get_encoded_char_adv(&s);
|
|
||||||
if (char2cells(c1) > 1)
|
|
||||||
return e_invalid_argument;
|
return e_invalid_argument;
|
||||||
++multispace_len;
|
|
||||||
}
|
|
||||||
if (multispace_len == 0)
|
|
||||||
// lcs-multispace cannot be an empty string
|
|
||||||
return e_invalid_argument;
|
|
||||||
p = s;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int multispace_pos = 0;
|
|
||||||
|
|
||||||
while (*s != NUL && *s != ',')
|
|
||||||
{
|
|
||||||
c1 = get_encoded_char_adv(&s);
|
|
||||||
if (p == last_multispace)
|
|
||||||
lcs_chars.multispace[multispace_pos++] = c1;
|
|
||||||
}
|
|
||||||
p = s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (is_listchars
|
|
||||||
&& STRNCMP(p, "leadmultispace", len2) == 0
|
|
||||||
&& p[len2] == ':'
|
|
||||||
&& p[len2 + 1] != NUL)
|
|
||||||
{
|
|
||||||
s = p + len2 + 1;
|
|
||||||
if (round == 0)
|
|
||||||
{
|
|
||||||
// get length of lcs-leadmultispace string in first
|
|
||||||
// round
|
|
||||||
last_lmultispace = p;
|
|
||||||
lead_multispace_len = 0;
|
|
||||||
while (*s != NUL && *s != ',')
|
|
||||||
{
|
|
||||||
c1 = get_encoded_char_adv(&s);
|
|
||||||
if (char2cells(c1) > 1)
|
|
||||||
return e_invalid_argument;
|
|
||||||
++lead_multispace_len;
|
|
||||||
}
|
|
||||||
if (lead_multispace_len == 0)
|
|
||||||
// lcs-leadmultispace cannot be an empty string
|
|
||||||
return e_invalid_argument;
|
|
||||||
p = s;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int multispace_pos = 0;
|
|
||||||
|
|
||||||
while (*s != NUL && *s != ',')
|
|
||||||
{
|
|
||||||
c1 = get_encoded_char_adv(&s);
|
|
||||||
if (p == last_lmultispace)
|
|
||||||
lcs_chars.leadmultispace[multispace_pos++] = c1;
|
|
||||||
}
|
|
||||||
p = s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return e_invalid_argument;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*p == ',')
|
if (*p == ',')
|
||||||
++p;
|
++p;
|
||||||
|
@@ -517,10 +517,12 @@ func Test_set_completion_string_values()
|
|||||||
call assert_equal(getcompletion('set printoptions=', 'cmdline')[0], 'top')
|
call assert_equal(getcompletion('set printoptions=', 'cmdline')[0], 'top')
|
||||||
call assert_equal(getcompletion('set wincolor=', 'cmdline')[0], 'SpecialKey')
|
call assert_equal(getcompletion('set wincolor=', 'cmdline')[0], 'SpecialKey')
|
||||||
|
|
||||||
call assert_equal(getcompletion('set listchars+=', 'cmdline')[0], 'eol')
|
call assert_equal('eol', getcompletion('set listchars+=', 'cmdline')[0])
|
||||||
call assert_equal(getcompletion('setl listchars+=', 'cmdline')[0], 'eol')
|
call assert_equal(['multispace', 'leadmultispace'], getcompletion('set listchars+=', 'cmdline')[-2:])
|
||||||
call assert_equal(getcompletion('set fillchars+=', 'cmdline')[0], 'stl')
|
call assert_equal('eol', getcompletion('setl listchars+=', 'cmdline')[0])
|
||||||
call assert_equal(getcompletion('setl fillchars+=', 'cmdline')[0], 'stl')
|
call assert_equal(['multispace', 'leadmultispace'], getcompletion('setl listchars+=', 'cmdline')[-2:])
|
||||||
|
call assert_equal('stl', getcompletion('set fillchars+=', 'cmdline')[0])
|
||||||
|
call assert_equal('stl', getcompletion('setl fillchars+=', 'cmdline')[0])
|
||||||
|
|
||||||
"
|
"
|
||||||
" Unique string options below
|
" Unique string options below
|
||||||
|
@@ -699,6 +699,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1961,
|
||||||
/**/
|
/**/
|
||||||
1960,
|
1960,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user