1 Star 0 Fork 58

寓述/vim

forked from openMajun/vim 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-giving-the-error-0-more-files-to-edit.patch 2.66 KB
一键复制 编辑 原始数据 按行查看 历史
renmingshuai 提交于 2022-01-17 17:38 +08:00 . fix CVE-2021-4166 CVE-2021-4192 CVE-2021-4193
From 7b22117c4ecf383b6f35acef041773a83ec28220 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Mon, 17 Aug 2020 19:34:10 +0200
Subject: [PATCH] patch 8.2.1472: ":argdel" does not work like ":.argdel" as
documented
Conflict:NA
Reference:https://github.com/vim/vim/commit/7b22117c4ecf383b6f35acef041773a83ec28220
Problem: ":argdel" does not work like ":.argdel" as documented. (Alexey
Demin)
Solution: Make ":argdel" work like ":.argdel". (closes #6727)
Also fix giving the error "0 more files to edit".
---
src/arglist.c | 18 +++++++++++++-----
src/ex_docmd.c | 2 +-
src/testdir/test_arglist.vim | 10 ++++++++--
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/src/arglist.c b/src/arglist.c
index b1a6a0b..cab74f8 100644
--- a/src/arglist.c
+++ b/src/arglist.c
@@ -776,10 +776,20 @@ ex_argdelete(exarg_T *eap)
int i;
int n;
- if (eap->addr_count > 0)
+ if (eap->addr_count > 0 || *eap->arg == NUL)
{
- // ":1,4argdel": Delete all arguments in the range.
- if (eap->line2 > ARGCOUNT)
+ // ":argdel" works like ":argdel"
+ if (eap->addr_count == 0)
+ {
+ if (curwin->w_arg_idx >= ARGCOUNT)
+ {
+ emsg(_("E610: No argument to delete"));
+ return;
+ }
+ eap->line1 = eap->line2 = curwin->w_arg_idx + 1;
+ }
+ else if (eap->line2 > ARGCOUNT)
+ // ":1,4argdel": Delete all arguments in the range.
eap->line2 = ARGCOUNT;
n = eap->line2 - eap->line1 + 1;
if (*eap->arg != NUL)
@@ -808,8 +818,6 @@ ex_argdelete(exarg_T *eap)
curwin->w_arg_idx = ARGCOUNT - 1;
}
}
- else if (*eap->arg == NUL)
- emsg(_(e_argreq));
else
do_arglist(eap->arg, AL_DEL, 0, FALSE);
#ifdef FEAT_TITLE
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index cb6b64a..dfcbf37 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4719,7 +4719,7 @@ check_more(
int n = ARGCOUNT - curwin->w_arg_idx - 1;
if (!forceit && only_one_window()
- && ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0)
+ && ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0)
{
if (message)
{
diff --git a/src/testdir/test_arglist.vim b/src/testdir/test_arglist.vim
index c486b18..3e1e175 100644
--- a/src/testdir/test_arglist.vim
+++ b/src/testdir/test_arglist.vim
@@ -416,9 +416,15 @@ func Test_argdelete()
last
argdelete %
call assert_equal(['b'], argv())
- call assert_fails('argdelete', 'E471:')
+ call assert_fails('argdelete', 'E610:')
call assert_fails('1,100argdelete', 'E16:')
- %argd
+
+ call Reset_arglist()
+ args a b c d
+ next
+ argdel
+ call Assert_argc(['a', 'c', 'd'])
+ %argdel
endfunc
func Test_argdelete_completion()
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wqh0122/vim.git
git@gitee.com:wqh0122/vim.git
wqh0122
vim
vim
master

搜索帮助