To: vim-dev@vim.org Subject: Patch 6.1.141 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.141 Problem: ":wincmd gx" may cause problems when mixed with other commands. ":wincmd c" doesn't close the window immediately. (Benji Fisher) Solution: Pass the extra command character directly instead of using the stuff buffer and call ex_close() directly. Files: src/ex_docmd.c, src/normal.c, src/proto/normal.pro, src/proto/window.pro, src/window.c *** ../vim61.140/src/ex_docmd.c Sun Jul 21 21:04:38 2002 --- src/ex_docmd.c Thu Jul 18 20:44:49 2002 *************** *** 6170,6175 **** --- 6170,6177 ---- ex_wincmd(eap) exarg_T *eap; { + int xchar = NUL; + if (*eap->arg == 'g' || *eap->arg == Ctrl_G) { /* CTRL-W g and CTRL-W CTRL-G have an extra command character */ *************** *** 6178,6186 **** EMSG(_(e_invarg)); return; } ! stuffcharReadbuff(eap->arg[1]); } ! do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L); } #endif --- 6180,6188 ---- EMSG(_(e_invarg)); return; } ! xchar = eap->arg[1]; } ! do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); } #endif *** ../vim61.140/src/normal.c Mon Jun 3 21:53:04 2002 --- src/normal.c Sun Jul 14 21:53:05 2002 *************** *** 80,85 **** --- 80,86 ---- static void nv_ctrlo __ARGS((cmdarg_T *cap)); static void nv_hat __ARGS((cmdarg_T *cap)); static void nv_Zet __ARGS((cmdarg_T *cap)); + static void nv_ident __ARGS((cmdarg_T *cap)); #ifdef FEAT_VISUAL static int get_visual_text __ARGS((cmdarg_T *cap, char_u **pp, int *lenp)); #endif *************** *** 4576,4581 **** --- 4588,4614 ---- } } + #if defined(FEAT_WINDOWS) || defined(PROTO) + /* + * Call nv_ident() as if "c1" was used, with "c2" as next character. + */ + void + do_nv_ident(c1, c2) + int c1; + int c2; + { + oparg_T oa; + cmdarg_T ca; + + clear_oparg(&oa); + vim_memset(&ca, 0, sizeof(ca)); + ca.oap = &oa; + ca.cmdchar = c1; + ca.nchar = c2; + nv_ident(&ca); + } + #endif + /* * Handle the commands that use the word under the cursor. * [g] CTRL-] :ta to current identifier *************** *** 4584,4590 **** * [g] '#' ? to current identifier or string * g ']' :tselect for current identifier */ ! void nv_ident(cap) cmdarg_T *cap; { --- 4617,4623 ---- * [g] '#' ? to current identifier or string * g ']' :tselect for current identifier */ ! static void nv_ident(cap) cmdarg_T *cap; { *************** *** 6551,6557 **** { #ifdef FEAT_WINDOWS if (!checkclearop(cap->oap)) ! do_window(cap->nchar, cap->count0); /* everything is in window.c */ #else (void)checkclearop(cap->oap); #endif --- 6584,6590 ---- { #ifdef FEAT_WINDOWS if (!checkclearop(cap->oap)) ! do_window(cap->nchar, cap->count0, NUL); /* everything is in window.c */ #else (void)checkclearop(cap->oap); #endif *** ../vim61.140/src/proto/normal.pro Fri Mar 22 21:41:18 2002 --- src/proto/normal.pro Fri Jun 21 20:41:08 2002 *************** *** 16,22 **** void do_check_scrollbind __ARGS((int check)); void check_scrollbind __ARGS((linenr_T topline_diff, long leftcol_diff)); void scroll_redraw __ARGS((int up, long count)); ! void nv_ident __ARGS((cmdarg_T *cap)); void start_selection __ARGS((void)); void may_start_select __ARGS((int c)); /* vim: set ft=c : */ --- 16,22 ---- void do_check_scrollbind __ARGS((int check)); void check_scrollbind __ARGS((linenr_T topline_diff, long leftcol_diff)); void scroll_redraw __ARGS((int up, long count)); ! void do_nv_ident __ARGS((int c1, int c2)); void start_selection __ARGS((void)); void may_start_select __ARGS((int c)); /* vim: set ft=c : */ *** ../vim61.140/src/proto/window.pro Fri Mar 22 21:41:24 2002 --- src/proto/window.pro Fri Jun 21 20:39:45 2002 *************** *** 1,5 **** /* window.c */ ! void do_window __ARGS((int nchar, long Prenum)); int win_split __ARGS((int size, int flags)); int win_valid __ARGS((win_T *win)); int win_count __ARGS((void)); --- 1,5 ---- /* window.c */ ! void do_window __ARGS((int nchar, long Prenum, int xchar)); int win_split __ARGS((int size, int flags)); int win_valid __ARGS((win_T *win)); int win_count __ARGS((void)); *** ../vim61.140/src/window.c Sun Jun 23 15:04:45 2002 --- src/window.c Mon Jun 24 21:34:44 2002 *************** *** 80,92 **** * all CTRL-W window commands are handled here, called from normal_cmd(). */ void ! do_window(nchar, Prenum) int nchar; long Prenum; { long Prenum1; win_T *wp; - int xchar; #if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID) char_u *ptr; #endif --- 81,93 ---- * all CTRL-W window commands are handled here, called from normal_cmd(). */ void ! do_window(nchar, Prenum, xchar) int nchar; long Prenum; + int xchar; /* extra char from ":wincmd gx" or NUL */ { long Prenum1; win_T *wp; #if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID) char_u *ptr; #endif *************** *** 94,99 **** --- 95,101 ---- int type = FIND_DEFINE; int len; #endif + char_u cbuf[40]; if (Prenum == 0) Prenum1 = 1; *************** *** 144,153 **** #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! stuffReadbuff((char_u *)":split #"); if (Prenum) ! stuffnumReadbuff(Prenum); /* buffer number */ ! stuffcharReadbuff('\n'); break; /* open new window */ --- 146,155 ---- #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! STRCPY(cbuf, "split #"); if (Prenum) ! sprintf((char *)cbuf + 7, "%ld", Prenum); ! do_cmdline_cmd(cbuf); break; /* open new window */ *************** *** 157,166 **** #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif - stuffcharReadbuff(':'); if (Prenum) ! stuffnumReadbuff(Prenum); /* window height */ ! stuffReadbuff((char_u *)"new\n"); break; /* quit current window */ --- 159,170 ---- #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif if (Prenum) ! sprintf((char *)cbuf, "%ld", Prenum); /* window height */ ! else ! cbuf[0] = NUL; ! STRCAT(cbuf, "new"); ! do_cmdline_cmd(cbuf); break; /* quit current window */ *************** *** 169,175 **** #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! stuffReadbuff((char_u *)":quit\n"); break; /* close current window */ --- 173,179 ---- #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! do_cmdline_cmd((char_u *)"quit"); break; /* close current window */ *************** *** 178,184 **** #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! stuffReadbuff((char_u *)":close\n"); break; #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) --- 182,188 ---- #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! do_cmdline_cmd((char_u *)"close"); break; #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) *************** *** 189,195 **** #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! stuffReadbuff((char_u *)":pclose\n"); break; /* cursor to preview window */ --- 193,199 ---- #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! do_cmdline_cmd((char_u *)"pclose"); break; /* cursor to preview window */ *************** *** 211,217 **** #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! stuffReadbuff((char_u *)":only\n"); break; /* cursor to next window with wrap around */ --- 215,221 ---- #ifdef FEAT_VISUAL reset_VIsual_and_resel(); /* stop Visual mode */ #endif ! do_cmdline_cmd((char_u *)"only"); break; /* cursor to next window with wrap around */ *************** *** 441,447 **** postponed_split = Prenum; else postponed_split = -1; ! stuffcharReadbuff(Ctrl_RSB); break; #ifdef FEAT_SEARCHPATH --- 445,454 ---- postponed_split = Prenum; else postponed_split = -1; ! ! /* Execute the command right here, required when ! * "wincmd ]" was used in a function. */ ! do_nv_ident(Ctrl_RSB, NUL); break; #ifdef FEAT_SEARCHPATH *************** *** 497,503 **** #endif ++no_mapping; ++allow_keys; /* no mapping for xchar, but allow key codes */ ! xchar = safe_vgetc(); #ifdef FEAT_LANGMAP LANGMAP_ADJUST(xchar, TRUE); #endif --- 504,511 ---- #endif ++no_mapping; ++allow_keys; /* no mapping for xchar, but allow key codes */ ! if (xchar == NUL) ! xchar = safe_vgetc(); #ifdef FEAT_LANGMAP LANGMAP_ADJUST(xchar, TRUE); #endif *************** *** 529,545 **** /* Execute the command right here, required when * "wincmd g}" was used in a function. */ ! { ! oparg_T oa; ! cmdarg_T ca; ! ! clear_oparg(&oa); ! vim_memset(&ca, 0, sizeof(ca)); ! ca.oap = &oa; ! ca.cmdchar = 'g'; ! ca.nchar = xchar; ! nv_ident(&ca); ! } break; default: --- 537,543 ---- /* Execute the command right here, required when * "wincmd g}" was used in a function. */ ! do_nv_ident('g', xchar); break; default: *** ../vim61.140/src/version.c Sun Jul 21 21:35:45 2002 --- src/version.c Sun Jul 21 21:39:23 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 141, /**/ -- hundred-and-one symptoms of being an internet addict: 22. You've already visited all the links at Yahoo and you're halfway through Lycos. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///