Mercurial > vim
comparison src/getchar.c @ 28127:b9e8f3674090 v8.2.4588
patch 8.2.4588: mapping with key after other matching mapping does not work
Commit: https://github.com/vim/vim/commit/f35fd8e5d484be0e3fdd7c3c24f690083f91264d
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 18 15:41:17 2022 +0000
patch 8.2.4588: mapping with key after other matching mapping does not work
Problem: Mapping with key code after other matching mapping does not work.
Solution: Change ">" to ">=". (closes https://github.com/vim/vim/issues/9903)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 18 Mar 2022 16:45:03 +0100 |
parents | f615d89a5351 |
children | e6022d580823 |
comparison
equal
deleted
inserted
replaced
28126:b8f593e7c080 | 28127:b9e8f3674090 |
---|---|
2414 mapblock_T *mp = NULL; | 2414 mapblock_T *mp = NULL; |
2415 mapblock_T *mp2; | 2415 mapblock_T *mp2; |
2416 mapblock_T *mp_match; | 2416 mapblock_T *mp_match; |
2417 int mp_match_len = 0; | 2417 int mp_match_len = 0; |
2418 int max_mlen = 0; | 2418 int max_mlen = 0; |
2419 int want_termcode = 0; // 1 if termcode expected after max_mlen | |
2419 int tb_c1; | 2420 int tb_c1; |
2420 int mlen; | 2421 int mlen; |
2421 #ifdef FEAT_LANGMAP | 2422 #ifdef FEAT_LANGMAP |
2422 int nolmaplen; | 2423 int nolmaplen; |
2423 #endif | 2424 #endif |
2589 mp_match_len = keylen; | 2590 mp_match_len = keylen; |
2590 } | 2591 } |
2591 } | 2592 } |
2592 else | 2593 else |
2593 // No match; may have to check for termcode at next | 2594 // No match; may have to check for termcode at next |
2594 // character. | 2595 // character. If the first character that didn't match is |
2596 // K_SPECIAL then check for a termcode. This isn't perfect | |
2597 // but should work in most cases. | |
2595 if (max_mlen < mlen) | 2598 if (max_mlen < mlen) |
2599 { | |
2596 max_mlen = mlen; | 2600 max_mlen = mlen; |
2601 want_termcode = mp->m_keys[mlen] == K_SPECIAL; | |
2602 } | |
2603 else if (max_mlen == mlen && mp->m_keys[mlen] == K_SPECIAL) | |
2604 want_termcode = 1; | |
2597 } | 2605 } |
2598 } | 2606 } |
2599 | 2607 |
2600 // If no partly match found, use the longest full match. | 2608 // If no partly match found, use the longest full match. |
2601 if (keylen != KEYLEN_PART_MAP && mp_match != NULL) | 2609 if (keylen != KEYLEN_PART_MAP && mp_match != NULL) |
2644 } | 2652 } |
2645 | 2653 |
2646 // May check for a terminal code when there is no mapping or only a partial | 2654 // May check for a terminal code when there is no mapping or only a partial |
2647 // mapping. Also check if there is a full mapping with <Esc>, unless timed | 2655 // mapping. Also check if there is a full mapping with <Esc>, unless timed |
2648 // out, since that is nearly always a partial match with a terminal code. | 2656 // out, since that is nearly always a partial match with a terminal code. |
2649 if ((mp == NULL || max_mlen > mp_match_len | 2657 if ((mp == NULL || max_mlen + want_termcode > mp_match_len |
2650 || (mp_match_len == 1 && *mp->m_keys == ESC && !*timedout)) | 2658 || (mp_match_len == 1 && *mp->m_keys == ESC && !*timedout)) |
2651 && keylen != KEYLEN_PART_MAP) | 2659 && keylen != KEYLEN_PART_MAP) |
2652 { | 2660 { |
2653 int save_keylen = keylen; | 2661 int save_keylen = keylen; |
2654 | 2662 |