To: vim_dev@googlegroups.com Subject: Patch 8.2.4691 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4691 (after 8.2.4689) Problem: Solution for in a mapping causes trouble. Solution: Use another solution: put back CTRL-O after reading the sequence. Files: src/getchar.c *** ../vim-8.2.4690/src/getchar.c 2022-04-04 21:03:49.180834694 +0100 --- src/getchar.c 2022-04-04 22:07:30.619451549 +0100 *************** *** 96,105 **** static int vgetorpeek(int); static int inchar(char_u *buf, int maxlen, long wait_time); - // flags for vgetorpeek() - #define VGOP_ADVANCE 1 // really get the character - #define VGOP_NO_STUFF 2 // do not use the stuff buffer - /* * Free and clear a buffer. */ --- 96,101 ---- *************** *** 1724,1730 **** ++allow_keys; did_inc = TRUE; // mod_mask may change value } ! c = vgetorpeek(VGOP_ADVANCE); if (did_inc) { --no_mapping; --- 1720,1726 ---- ++allow_keys; did_inc = TRUE; // mod_mask may change value } ! c = vgetorpeek(TRUE); if (did_inc) { --no_mapping; *************** *** 1742,1749 **** ++no_mapping; allow_keys = 0; // make sure BS is not found ! c2 = vgetorpeek(VGOP_ADVANCE); // no mapping for these chars ! c = vgetorpeek(VGOP_ADVANCE); --no_mapping; allow_keys = save_allow_keys; if (c2 == KS_MODIFIER) --- 1738,1745 ---- ++no_mapping; allow_keys = 0; // make sure BS is not found ! c2 = vgetorpeek(TRUE); // no mapping for these chars ! c = vgetorpeek(TRUE); --no_mapping; allow_keys = save_allow_keys; if (c2 == KS_MODIFIER) *************** *** 1766,1772 **** int j; // get menu path, it ends with a ! for (j = 0; (c = vgetorpeek(VGOP_ADVANCE)) != '\r'; ) { name[j] = c; if (j < 199) --- 1762,1768 ---- int j; // get menu path, it ends with a ! for (j = 0; (c = vgetorpeek(TRUE)) != '\r'; ) { name[j] = c; if (j < 199) *************** *** 1876,1882 **** buf[0] = c; for (i = 1; i < n; ++i) { ! buf[i] = vgetorpeek(VGOP_ADVANCE); if (buf[i] == K_SPECIAL #ifdef FEAT_GUI || (buf[i] == CSI) --- 1872,1878 ---- buf[0] = c; for (i = 1; i < n; ++i) { ! buf[i] = vgetorpeek(TRUE); if (buf[i] == K_SPECIAL #ifdef FEAT_GUI || (buf[i] == CSI) *************** *** 1889,1896 **** // represents a CSI (0x9B), // or a K_SPECIAL - KS_EXTRA - KE_CSI, which is CSI // too. ! c = vgetorpeek(VGOP_ADVANCE); ! if (vgetorpeek(VGOP_ADVANCE) == KE_CSI && c == KS_EXTRA) buf[i] = CSI; } } --- 1885,1892 ---- // represents a CSI (0x9B), // or a K_SPECIAL - KS_EXTRA - KE_CSI, which is CSI // too. ! c = vgetorpeek(TRUE); ! if (vgetorpeek(TRUE) == KE_CSI && c == KS_EXTRA) buf[i] = CSI; } } *************** *** 1993,1999 **** { if (old_char != -1) return old_char; ! return vgetorpeek(0); } #if defined(FEAT_TERMRESPONSE) || defined(FEAT_TERMINAL) || defined(PROTO) --- 1989,1995 ---- { if (old_char != -1) return old_char; ! return vgetorpeek(FALSE); } #if defined(FEAT_TERMRESPONSE) || defined(FEAT_TERMINAL) || defined(PROTO) *************** *** 2968,2978 **** * 3. from the user * This may do a blocking wait if "advance" is TRUE. * ! * if "flags & VGOP_ADVANCE" is non-zero (vgetc()): * Really get the character. * KeyTyped is set to TRUE in the case the user typed the key. * KeyStuffed is TRUE if the character comes from the stuff buffer. ! * if "flags & VGOP_ADVANCE" is zero (vpeekc()): * Just look whether there is a character available. * Return NUL if not. * --- 2964,2974 ---- * 3. from the user * This may do a blocking wait if "advance" is TRUE. * ! * if "advance" is TRUE (vgetc()): * Really get the character. * KeyTyped is set to TRUE in the case the user typed the key. * KeyStuffed is TRUE if the character comes from the stuff buffer. ! * if "advance" is FALSE (vpeekc()): * Just look whether there is a character available. * Return NUL if not. * *************** *** 2981,2989 **** * K_SPECIAL and CSI may be escaped, need to get two more bytes then. */ static int ! vgetorpeek(int flags) { - int advance = flags & VGOP_ADVANCE; int c, c1; int timedout = FALSE; // waited for more than 1 second // for mapping to complete --- 2977,2984 ---- * K_SPECIAL and CSI may be escaped, need to get two more bytes then. */ static int ! vgetorpeek(int advance) { int c, c1; int timedout = FALSE; // waited for more than 1 second // for mapping to complete *************** *** 3027,3035 **** /* * get a character: 1. from the stuffbuffer */ ! if (flags & VGOP_NO_STUFF) ! c = 0; ! else if (typeahead_char != 0) { c = typeahead_char; if (advance) --- 3022,3028 ---- /* * get a character: 1. from the stuffbuffer */ ! if (typeahead_char != 0) { c = typeahead_char; if (advance) *************** *** 3762,3767 **** --- 3755,3762 ---- int c2; int cmod = 0; int aborted = FALSE; + int first = TRUE; + int got_ctrl_o = FALSE; ga_init2(&line_ga, 1, 32); *************** *** 3777,3783 **** break; } ! if (vgetorpeek(0 | VGOP_NO_STUFF) == NUL) { // incomplete is an error, because there is not much the user // could do in this state. --- 3772,3778 ---- break; } ! if (vgetorpeek(FALSE) == NUL) { // incomplete is an error, because there is not much the user // could do in this state. *************** *** 3787,3799 **** } // Get one character at a time. ! c1 = vgetorpeek(VGOP_ADVANCE | VGOP_NO_STUFF); // Get two extra bytes for special keys if (c1 == K_SPECIAL) { ! c1 = vgetorpeek(VGOP_ADVANCE | VGOP_NO_STUFF); ! c2 = vgetorpeek(VGOP_ADVANCE | VGOP_NO_STUFF); if (c1 == KS_MODIFIER) { cmod = c2; --- 3782,3803 ---- } // Get one character at a time. ! c1 = vgetorpeek(TRUE); ! ! // do not use Ctrl_O at the start, stuff it back later ! if (first && c1 == Ctrl_O) ! { ! got_ctrl_o = TRUE; ! first = FALSE; ! continue; ! } ! first = FALSE; // Get two extra bytes for special keys if (c1 == K_SPECIAL) { ! c1 = vgetorpeek(TRUE); ! c2 = vgetorpeek(TRUE); if (c1 == KS_MODIFIER) { cmod = c2; *************** *** 3840,3845 **** --- 3844,3851 ---- } no_mapping--; + if (got_ctrl_o) + stuffcharReadbuff(Ctrl_O); if (aborted) ga_clear(&line_ga); *** ../vim-8.2.4690/src/version.c 2022-04-04 21:13:31.767884403 +0100 --- src/version.c 2022-04-04 22:08:15.547118812 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4691, /**/ -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///