vim-patch:9.0.0806: 'langmap' works differently when there are modifiers (#20754)

Problem:    'langmap' works differently when there are modifiers.
Solution:   Only apply 'langmap' to a character where modifiers have no
            effect. (closes vim/vim#11395, closes vim/vim#11404)
49660f5139
This commit is contained in:
zeertzjq
2022-10-21 06:32:15 +08:00
committed by GitHub
parent 45ae5c6dc5
commit a288b4f214
2 changed files with 52 additions and 5 deletions

View File

@@ -1959,16 +1959,28 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
if (mp->m_keys[0] == tb_c1 && (mp->m_mode & local_State)
&& ((mp->m_mode & MODE_LANGMAP) == 0 || typebuf.tb_maplen == 0)) {
int nomap = nolmaplen;
int c2;
int modifiers = 0;
// find the match length of this mapping
for (mlen = 1; mlen < typebuf.tb_len; mlen++) {
c2 = typebuf.tb_buf[typebuf.tb_off + mlen];
int c2 = typebuf.tb_buf[typebuf.tb_off + mlen];
if (nomap > 0) {
if (nomap == 2 && c2 == KS_MODIFIER) {
modifiers = 1;
} else if (nomap == 1 && modifiers == 1) {
modifiers = c2;
}
nomap--;
} else if (c2 == K_SPECIAL) {
nomap = 2;
} else {
LANGMAP_ADJUST(c2, true);
if (c2 == K_SPECIAL) {
nomap = 2;
} else if (merge_modifiers(c2, &modifiers) == c2) {
// Only apply 'langmap' if merging modifiers into
// the key will not result in another character,
// so that 'langmap' behaves consistently in
// different terminals and GUIs.
LANGMAP_ADJUST(c2, true);
}
modifiers = 0;
}
if (mp->m_keys[mlen] != c2) {
break;