diff options
Diffstat (limited to 'data/vim/patches/8.1.0341')
-rw-r--r-- | data/vim/patches/8.1.0341 | 312 |
1 files changed, 312 insertions, 0 deletions
diff --git a/data/vim/patches/8.1.0341 b/data/vim/patches/8.1.0341 new file mode 100644 index 000000000..fed330424 --- /dev/null +++ b/data/vim/patches/8.1.0341 @@ -0,0 +1,312 @@ +To: vim_dev@googlegroups.com +Subject: Patch 8.1.0341 +Fcc: outbox +From: Bram Moolenaar <Bram@moolenaar.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +------------ + +Patch 8.1.0341 +Problem: :argadd in empty buffer changes the buffer name. (Pavol Juhas) +Solution: Don't re-use the current buffer when not going to edit the file. + (closes #3397) Do re-use the current buffer for :next. +Files: src/ex_cmds2.c, src/testdir/test_arglist.vim, + src/testdir/test_command_count.vim + + +*** ../vim-8.1.0340/src/ex_cmds2.c 2018-08-30 13:07:12.026033864 +0200 +--- src/ex_cmds2.c 2018-08-31 23:00:26.400150737 +0200 +*************** +*** 2445,2454 **** + */ + + static char_u *do_one_arg(char_u *str); +! static int do_arglist(char_u *str, int what, int after); + static void alist_check_arg_idx(void); + static int editing_arg_idx(win_T *win); +! static int alist_add_list(int count, char_u **files, int after); + #define AL_SET 1 + #define AL_ADD 2 + #define AL_DEL 3 +--- 2445,2454 ---- + */ + + static char_u *do_one_arg(char_u *str); +! static int do_arglist(char_u *str, int what, int after, int will_edit); + static void alist_check_arg_idx(void); + static int editing_arg_idx(win_T *win); +! static void alist_add_list(int count, char_u **files, int after, int will_edit); + #define AL_SET 1 + #define AL_ADD 2 + #define AL_DEL 3 +*************** +*** 2553,2559 **** + void + set_arglist(char_u *str) + { +! do_arglist(str, AL_SET, 0); + } + + /* +--- 2553,2559 ---- + void + set_arglist(char_u *str) + { +! do_arglist(str, AL_SET, 0, FALSE); + } + + /* +*************** +*** 2567,2573 **** + do_arglist( + char_u *str, + int what, +! int after UNUSED) /* 0 means before first one */ + { + garray_T new_ga; + int exp_count; +--- 2567,2574 ---- + do_arglist( + char_u *str, + int what, +! int after UNUSED, // 0 means before first one +! int will_edit) // will edit added argument + { + garray_T new_ga; + int exp_count; +*************** +*** 2652,2662 **** + + if (what == AL_ADD) + { +! (void)alist_add_list(exp_count, exp_files, after); + vim_free(exp_files); + } + else /* what == AL_SET */ +! alist_set(ALIST(curwin), exp_count, exp_files, FALSE, NULL, 0); + } + + alist_check_arg_idx(); +--- 2653,2663 ---- + + if (what == AL_ADD) + { +! alist_add_list(exp_count, exp_files, after, will_edit); + vim_free(exp_files); + } + else /* what == AL_SET */ +! alist_set(ALIST(curwin), exp_count, exp_files, will_edit, NULL, 0); + } + + alist_check_arg_idx(); +*************** +*** 2932,2938 **** + { + if (*eap->arg != NUL) /* redefine file list */ + { +! if (do_arglist(eap->arg, AL_SET, 0) == FAIL) + return; + i = 0; + } +--- 2933,2939 ---- + { + if (*eap->arg != NUL) /* redefine file list */ + { +! if (do_arglist(eap->arg, AL_SET, 0, TRUE) == FAIL) + return; + i = 0; + } +*************** +*** 2952,2958 **** + // Whether curbuf will be reused, curbuf->b_ffname will be set. + int curbuf_is_reusable = curbuf_reusable(); + +! if (do_arglist(eap->arg, AL_ADD, i) == FAIL) + return; + #ifdef FEAT_TITLE + maketitle(); +--- 2953,2959 ---- + // Whether curbuf will be reused, curbuf->b_ffname will be set. + int curbuf_is_reusable = curbuf_reusable(); + +! if (do_arglist(eap->arg, AL_ADD, i, TRUE) == FAIL) + return; + #ifdef FEAT_TITLE + maketitle(); +*************** +*** 2974,2980 **** + ex_argadd(exarg_T *eap) + { + do_arglist(eap->arg, AL_ADD, +! eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1); + #ifdef FEAT_TITLE + maketitle(); + #endif +--- 2975,2982 ---- + ex_argadd(exarg_T *eap) + { + do_arglist(eap->arg, AL_ADD, +! eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1, +! FALSE); + #ifdef FEAT_TITLE + maketitle(); + #endif +*************** +*** 3024,3030 **** + else if (*eap->arg == NUL) + EMSG(_(e_argreq)); + else +! do_arglist(eap->arg, AL_DEL, 0); + #ifdef FEAT_TITLE + maketitle(); + #endif +--- 3026,3032 ---- + else if (*eap->arg == NUL) + EMSG(_(e_argreq)); + else +! do_arglist(eap->arg, AL_DEL, 0, FALSE); + #ifdef FEAT_TITLE + maketitle(); + #endif +*************** +*** 3269,3281 **** + * Add files[count] to the arglist of the current window after arg "after". + * The file names in files[count] must have been allocated and are taken over. + * Files[] itself is not taken over. +- * Returns index of first added argument. Returns -1 when failed (out of mem). + */ +! static int + alist_add_list( + int count, + char_u **files, +! int after) /* where to add: 0 = before first one */ + { + int i; + int old_argcount = ARGCOUNT; +--- 3271,3283 ---- + * Add files[count] to the arglist of the current window after arg "after". + * The file names in files[count] must have been allocated and are taken over. + * Files[] itself is not taken over. + */ +! static void + alist_add_list( + int count, + char_u **files, +! int after, // where to add: 0 = before first one +! int will_edit) // will edit adding argument + { + int i; + int old_argcount = ARGCOUNT; +*************** +*** 3291,3309 **** + (ARGCOUNT - after) * sizeof(aentry_T)); + for (i = 0; i < count; ++i) + { + ARGLIST[after + i].ae_fname = files[i]; +! ARGLIST[after + i].ae_fnum = +! buflist_add(files[i], BLN_LISTED | BLN_CURBUF); + } + ALIST(curwin)->al_ga.ga_len += count; + if (old_argcount > 0 && curwin->w_arg_idx >= after) + curwin->w_arg_idx += count; +! return after; + } + + for (i = 0; i < count; ++i) + vim_free(files[i]); +- return -1; + } + + #if defined(FEAT_CMDL_COMPL) || defined(PROTO) +--- 3293,3311 ---- + (ARGCOUNT - after) * sizeof(aentry_T)); + for (i = 0; i < count; ++i) + { ++ int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0); ++ + ARGLIST[after + i].ae_fname = files[i]; +! ARGLIST[after + i].ae_fnum = buflist_add(files[i], flags); + } + ALIST(curwin)->al_ga.ga_len += count; + if (old_argcount > 0 && curwin->w_arg_idx >= after) + curwin->w_arg_idx += count; +! return; + } + + for (i = 0; i < count; ++i) + vim_free(files[i]); + } + + #if defined(FEAT_CMDL_COMPL) || defined(PROTO) +*** ../vim-8.1.0340/src/testdir/test_arglist.vim 2018-04-24 21:54:38.000000000 +0200 +--- src/testdir/test_arglist.vim 2018-08-31 22:42:29.649222626 +0200 +*************** +*** 80,85 **** +--- 80,103 ---- + call assert_equal(0, len(argv())) + endfunc + ++ func Test_argadd_empty_curbuf() ++ new ++ let curbuf = bufnr('%') ++ call writefile(['test', 'Xargadd'], 'Xargadd') ++ " must not re-use the current buffer. ++ argadd Xargadd ++ call assert_equal(curbuf, bufnr('%')) ++ call assert_equal('', bufname('%')) ++ call assert_equal(1, line('$')) ++ rew ++ call assert_notequal(curbuf, bufnr('%')) ++ call assert_equal('Xargadd', bufname('%')) ++ call assert_equal(2, line('$')) ++ ++ %argd ++ bwipe! ++ endfunc ++ + func Init_abc() + args a b c + next +*** ../vim-8.1.0340/src/testdir/test_command_count.vim 2018-04-24 21:47:12.000000000 +0200 +--- src/testdir/test_command_count.vim 2018-08-31 23:01:54.967036898 +0200 +*************** +*** 158,164 **** + func Test_command_count_4() + %argd + let bufnr = bufnr('$') +! arga aa bb cc dd ee ff + 3argu + let args = [] + .,$-argdo call add(args, expand('%')) +--- 158,166 ---- + func Test_command_count_4() + %argd + let bufnr = bufnr('$') +! next aa bb cc dd ee ff +! call assert_equal(bufnr, bufnr('%')) +! + 3argu + let args = [] + .,$-argdo call add(args, expand('%')) +*** ../vim-8.1.0340/src/version.c 2018-08-31 22:26:49.210912007 +0200 +--- src/version.c 2018-08-31 22:44:55.551715626 +0200 +*************** +*** 796,797 **** +--- 796,799 ---- + { /* Add new patch number below this line */ ++ /**/ ++ 341, + /**/ + +-- +login: yes +password: I don't know, please tell me +password is incorrect +login: yes +password: incorrect + + /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ +/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ +\\\ an exciting new programming language -- http://www.Zimbu.org /// + \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |