To: vim-dev@vim.org Subject: Patch 6.2.228 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.228 Problem: Receiving CTRL-\ CTRL-N after typing "f" or "m" doesn't switch Vim back to Normal mode. Same for CTRL-\ CTRL-G. Solution: Check if the character typed after a command is CTRL-\ and obtain another character to check for CTRL-N or CTRL-G, waiting up to 'ttimeoutlen' msec. Files: src/normal.c *** ../vim-6.2.227/src/normal.c Tue Jan 27 17:09:16 2004 --- src/normal.c Tue Feb 3 16:26:11 2004 *************** *** 250,256 **** {Ctrl_Y, nv_scroll_line, 0, FALSE}, {Ctrl_Z, nv_suspend, 0, 0}, {ESC, nv_esc, 0, FALSE}, ! {Ctrl_BSL, nv_normal, 0, 0}, {Ctrl_RSB, nv_ident, NV_NCW, 0}, {Ctrl_HAT, nv_hat, NV_NCW, 0}, {Ctrl__, nv_error, 0, 0}, --- 250,256 ---- {Ctrl_Y, nv_scroll_line, 0, FALSE}, {Ctrl_Z, nv_suspend, 0, 0}, {ESC, nv_esc, 0, FALSE}, ! {Ctrl_BSL, nv_normal, NV_NCH_ALW, 0}, {Ctrl_RSB, nv_ident, NV_NCW, 0}, {Ctrl_HAT, nv_hat, NV_NCW, 0}, {Ctrl__, nv_error, 0, 0}, *************** *** 880,886 **** #ifdef FEAT_CMDL_INFO need_flushbuf |= add_to_showcmd(ca.nchar); #endif ! if (ca.nchar == 'r' || ca.nchar == '\'' || ca.nchar == '`') { cp = &ca.extra_char; /* need to get a third character */ if (ca.nchar != 'r') --- 880,887 ---- #ifdef FEAT_CMDL_INFO need_flushbuf |= add_to_showcmd(ca.nchar); #endif ! if (ca.nchar == 'r' || ca.nchar == '\'' || ca.nchar == '`' ! || ca.nchar == Ctrl_BSL) { cp = &ca.extra_char; /* need to get a third character */ if (ca.nchar != 'r') *************** *** 992,997 **** --- 993,1035 ---- #endif } + /* + * When the next character is CTRL-\ a following CTRL-N means the + * command is aborted and we go to Normal mode. + */ + if (cp == &ca.extra_char + && ca.nchar == Ctrl_BSL + && (ca.extra_char == Ctrl_N || ca.extra_char == Ctrl_G)) + { + ca.cmdchar = Ctrl_BSL; + ca.nchar = ca.extra_char; + idx = find_command(ca.cmdchar); + } + else if (*cp == Ctrl_BSL) + { + long towait = (p_ttm >= 0 ? p_ttm : p_tm); + + /* There is a busy wait here when typing "f" and then + * something different from CTRL-N. Can't be avoided. */ + while ((c = vpeekc()) <= 0 && towait > 0L) + { + do_sleep(towait > 50L ? 50L : towait); + towait -= 50L; + } + if (c > 0) + { + c = safe_vgetc(); + if (c != Ctrl_N && c != Ctrl_G) + vungetc(c); + else + { + ca.cmdchar = Ctrl_BSL; + ca.nchar = c; + idx = find_command(ca.cmdchar); + } + } + } + #ifdef FEAT_MBYTE /* When getting a text character and the next character is a * multi-byte character, it could be a composing character. *************** *** 7746,7754 **** nv_normal(cap) cmdarg_T *cap; { ! int c = safe_vgetc(); ! ! if (c == Ctrl_N || c == Ctrl_G) { clearop(cap->oap); if (restart_edit != 0 && p_smd) --- 7784,7790 ---- nv_normal(cap) cmdarg_T *cap; { ! if (cap->nchar == Ctrl_N || cap->nchar == Ctrl_G) { clearop(cap->oap); if (restart_edit != 0 && p_smd) *************** *** 7766,7772 **** } #endif /* CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. */ ! if (c == Ctrl_G && p_im) restart_edit = 'a'; } else --- 7802,7808 ---- } #endif /* CTRL-\ CTRL-G restarts Insert mode when 'insertmode' is set. */ ! if (cap->nchar == Ctrl_G && p_im) restart_edit = 'a'; } else *** ../vim-6.2.227/src/version.c Tue Feb 3 16:20:37 2004 --- src/version.c Tue Feb 3 16:28:19 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 228, /**/ -- Time is an illusion. Lunchtime doubly so. -- Ford Prefect, in Douglas Adams' "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///