diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-08-14 16:07:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-08-14 16:07:48 +0200 |
commit | 35a4cfa200917dd171b1fff3cd5b6cee9add673d (patch) | |
tree | e12d8aac31bfe6c651bb4f5553658203c817ea55 /src/misc2.c | |
parent | 2d1a248762f069e470acde389ff4686a45d2f817 (diff) | |
download | vim-git-35a4cfa200917dd171b1fff3cd5b6cee9add673d.tar.gz |
patch 7.4.2209v7.4.2209
Problem: Cannot map <M-">. (Stephen Riehm)
Solution: Solve the memory access problem in another way. (Dominique Pelle)
Allow for using <M-\"> in a string.
Diffstat (limited to 'src/misc2.c')
-rw-r--r-- | src/misc2.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/misc2.c b/src/misc2.c index f44c33cea..00c01f463 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2674,13 +2674,14 @@ get_special_key_name(int c, int modifiers) trans_special( char_u **srcp, char_u *dst, - int keycode) /* prefer key code, e.g. K_DEL instead of DEL */ + int keycode, /* prefer key code, e.g. K_DEL instead of DEL */ + int in_string) /* TRUE when inside a double quoted string */ { int modifiers = 0; int key; int dlen = 0; - key = find_special_key(srcp, &modifiers, keycode, FALSE); + key = find_special_key(srcp, &modifiers, keycode, FALSE, in_string); if (key == 0) return 0; @@ -2720,7 +2721,8 @@ find_special_key( char_u **srcp, int *modp, int keycode, /* prefer key code, e.g. K_DEL instead of DEL */ - int keep_x_key) /* don't translate xHome to Home key */ + int keep_x_key, /* don't translate xHome to Home key */ + int in_string) /* TRUE in string, double quote is escaped */ { char_u *last_dash; char_u *end_of_name; @@ -2751,10 +2753,14 @@ find_special_key( else #endif l = 1; - /* Anything accepted, like <C-?>, except <C-">, because the " - * ends the string. */ - if (bp[l] != '"' && bp[l + 1] == '>') + /* Anything accepted, like <C-?>. + * <C-"> or <M-"> are not special in strings as " is + * the string delimiter. With a backslash it works: <M-\"> */ + if (!(in_string && bp[1] == '"') && bp[2] == '>') bp += l; + else if (in_string && bp[1] == '\\' && bp[2] == '"' + && bp[3] == '>') + bp += 2; } } if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) @@ -2798,20 +2804,22 @@ find_special_key( } else { - /* - * Modifier with single letter, or special key name. - */ + int off = 1; + + /* Modifier with single letter, or special key name. */ + if (in_string && last_dash[1] == '\\' && last_dash[2] == '"') + off = 2; #ifdef FEAT_MBYTE if (has_mbyte) - l = mb_ptr2len(last_dash + 1); + l = mb_ptr2len(last_dash + off); else #endif l = 1; - if (modifiers != 0 && last_dash[l + 1] == '>') - key = PTR2CHAR(last_dash + 1); + if (modifiers != 0 && last_dash[l + off] == '>') + key = PTR2CHAR(last_dash + off); else { - key = get_special_key_code(last_dash + 1); + key = get_special_key_code(last_dash + off); if (!keep_x_key) key = handle_x_keys(key); } |