To: vim-dev@vim.org Subject: Patch 6.1.173 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.173 Problem: When using remote control to edit a position in a file and this file is the current buffer and it's modified, the window is split and the ":drop" command fails. Solution: Don't split the window, keep editing the same buffer. Use the ":drop" command in VisVim to avoid the problem there. Files: src/ex_cmds.c, src/ex_cmds2.c, src/proto/ex_cmds2.pro, VisVim/Commands.cpp *** ../vim61.172/src/ex_cmds.c Fri Aug 30 22:15:48 2002 --- src/ex_cmds.c Sat Sep 7 17:11:47 2002 *************** *** 5649,5654 **** --- 5650,5694 ---- ++emsg_off; split = check_changed(curbuf, TRUE, FALSE, FALSE, FALSE); --emsg_off; + + /* + * When dropping a single file that is equal to the currently edited + * file, no splitting is to be done. This happens when controlling + * Vim remotely to jump to a position in a file. + */ + if (split) + { + char_u *arg = vim_strsave(eap->arg); + char_u *nxt; + char_u *f; + + if (arg != NULL) + { + /* get the first argument, removing quotes. */ + nxt = do_one_arg(arg); + f = fix_fname(arg); + if (f != NULL) + { + /* if it's equal to the current file, don't split */ + if (!otherfile(f)) + split = FALSE; + vim_free(f); + } + vim_free(arg); + + if (!split) + { + /* If already editing the file and it's the only one: + * return. Otherwise remove the file from the list and + * split anyway to edit the others. */ + if (*nxt == NUL) + return; + f = eap->arg + (nxt - arg); + mch_memmove(eap->arg, f, STRLEN(f) + 1); + split = TRUE; + } + } + } } /* Fake a ":snext" or ":next" command. */ *** ../vim61.172/src/ex_cmds2.c Thu Jun 27 21:27:57 2002 --- src/ex_cmds2.c Sat Sep 7 16:11:46 2002 *************** *** 837,842 **** --- 837,889 ---- /* * Code to handle the argument list. */ + + /* + * Isolate one argument, taking quotes and backticks. + * Changes the argument in-place, puts a NUL after it. + * Quotes are removed, backticks remain. + * Return a pointer to the start of the next argument. + */ + char_u * + do_one_arg(str) + char_u *str; + { + char_u *p; + int inquote; + int inbacktick; + + inquote = FALSE; + inbacktick = FALSE; + for (p = str; *str; ++str) + { + /* + * for MSDOS et.al. a backslash is part of a file name. + * Only skip ", space and tab. + */ + if (rem_backslash(str)) + { + *p++ = *str++; + *p++ = *str; + } + else + { + /* An item ends at a space not in quotes or backticks */ + if (!inquote && !inbacktick && vim_isspace(*str)) + break; + if (!inquote && *str == '`') + inbacktick ^= TRUE; + if (!inbacktick && *str == '"') + inquote ^= TRUE; + else + *p++ = *str; + } + } + str = skipwhite(str); + *p = NUL; + + return str; + } + static int do_arglist __ARGS((char_u *str, int what, int after)); static void alist_check_arg_idx __ARGS((void)); #ifdef FEAT_LISTCMDS *************** *** 864,871 **** int exp_count; char_u **exp_files; char_u *p; - int inquote; - int inbacktick; int i; #ifdef FEAT_LISTCMDS int match; --- 911,916 ---- *************** *** 885,922 **** ((char_u **)new_ga.ga_data)[new_ga.ga_len++] = str; --new_ga.ga_room; ! /* ! * Isolate one argument, taking quotes and backticks. ! * Quotes are removed, backticks remain. ! */ ! inquote = FALSE; ! inbacktick = FALSE; ! for (p = str; *str; ++str) ! { ! /* ! * for MSDOS et.al. a backslash is part of a file name. ! * Only skip ", space and tab. ! */ ! if (rem_backslash(str)) ! { ! *p++ = *str++; ! *p++ = *str; ! } ! else ! { ! /* An item ends at a space not in quotes or backticks */ ! if (!inquote && !inbacktick && vim_isspace(*str)) ! break; ! if (!inquote && *str == '`') ! inbacktick ^= TRUE; ! if (!inbacktick && *str == '"') ! inquote ^= TRUE; ! else ! *p++ = *str; ! } ! } ! str = skipwhite(str); ! *p = NUL; } #ifdef FEAT_LISTCMDS --- 930,937 ---- ((char_u **)new_ga.ga_data)[new_ga.ga_len++] = str; --new_ga.ga_room; ! /* Isolate one argument, change it in-place, put a NUL after it. */ ! str = do_one_arg(str); } #ifdef FEAT_LISTCMDS *** ../vim61.172/src/proto/ex_cmds2.pro Fri Mar 22 21:41:08 2002 --- src/proto/ex_cmds2.pro Sat Sep 7 16:07:46 2002 *************** *** 15,20 **** --- 15,21 ---- int check_changed_any __ARGS((int hidden)); int check_fname __ARGS((void)); int buf_write_all __ARGS((buf_T *buf, int forceit)); + char_u *do_one_arg __ARGS((char_u *str)); void check_arg_idx __ARGS((win_T *win)); void ex_args __ARGS((exarg_T *eap)); void ex_previous __ARGS((exarg_T *eap)); *** ../vim61.172/VisVim/Commands.cpp Mon Jan 7 17:15:57 2002 --- VisVim/Commands.cpp Sat Sep 7 17:03:06 2002 *************** *** 524,532 **** #ifdef SINGLE_WINDOW // Update the current file in Vim if it has been modified sprintf (VimCmdStart, ":up\n"); - #else - // Split the window if the current file has been modified - sprintf (VimCmdStart, ":if &mod | split | endif\n"); #endif if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf))) goto OleError; --- 524,529 ---- *************** *** 536,542 **** VimChangeDir (VimOle, DispatchId, FileName); // Make Vim open the file ! sprintf (VimCmd, ":e %S\n", (char*) FileName); // Convert all \ to / for (s = VimCmd; *s; ++s) if (*s == '\\') --- 533,539 ---- VimChangeDir (VimOle, DispatchId, FileName); // Make Vim open the file ! sprintf (VimCmd, ":drop %S\n", (char*) FileName); // Convert all \ to / for (s = VimCmd; *s; ++s) if (*s == '\\') *** ../vim61.172/src/version.c Sat Sep 7 15:05:56 2002 --- src/version.c Sat Sep 7 17:03:59 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 173, /**/ -- The war between Emacs and Vi is over. Vi has won with 3 to 1. http://www.ssc.com/lg/issue30/raymond.html /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///