comparison src/normal.c @ 32750:dfaddd6f039e v9.0.1694

patch 9.0.1694: wrong mapping applied when replaying a char search Commit: https://github.com/vim/vim/commit/bacc83009bc38c9ba0247aaa22b76d1993d57993 Author: zeertzjq <zeertzjq@outlook.com> Date: Sat Aug 12 00:09:31 2023 +0200 patch 9.0.1694: wrong mapping applied when replaying a char search Problem: wrong mapping applied when replaying a char search Solution: Store a NOP after the ESC closes: #12708 closes: #6350 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author Christian Brabandt <cb@256bit.org>
date Sat, 12 Aug 2023 00:15:04 +0200
parents a5a2a5e56c63
children b1162ad29d73
comparison
equal deleted inserted replaced
32749:6eb2a929432a 32750:dfaddd6f039e
541 idx = find_command(cap->cmdchar); 541 idx = find_command(cap->cmdchar);
542 } 542 }
543 } 543 }
544 } 544 }
545 545
546 // When getting a text character and the next character is a 546 if (enc_utf8 && lang)
547 // multi-byte character, it could be a composing character. 547 {
548 // However, don't wait for it to arrive. Also, do enable mapping, 548 // When getting a text character and the next character is a
549 // because if it's put back with vungetc() it's too late to apply 549 // multi-byte character, it could be a composing character.
550 // mapping. 550 // However, don't wait for it to arrive. Also, do enable mapping,
551 --no_mapping; 551 // because if it's put back with vungetc() it's too late to apply
552 while (enc_utf8 && lang && (c = vpeekc()) > 0 552 // mapping.
553 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) 553 --no_mapping;
554 { 554 while ((c = vpeekc()) > 0
555 c = plain_vgetc(); 555 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1))
556 if (!utf_iscomposing(c))
557 { 556 {
558 vungetc(c); // it wasn't, put it back 557 c = plain_vgetc();
559 break; 558 if (!utf_iscomposing(c))
559 {
560 vungetc(c); // it wasn't, put it back
561 break;
562 }
563 else if (cap->ncharC1 == 0)
564 cap->ncharC1 = c;
565 else
566 cap->ncharC2 = c;
560 } 567 }
561 else if (cap->ncharC1 == 0) 568 ++no_mapping;
562 cap->ncharC1 = c; 569 // Vim may be in a different mode when the user types the next key,
563 else 570 // but when replaying a recording the next key is already in the
564 cap->ncharC2 = c; 571 // typeahead buffer, so record a <Nop> before that to prevent the
565 } 572 // vpeekc() above from applying wrong mappings when replaying.
566 ++no_mapping; 573 gotchars_nop();
574 }
567 } 575 }
568 --no_mapping; 576 --no_mapping;
569 --allow_keys; 577 --allow_keys;
570 578
571 return idx; 579 return idx;