mirror of
https://github.com/vim/vim.git
synced 2025-09-07 22:03:36 -04:00
patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Problem: GUI tests fail because the test doesn't use a modifier. Solution: Add "\{xxx}" to be able to encode a modifier.
This commit is contained in:
parent
363d6148df
commit
ebe9d34aa0
@ -1353,6 +1353,9 @@ A string constant accepts these special characters:
|
|||||||
To use the double quote character it must be escaped: "<M-\">".
|
To use the double quote character it must be escaped: "<M-\">".
|
||||||
Don't use <Char-xxxx> to get a utf-8 character, use \uxxxx as
|
Don't use <Char-xxxx> to get a utf-8 character, use \uxxxx as
|
||||||
mentioned above.
|
mentioned above.
|
||||||
|
\{xxx} like \<xxx> but prepends a modifier instead of including it in the
|
||||||
|
character. E.g. "\<C-w>" is one character 0x17 while "\{C-w}" is four
|
||||||
|
bytes: 3 for the CTRL modifier and then character "W".
|
||||||
|
|
||||||
Note that "\xff" is stored as the byte 255, which may be invalid in some
|
Note that "\xff" is stored as the byte 255, which may be invalid in some
|
||||||
encodings. Use "\u00ff" to store character 255 according to the current value
|
encodings. Use "\u00ff" to store character 255 according to the current value
|
||||||
|
@ -4755,8 +4755,7 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx)
|
|||||||
char_u *p_actext;
|
char_u *p_actext;
|
||||||
|
|
||||||
p_actext = menu->actext;
|
p_actext = menu->actext;
|
||||||
key = find_special_key(&p_actext, &modifiers, FALSE, FALSE, FALSE,
|
key = find_special_key(&p_actext, &modifiers, FSK_SIMPLIFY, NULL);
|
||||||
TRUE, NULL);
|
|
||||||
if (*p_actext != 0)
|
if (*p_actext != 0)
|
||||||
key = 0; // error: trailing text
|
key = 0; // error: trailing text
|
||||||
// find_special_key() returns a keycode with as many of the
|
// find_special_key() returns a keycode with as many of the
|
||||||
|
@ -1412,8 +1412,7 @@ do_highlight(
|
|||||||
*/
|
*/
|
||||||
for (p = arg, off = 0; off < 100 - 6 && *p; )
|
for (p = arg, off = 0; off < 100 - 6 && *p; )
|
||||||
{
|
{
|
||||||
len = trans_special(&p, buf + off, FALSE, FALSE,
|
len = trans_special(&p, buf + off, FSK_SIMPLIFY, NULL);
|
||||||
TRUE, NULL);
|
|
||||||
if (len > 0) // recognized special char
|
if (len > 0) // recognized special char
|
||||||
off += len;
|
off += len;
|
||||||
else // copy as normal char
|
else // copy as normal char
|
||||||
|
36
src/misc2.c
36
src/misc2.c
@ -2703,20 +2703,17 @@ get_special_key_name(int c, int modifiers)
|
|||||||
trans_special(
|
trans_special(
|
||||||
char_u **srcp,
|
char_u **srcp,
|
||||||
char_u *dst,
|
char_u *dst,
|
||||||
int keycode, // prefer key code, e.g. K_DEL instead of DEL
|
int flags, // FSK_ values
|
||||||
int in_string, // TRUE when inside a double quoted string
|
int *did_simplify) // FSK_SIMPLIFY and found <C-H> or <A-x>
|
||||||
int simplify, // simplify <C-H> and <A-x>
|
|
||||||
int *did_simplify) // found <C-H> or <A-x>
|
|
||||||
{
|
{
|
||||||
int modifiers = 0;
|
int modifiers = 0;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
key = find_special_key(srcp, &modifiers, keycode, FALSE, in_string,
|
key = find_special_key(srcp, &modifiers, flags, did_simplify);
|
||||||
simplify, did_simplify);
|
|
||||||
if (key == 0)
|
if (key == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return special_to_buf(key, modifiers, keycode, dst);
|
return special_to_buf(key, modifiers, flags & FSK_KEYCODE, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2764,24 +2761,23 @@ special_to_buf(int key, int modifiers, int keycode, char_u *dst)
|
|||||||
find_special_key(
|
find_special_key(
|
||||||
char_u **srcp,
|
char_u **srcp,
|
||||||
int *modp,
|
int *modp,
|
||||||
int keycode, // prefer key code, e.g. K_DEL instead of DEL
|
int flags, // FSK_ values
|
||||||
int keep_x_key, // don't translate xHome to Home key
|
|
||||||
int in_string, // TRUE in string, double quote is escaped
|
|
||||||
int simplify, // simplify <C-H> and <A-x>
|
|
||||||
int *did_simplify) // found <C-H> or <A-x>
|
int *did_simplify) // found <C-H> or <A-x>
|
||||||
{
|
{
|
||||||
char_u *last_dash;
|
char_u *last_dash;
|
||||||
char_u *end_of_name;
|
char_u *end_of_name;
|
||||||
char_u *src;
|
char_u *src;
|
||||||
char_u *bp;
|
char_u *bp;
|
||||||
|
int in_string = flags & FSK_IN_STRING;
|
||||||
int modifiers;
|
int modifiers;
|
||||||
int bit;
|
int bit;
|
||||||
int key;
|
int key;
|
||||||
|
int endchar = (flags & FSK_CURLY) ? '}' : '>';
|
||||||
uvarnumber_T n;
|
uvarnumber_T n;
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
src = *srcp;
|
src = *srcp;
|
||||||
if (src[0] != '<')
|
if (src[0] != ((flags & FSK_CURLY) ? '{' : '<'))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Find end of modifier list
|
// Find end of modifier list
|
||||||
@ -2800,15 +2796,15 @@ find_special_key(
|
|||||||
// Anything accepted, like <C-?>.
|
// Anything accepted, like <C-?>.
|
||||||
// <C-"> or <M-"> are not special in strings as " is
|
// <C-"> or <M-"> are not special in strings as " is
|
||||||
// the string delimiter. With a backslash it works: <M-\">
|
// the string delimiter. With a backslash it works: <M-\">
|
||||||
if (!(in_string && bp[1] == '"') && bp[l + 1] == '>')
|
if (!(in_string && bp[1] == '"') && bp[l + 1] == endchar)
|
||||||
bp += l;
|
bp += l;
|
||||||
else if (in_string && bp[1] == '\\' && bp[2] == '"'
|
else if (in_string && bp[1] == '\\' && bp[2] == '"'
|
||||||
&& bp[3] == '>')
|
&& bp[3] == endchar)
|
||||||
bp += 2;
|
bp += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
|
if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
|
||||||
bp += 3; // skip t_xx, xx may be '-' or '>'
|
bp += 3; // skip t_xx, xx may be '-' or '>'/'}'
|
||||||
else if (STRNICMP(bp, "char-", 5) == 0)
|
else if (STRNICMP(bp, "char-", 5) == 0)
|
||||||
{
|
{
|
||||||
vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, TRUE);
|
vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, TRUE);
|
||||||
@ -2822,7 +2818,7 @@ find_special_key(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*bp == '>') // found matching '>'
|
if (*bp == endchar) // found matching '>' or '}'
|
||||||
{
|
{
|
||||||
end_of_name = bp + 1;
|
end_of_name = bp + 1;
|
||||||
|
|
||||||
@ -2868,12 +2864,12 @@ find_special_key(
|
|||||||
l = mb_ptr2len(last_dash + off);
|
l = mb_ptr2len(last_dash + off);
|
||||||
else
|
else
|
||||||
l = 1;
|
l = 1;
|
||||||
if (modifiers != 0 && last_dash[l + off] == '>')
|
if (modifiers != 0 && last_dash[l + off] == endchar)
|
||||||
key = PTR2CHAR(last_dash + off);
|
key = PTR2CHAR(last_dash + off);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = get_special_key_code(last_dash + off);
|
key = get_special_key_code(last_dash + off);
|
||||||
if (!keep_x_key)
|
if (!(flags & FSK_KEEP_X_KEY))
|
||||||
key = handle_x_keys(key);
|
key = handle_x_keys(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2890,7 +2886,7 @@ find_special_key(
|
|||||||
*/
|
*/
|
||||||
key = simplify_key(key, &modifiers);
|
key = simplify_key(key, &modifiers);
|
||||||
|
|
||||||
if (!keycode)
|
if (!(flags & FSK_KEYCODE))
|
||||||
{
|
{
|
||||||
// don't want keycode, use single byte code
|
// don't want keycode, use single byte code
|
||||||
if (key == K_BS)
|
if (key == K_BS)
|
||||||
@ -2902,7 +2898,7 @@ find_special_key(
|
|||||||
// Normal Key with modifier: Try to make a single byte code.
|
// Normal Key with modifier: Try to make a single byte code.
|
||||||
if (!IS_SPECIAL(key))
|
if (!IS_SPECIAL(key))
|
||||||
key = extract_modifiers(key, &modifiers,
|
key = extract_modifiers(key, &modifiers,
|
||||||
simplify, did_simplify);
|
flags & FSK_SIMPLIFY, did_simplify);
|
||||||
|
|
||||||
*modp = modifiers;
|
*modp = modifiers;
|
||||||
*srcp = end_of_name;
|
*srcp = end_of_name;
|
||||||
|
@ -4330,7 +4330,8 @@ find_key_option(char_u *arg_arg, int has_lt)
|
|||||||
{
|
{
|
||||||
--arg; // put arg at the '<'
|
--arg; // put arg at the '<'
|
||||||
modifiers = 0;
|
modifiers = 0;
|
||||||
key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE, TRUE, NULL);
|
key = find_special_key(&arg, &modifiers,
|
||||||
|
FSK_KEYCODE | FSK_KEEP_X_KEY | FSK_SIMPLIFY, NULL);
|
||||||
if (modifiers) // can't handle modifiers here
|
if (modifiers) // can't handle modifiers here
|
||||||
key = 0;
|
key = 0;
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,9 @@ void append_ga_line(garray_T *gap);
|
|||||||
int simplify_key(int key, int *modifiers);
|
int simplify_key(int key, int *modifiers);
|
||||||
int handle_x_keys(int key);
|
int handle_x_keys(int key);
|
||||||
char_u *get_special_key_name(int c, int modifiers);
|
char_u *get_special_key_name(int c, int modifiers);
|
||||||
int trans_special(char_u **srcp, char_u *dst, int keycode, int in_string, int simplify, int *did_simplify);
|
int trans_special(char_u **srcp, char_u *dst, int flags, int *did_simplify);
|
||||||
int special_to_buf(int key, int modifiers, int keycode, char_u *dst);
|
int special_to_buf(int key, int modifiers, int keycode, char_u *dst);
|
||||||
int find_special_key(char_u **srcp, int *modp, int keycode, int keep_x_key, int in_string, int simplify, int *did_simplify);
|
int find_special_key(char_u **srcp, int *modp, int flags, int *did_simplify);
|
||||||
int extract_modifiers(int key, int *modp, int simplify, int *did_simplify);
|
int extract_modifiers(int key, int *modp, int simplify, int *did_simplify);
|
||||||
int find_special_key_in_table(int c);
|
int find_special_key_in_table(int c);
|
||||||
int get_special_key_code(char_u *name);
|
int get_special_key_code(char_u *name);
|
||||||
|
@ -5488,8 +5488,9 @@ replace_termcodes(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
slen = trans_special(&src, result + dlen, TRUE, FALSE,
|
slen = trans_special(&src, result + dlen, FSK_KEYCODE
|
||||||
(flags & REPTERM_NO_SIMPLIFY) == 0, did_simplify);
|
| ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY),
|
||||||
|
did_simplify);
|
||||||
if (slen)
|
if (slen)
|
||||||
{
|
{
|
||||||
dlen += slen;
|
dlen += slen;
|
||||||
|
@ -86,7 +86,7 @@ func Test_backspace_ctrl_u()
|
|||||||
|
|
||||||
set cpo-=<
|
set cpo-=<
|
||||||
inoremap <c-u> <left><c-u>
|
inoremap <c-u> <left><c-u>
|
||||||
exe "normal Avim3\<C-U>\<Esc>\<CR>"
|
exe "normal Avim3\{C-U}\<Esc>\<CR>"
|
||||||
iunmap <c-u>
|
iunmap <c-u>
|
||||||
exe "normal Avim4\<C-U>\<C-U>\<Esc>\<CR>"
|
exe "normal Avim4\<C-U>\<C-U>\<Esc>\<CR>"
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ func Test_backspace_ctrl_u()
|
|||||||
exe "normal A vim6\<Esc>Azwei\<C-G>u\<C-U>\<Esc>\<CR>"
|
exe "normal A vim6\<Esc>Azwei\<C-G>u\<C-U>\<Esc>\<CR>"
|
||||||
|
|
||||||
inoremap <c-u> <left><c-u>
|
inoremap <c-u> <left><c-u>
|
||||||
exe "normal A vim7\<C-U>\<C-U>\<Esc>\<CR>"
|
exe "normal A vim7\{C-U}\{C-U}\<Esc>\<CR>"
|
||||||
|
|
||||||
call assert_equal([
|
call assert_equal([
|
||||||
\ "1 this shouldn't be deleted",
|
\ "1 this shouldn't be deleted",
|
||||||
|
@ -76,7 +76,7 @@ func Test_map_ctrl_c_insert()
|
|||||||
inoremap <c-c> <ctrl-c>
|
inoremap <c-c> <ctrl-c>
|
||||||
cnoremap <c-c> dummy
|
cnoremap <c-c> dummy
|
||||||
cunmap <c-c>
|
cunmap <c-c>
|
||||||
call feedkeys("GoTEST2: CTRL-C |\<C-C>A|\<Esc>", "xt")
|
call feedkeys("GoTEST2: CTRL-C |\{C-C}A|\<Esc>", "xt")
|
||||||
call assert_equal('TEST2: CTRL-C |<ctrl-c>A|', getline('$'))
|
call assert_equal('TEST2: CTRL-C |<ctrl-c>A|', getline('$'))
|
||||||
unmap! <c-c>
|
unmap! <c-c>
|
||||||
set nomodified
|
set nomodified
|
||||||
@ -85,7 +85,7 @@ endfunc
|
|||||||
func Test_map_ctrl_c_visual()
|
func Test_map_ctrl_c_visual()
|
||||||
" mapping of ctrl-c in Visual mode
|
" mapping of ctrl-c in Visual mode
|
||||||
vnoremap <c-c> :<C-u>$put ='vmap works'
|
vnoremap <c-c> :<C-u>$put ='vmap works'
|
||||||
call feedkeys("GV\<C-C>\<CR>", "xt")
|
call feedkeys("GV\{C-C}\<CR>", "xt")
|
||||||
call assert_equal('vmap works', getline('$'))
|
call assert_equal('vmap works', getline('$'))
|
||||||
vunmap <c-c>
|
vunmap <c-c>
|
||||||
set nomodified
|
set nomodified
|
||||||
@ -235,7 +235,7 @@ endfunc
|
|||||||
|
|
||||||
func Test_map_meta_quotes()
|
func Test_map_meta_quotes()
|
||||||
imap <M-"> foo
|
imap <M-"> foo
|
||||||
call feedkeys("Go-\<M-\">-\<Esc>", "xt")
|
call feedkeys("Go-\{M-\"}-\<Esc>", "xt")
|
||||||
call assert_equal("-foo-", getline('$'))
|
call assert_equal("-foo-", getline('$'))
|
||||||
set nomodified
|
set nomodified
|
||||||
iunmap <M-">
|
iunmap <M-">
|
||||||
|
@ -309,7 +309,7 @@ endfunc
|
|||||||
func Test_mapping_at_hit_return_prompt()
|
func Test_mapping_at_hit_return_prompt()
|
||||||
nnoremap <C-B> :echo "hit ctrl-b"<CR>
|
nnoremap <C-B> :echo "hit ctrl-b"<CR>
|
||||||
call feedkeys(":ls\<CR>", "xt")
|
call feedkeys(":ls\<CR>", "xt")
|
||||||
call feedkeys("\<C-B>", "xt")
|
call feedkeys("\{C-B}", "xt")
|
||||||
call assert_match('hit ctrl-b', Screenline(&lines - 1))
|
call assert_match('hit ctrl-b', Screenline(&lines - 1))
|
||||||
nunmap <C-B>
|
nunmap <C-B>
|
||||||
endfunc
|
endfunc
|
||||||
|
25
src/typval.c
25
src/typval.c
@ -1285,15 +1285,24 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
++name;
|
++name;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Special key, e.g.: "\<C-W>"
|
// Special key, e.g.: "\<C-W>" or "\{C-W}"
|
||||||
case '<': extra = trans_special(&p, name, TRUE, TRUE,
|
case '<':
|
||||||
TRUE, NULL);
|
case '{':
|
||||||
if (extra != 0)
|
|
||||||
{
|
{
|
||||||
name += extra;
|
int flags = FSK_KEYCODE | FSK_IN_STRING;
|
||||||
if (name >= rettv->vval.v_string + len)
|
|
||||||
iemsg("get_string_tv() used more space than allocated");
|
if (*p == '<')
|
||||||
break;
|
flags |= FSK_SIMPLIFY;
|
||||||
|
else
|
||||||
|
flags |= FSK_CURLY;
|
||||||
|
extra = trans_special(&p, name, flags, NULL);
|
||||||
|
if (extra != 0)
|
||||||
|
{
|
||||||
|
name += extra;
|
||||||
|
if (name >= rettv->vval.v_string + len)
|
||||||
|
iemsg("get_string_tv() used more space than allocated");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// FALLTHROUGH
|
// FALLTHROUGH
|
||||||
|
|
||||||
|
@ -746,6 +746,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 */
|
||||||
|
/**/
|
||||||
|
855,
|
||||||
/**/
|
/**/
|
||||||
854,
|
854,
|
||||||
/**/
|
/**/
|
||||||
|
@ -2661,4 +2661,11 @@ long elapsed(DWORD start_tick);
|
|||||||
#define EVAL_EVALUATE 1 // when missing don't actually evaluate
|
#define EVAL_EVALUATE 1 // when missing don't actually evaluate
|
||||||
#define EVAL_CONSTANT 2 // when not a constant return FAIL
|
#define EVAL_CONSTANT 2 // when not a constant return FAIL
|
||||||
|
|
||||||
|
// Flags for find_special_key()
|
||||||
|
#define FSK_KEYCODE 0x01 // prefer key code, e.g. K_DEL instead of DEL
|
||||||
|
#define FSK_KEEP_X_KEY 0x02 // don't translate xHome to Home key
|
||||||
|
#define FSK_IN_STRING 0x04 // TRUE in string, double quote is escaped
|
||||||
|
#define FSK_SIMPLIFY 0x08 // simplify <C-H> and <A-x>
|
||||||
|
#define FSK_CURLY 0x10 // {C-x} instead of <C-x>
|
||||||
|
|
||||||
#endif // VIM__H
|
#endif // VIM__H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user