From: zeertzjq Date: Sat, 20 Jun 2026 16:38:47 +0000 (+0000) Subject: patch 9.2.0680: keytrans() doesn't replace '|' and '\' X-Git-Tag: v9.2.0680^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47fd183c4efe50c9fbee3380397e32459749a547;p=thirdparty%2Fvim.git patch 9.2.0680: keytrans() doesn't replace '|' and '\' Problem: keytrans() doesn't replace '|' and '\' (user202729) Solution: Replace '|' and '\' with "" and "" respectively. (zeertzjq) fixes: #20585 closes: #20586 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- diff --git a/src/message.c b/src/message.c index ac25fe322e..b0d09f6da6 100644 --- a/src/message.c +++ b/src/message.c @@ -1907,14 +1907,15 @@ str2special_save( char_u *str, int replace_spaces, // TRUE to replace " " with "". // used for the lhs of mapping and keytrans(). - int replace_lt) // TRUE to replace "<" with "". + int replace_others) // TRUE to replace "<" with "", + // "|" with "", "\" with "". { garray_T ga; char_u *p = str; ga_init2(&ga, 1, 40); while (*p != NUL) - ga_concat(&ga, str2special(&p, replace_spaces, replace_lt)); + ga_concat(&ga, str2special(&p, replace_spaces, replace_others)); ga_append(&ga, NUL); return (char_u *)ga.ga_data; } @@ -1931,7 +1932,8 @@ str2special( char_u **sp, int replace_spaces, // TRUE to replace " " with "". // used for the lhs of mapping and keytrans(). - int replace_lt) // TRUE to replace "<" with "". + int replace_others) // TRUE to replace "<" with "", + // "|" with "", "\" with "". { int c; static char_u buf[7]; @@ -1999,7 +2001,7 @@ str2special( if (special || c < ' ' || (replace_spaces && c == ' ') - || (replace_lt && c == '<')) + || (replace_others && (c == '<' || c == '|' || c == '\\'))) return get_special_key_name(c, modifiers); buf[0] = c; buf[1] = NUL; diff --git a/src/proto/message.pro b/src/proto/message.pro index 34b381866f..29519a2af6 100644 --- a/src/proto/message.pro +++ b/src/proto/message.pro @@ -38,8 +38,8 @@ char_u *msg_outtrans_one(char_u *p, int attr); int msg_outtrans_len_attr(char_u *msgstr, int len, int attr); void msg_make(char_u *arg); int msg_outtrans_special(char_u *strstart, int from, int maxlen); -char_u *str2special_save(char_u *str, int replace_spaces, int replace_lt); -char_u *str2special(char_u **sp, int replace_spaces, int replace_lt); +char_u *str2special_save(char_u *str, int replace_spaces, int replace_others); +char_u *str2special(char_u **sp, int replace_spaces, int replace_others); void str2specialbuf(char_u *sp, char_u *buf, int len); void msg_prt_line(char_u *s, int list); void msg_puts(char *s); diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 8ca73a62ae..bace380001 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -3702,6 +3702,10 @@ func Test_keytrans() call assert_equal('', "\<*M-x>"->keytrans()) call assert_equal('', "\<*C-I>"->keytrans()) call assert_equal('', "\<*S-3>"->keytrans()) + call assert_equal('', '|'->keytrans()) + call assert_equal('', "\<*M-|>"->keytrans()) + call assert_equal('', '\'->keytrans()) + call assert_equal('', "\<*M-\>"->keytrans()) call assert_equal('π', 'π'->keytrans()) call assert_equal('', "\"->keytrans()) call assert_equal('ě', 'ě'->keytrans()) diff --git a/src/version.c b/src/version.c index 933e847377..484f7515a9 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 680, /**/ 679, /**/