• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision29eccef07e2f914dc64bdf5f1d80ce13e24b41ec (tree)
l'heure2021-01-23 23:30:04
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.2397: Vim9: "%%" not seen as alternate file name for ":bdel"

Commit: https://github.com/vim/vim/commit/dfbc5fd879d92c2a79ced1e1d16dc89f4d55772d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 23 15:15:01 2021 +0100

patch 8.2.2397: Vim9: "%%" not seen as alternate file name for ":bdel"
Problem: Vim9: "%%" not seen as alternate file name for commands with a
buffer name argument.
Solution: Recognize "%%" like "#". (closes #7732)

Change Summary

Modification

diff -r 5f90c249c3e9 -r 29eccef07e2f src/buffer.c
--- a/src/buffer.c Sat Jan 23 14:30:04 2021 +0100
+++ b/src/buffer.c Sat Jan 23 15:30:04 2021 +0100
@@ -2564,12 +2564,15 @@
25642564 char_u *p;
25652565 int toggledollar;
25662566
2567- if (pattern_end == pattern + 1 && (*pattern == '%' || *pattern == '#'))
2567+ // "%" is current file, "%%" or "#" is alternate file
2568+ if ((pattern_end == pattern + 1 && (*pattern == '%' || *pattern == '#'))
2569+ || (in_vim9script() && pattern_end == pattern + 2
2570+ && pattern[0] == '%' && pattern[1] == '%'))
25682571 {
2569- if (*pattern == '%')
2572+ if (*pattern == '#' || pattern_end == pattern + 2)
2573+ match = curwin->w_alt_fnum;
2574+ else
25702575 match = curbuf->b_fnum;
2571- else
2572- match = curwin->w_alt_fnum;
25732576 #ifdef FEAT_DIFF
25742577 if (diffmode && !diff_mode_buf(buflist_findnr(match)))
25752578 match = -1;
diff -r 5f90c249c3e9 -r 29eccef07e2f src/testdir/test_vim9_cmd.vim
--- a/src/testdir/test_vim9_cmd.vim Sat Jan 23 14:30:04 2021 +0100
+++ b/src/testdir/test_vim9_cmd.vim Sat Jan 23 15:30:04 2021 +0100
@@ -68,6 +68,17 @@
6868 edit Xfiletwo
6969 edit %%:r
7070 assert_equal('Xfileone', bufname())
71+
72+ assert_false(bufexists('altfoo'))
73+ edit altfoo
74+ edit bar
75+ assert_true(bufexists('altfoo'))
76+ assert_true(buflisted('altfoo'))
77+ bdel %%
78+ assert_true(bufexists('altfoo'))
79+ assert_false(buflisted('altfoo'))
80+ bwipe! altfoo
81+ bwipe! bar
7182 END
7283 CheckDefAndScriptSuccess(lines)
7384 enddef
diff -r 5f90c249c3e9 -r 29eccef07e2f src/version.c
--- a/src/version.c Sat Jan 23 14:30:04 2021 +0100
+++ b/src/version.c Sat Jan 23 15:30:04 2021 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 2397,
755+/**/
754756 2396,
755757 /**/
756758 2395,
Afficher sur ancien navigateur de dépôt.