comparison src/getchar.c @ 20733:e3078150144d v8.2.0919

patch 8.2.0919: merging modifier for modifyOtherKeys is done twice Commit: https://github.com/vim/vim/commit/673fc3e23f09095d17f0095c4323958041b2d0d2 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 7 15:46:11 2020 +0200 patch 8.2.0919: merging modifier for modifyOtherKeys is done twice Problem: Merging modifier for modifyOtherKeys is done twice. Solution: Remove the merging done in vgetc().
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Jun 2020 16:00:06 +0200
parents 5ffe112b1afd
children e76b83c07bd8
comparison
equal deleted inserted replaced
20732:34095410f55f 20733:e3078150144d
1856 } 1856 }
1857 --no_mapping; 1857 --no_mapping;
1858 c = (*mb_ptr2char)(buf); 1858 c = (*mb_ptr2char)(buf);
1859 } 1859 }
1860 1860
1861 if (!no_reduce_keys) 1861 if (vgetc_char == 0)
1862 { 1862 {
1863 // A modifier was not used for a mapping, apply it to ASCII
1864 // keys. Shift would already have been applied.
1865 // Remember the character and mod_mask from before, in some
1866 // cases they are put back in the typeahead buffer.
1867 vgetc_mod_mask = mod_mask; 1863 vgetc_mod_mask = mod_mask;
1868 vgetc_char = c; 1864 vgetc_char = c;
1869 c = merge_modifyOtherKeys(c, &mod_mask);
1870 } 1865 }
1871 1866
1872 break; 1867 break;
1873 } 1868 }
1874 } 1869 }
2272 if (offset + 3 >= typebuf.tb_len) 2267 if (offset + 3 >= typebuf.tb_len)
2273 break; 2268 break;
2274 tp = typebuf.tb_buf + typebuf.tb_off + offset; 2269 tp = typebuf.tb_buf + typebuf.tb_off + offset;
2275 if (tp[0] == K_SPECIAL && tp[1] == KS_MODIFIER) 2270 if (tp[0] == K_SPECIAL && tp[1] == KS_MODIFIER)
2276 { 2271 {
2272 // A modifier was not used for a mapping, apply it to ASCII keys.
2273 // Shift would already have been applied.
2277 int modifier = tp[2]; 2274 int modifier = tp[2];
2278 int new_c = merge_modifyOtherKeys(tp[3], &modifier); 2275 int c = tp[3];
2279 2276 int new_c = merge_modifyOtherKeys(c, &modifier);
2280 if (new_c != tp[3] && modifier == 0) 2277
2278 if (new_c != c)
2281 { 2279 {
2282 char_u new_string[MB_MAXBYTES]; 2280 char_u new_string[MB_MAXBYTES];
2283 int len = mb_char2bytes(new_c, new_string); 2281 int len;
2284 2282
2285 if (put_string_in_typebuf(offset, 4, new_string, len, 2283 if (offset == 0)
2284 {
2285 // At the start: remember the character and mod_mask before
2286 // merging, in some cases, e.g. at the hit-return prompt,
2287 // they are put back in the typeahead buffer.
2288 vgetc_char = c;
2289 vgetc_mod_mask = tp[2];
2290 }
2291 len = mb_char2bytes(new_c, new_string);
2292 if (modifier == 0)
2293 {
2294 if (put_string_in_typebuf(offset, 4, new_string, len,
2286 NULL, 0, 0) == FAIL) 2295 NULL, 0, 0) == FAIL)
2287 return -1; 2296 return -1;
2297 }
2298 else
2299 {
2300 tp[2] = modifier;
2301 if (put_string_in_typebuf(offset + 3, 1, new_string, len,
2302 NULL, 0, 0) == FAIL)
2303 return -1;
2304 }
2288 return len; 2305 return len;
2289 } 2306 }
2290 } 2307 }
2291 } 2308 }
2292 return 0; 2309 return 0;
2557 if (keylen == 0 && save_keylen == KEYLEN_PART_KEY) 2574 if (keylen == 0 && save_keylen == KEYLEN_PART_KEY)
2558 keylen = KEYLEN_PART_KEY; 2575 keylen = KEYLEN_PART_KEY;
2559 2576
2560 // If no termcode matched, try to include the modifier into the 2577 // If no termcode matched, try to include the modifier into the
2561 // key. This for when modifyOtherKeys is working. 2578 // key. This for when modifyOtherKeys is working.
2562 if (keylen == 0) 2579 if (keylen == 0 && !no_reduce_keys)
2563 keylen = check_simplify_modifier(max_mlen + 1); 2580 keylen = check_simplify_modifier(max_mlen + 1);
2564 2581
2565 // When getting a partial match, but the last characters were not 2582 // When getting a partial match, but the last characters were not
2566 // typed, don't wait for a typed character to complete the 2583 // typed, don't wait for a typed character to complete the
2567 // termcode. This helps a lot when a ":normal" command ends in an 2584 // termcode. This helps a lot when a ":normal" command ends in an