To: vim-dev@vim.org Subject: Patch 6.1.313 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.313 Problem: When a ":drop fname" command is used and "fname" is open in another window, it is also opened in the current window. Solution: Change to the window with "fname" instead. Don't redefine the argument list when dropping only one file. Files: runtime/doc/windows.txt, src/ex_cmds2.c, src/ex_cmds.c, src/ex_docmd.c, src/proto/ex_cmds2.pro, src/proto/ex_docmd.pro *** ../vim61.312/runtime/doc/windows.txt Fri Mar 22 21:18:42 2002 --- runtime/doc/windows.txt Sat Feb 1 16:40:03 2003 *************** *** 1,4 **** ! *windows.txt* For Vim version 6.1. Last change: 2002 Jan 30 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *windows.txt* For Vim version 6.1. Last change: 2003 Feb 01 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 588,597 **** *:dr* *:drop* :dr[op] {file} .. ! Redefine the argument list to "{file} ..", similar to ":next". ! The first file is edited in the current window if possible. ! If the current buffer can't be |abandon|ed, the window is ! split first. The purpose of this command is that it can be used from a program that wants Vim to edit another file, e.g., a debugger. {only available when compiled with the +gui feature} --- 588,601 ---- *:dr* *:drop* :dr[op] {file} .. ! Edit the first file in a window. ! - If the file is already open in a window change to that ! window. ! - If the file is not open in a window edit the file in the ! current window. If the current buffer can't be |abandon|ed, ! the window is split first. ! When there are two or more arguments the |argument-list| is ! set, like with the |:next| command. The purpose of this command is that it can be used from a program that wants Vim to edit another file, e.g., a debugger. {only available when compiled with the +gui feature} *** ../vim61.312/src/ex_cmds2.c Thu Jan 30 22:21:10 2003 --- src/ex_cmds2.c Thu Jan 30 22:58:26 2003 *************** *** 921,926 **** --- 921,936 ---- #define AL_DEL 3 /* + * Redefine the argument list. + */ + void + set_arglist(str) + char_u *str; + { + do_arglist(str, AL_SET, 0); + } + + /* * "what" == AL_SET: Redefine the argument list to 'str'. * "what" == AL_ADD: add files in 'str' to the argument list after "after". * "what" == AL_DEL: remove files in 'str' from the argument list. *** ../vim61.312/src/ex_cmds.c Tue Jan 7 21:08:49 2003 --- src/ex_cmds.c Sat Feb 1 14:19:35 2003 *************** *** 5639,5710 **** #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO) /* * ":drop" */ void ex_drop(eap) exarg_T *eap; { int split = FALSE; ! /* Check whether the current buffer is changed. If so, we will need ! * to split the current window or data could be lost. ! * We don't need to check if the 'hidden' option is set, as in this ! * case the buffer won't be lost. */ ! if (!P_HID(curbuf)) { ! ++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. */ ! if (split) { ! eap->cmdidx = CMD_snext; ! eap->cmd[0] = 's'; } else ! eap->cmdidx = CMD_next; ! ex_next(eap); } #endif --- 5639,5750 ---- #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO) /* * ":drop" + * Opens the first argument in a window. When there are two or more arguments + * the argument list is redefined. */ void ex_drop(eap) exarg_T *eap; { int split = FALSE; + int incurwin = FALSE; + char_u *arg; + int two_or_more = FALSE; + char_u *first = NULL; + win_T *wp; + buf_T *buf; ! /* ! * Check if the first argument is already being edited in a window. If ! * so, jump to that window. ! * We would actually need to check all arguments, but that's complicated ! * and mostly only one file is dropped. */ ! arg = vim_strsave(eap->arg); ! if (arg != NULL) { ! /* Get the first argument, remove quotes, make it a full path. */ ! two_or_more = (*do_one_arg(arg) != NUL); ! first = fix_fname(arg); ! if (first != NULL) { ! buf = buflist_findname(first); ! FOR_ALL_WINDOWS(wp) { ! if (wp->w_buffer == buf) { ! incurwin = TRUE; ! # ifdef FEAT_WINDOWS ! win_enter(wp, TRUE); ! break; ! # endif } ! } ! vim_free(first); ! if (incurwin) ! { ! /* Already editing the file. If there are more redefine the ! * argument list. */ ! if (two_or_more) { ! set_arglist(eap->arg); ! curwin->w_arg_idx = 0; } + vim_free(arg); + return; } } + vim_free(arg); + } + + /* + * Check whether the current buffer is changed. If so, we will need + * to split the current window or data could be lost. + * Skip the check if the 'hidden' option is set, as in this case the + * buffer won't be lost. + */ + if (!P_HID(curbuf)) + { + # ifdef FEAT_WINDOWS + ++emsg_off; + # endif + split = check_changed(curbuf, TRUE, FALSE, FALSE, FALSE); + # ifdef FEAT_WINDOWS + --emsg_off; + # else + if (split) + return; + # endif } ! if (two_or_more) { ! /* Fake a ":snext" or ":next" command, redefine the arglist. */ ! if (split) ! { ! eap->cmdidx = CMD_snext; ! eap->cmd[0] = 's'; ! } ! else ! eap->cmdidx = CMD_next; ! ex_next(eap); } else ! { ! /* Fake a ":split" or ":edit" command, don't change the arglist. */ ! # ifdef FEAT_WINDOWS ! if (split) ! { ! eap->cmdidx = CMD_split; ! ex_splitview(eap); ! } ! else ! # endif ! { ! eap->cmdidx = CMD_edit; ! do_exedit(eap, NULL); ! } ! } } #endif *** ../vim61.312/src/ex_docmd.c Sun Jan 19 20:06:08 2003 --- src/ex_docmd.c Sat Feb 1 14:09:49 2003 *************** *** 138,144 **** static void ex_only __ARGS((exarg_T *eap)); static void ex_all __ARGS((exarg_T *eap)); static void ex_resize __ARGS((exarg_T *eap)); - static void ex_splitview __ARGS((exarg_T *eap)); static void ex_stag __ARGS((exarg_T *eap)); #else # define ex_close ex_ni --- 138,143 ---- *************** *** 5537,5543 **** * :vnew [[+command] file] split vertically window with no or new file * :sfind [+command] file split window with file in 'path' */ ! static void ex_splitview(eap) exarg_T *eap; { --- 5536,5542 ---- * :vnew [[+command] file] split vertically window with no or new file * :sfind [+command] file split window with file in 'path' */ ! void ex_splitview(eap) exarg_T *eap; { *** ../vim61.312/src/proto/ex_cmds2.pro Sat Sep 7 17:16:30 2002 --- src/proto/ex_cmds2.pro Thu Jan 30 23:04:47 2003 *************** *** 16,21 **** --- 16,22 ---- 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 set_arglist __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.312/src/proto/ex_docmd.pro Fri Mar 22 21:41:08 2002 --- src/proto/ex_docmd.pro Sat Feb 1 14:19:04 2003 *************** *** 26,31 **** --- 26,32 ---- void alist_set __ARGS((alist_T *al, int count, char_u **files, int use_curbuf)); void alist_add __ARGS((alist_T *al, char_u *fname, int set_fnum)); void alist_slash_adjust __ARGS((void)); + void ex_splitview __ARGS((exarg_T *eap)); void do_exedit __ARGS((exarg_T *eap, win_T *old_curwin)); void do_sleep __ARGS((long msec)); FILE *open_exfile __ARGS((char_u *fname, int forceit, char *mode)); *** ../vim61.312/src/version.c Thu Jan 30 22:21:10 2003 --- src/version.c Sat Feb 1 14:39:45 2003 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 313, /**/ -- I AM THANKFUL... ...for all the complaining I hear about the government because it means we have freedom of speech. /// 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 /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///