summaryrefslogtreecommitdiffstats
path: root/src/arglist.c
diff options
context:
space:
mode:
authorNir Lichtman <nir_lichtman@hotmail.com>2021-12-24 20:28:03 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-24 20:28:03 +0000
commit73a024209cbfbd5b39a2e974084d807c6131e2ed (patch)
tree3fc4d2207a59fd3b0bb04e92d1a282e64e61c4a2 /src/arglist.c
parent806da5176e9e9ab011d927c4ca33a8dde1769539 (diff)
patch 8.2.3888: the argument list may contain duplicatesv8.2.3888
Problem: The argument list may contain duplicates. Solution: Add the :argdedeupe command. (Nir Lichtman, closes #6235)
Diffstat (limited to 'src/arglist.c')
-rw-r--r--src/arglist.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/arglist.c b/src/arglist.c
index af8ce740fc..90ee4796b8 100644
--- a/src/arglist.c
+++ b/src/arglist.c
@@ -759,6 +759,33 @@ ex_next(exarg_T *eap)
}
/*
+ * ":argdedupe"
+ */
+ void
+ex_argdedupe(exarg_T *eap UNUSED)
+{
+ int i;
+ int j;
+
+ for (i = 0; i < ARGCOUNT; ++i)
+ for (j = i + 1; j < ARGCOUNT; ++j)
+ if (fnamecmp(ARGLIST[i].ae_fname, ARGLIST[j].ae_fname) == 0)
+ {
+ vim_free(ARGLIST[j].ae_fname);
+ mch_memmove(ARGLIST + j, ARGLIST + j + 1,
+ (ARGCOUNT - j - 1) * sizeof(aentry_T));
+ --ARGCOUNT;
+
+ if (curwin->w_arg_idx == j)
+ curwin->w_arg_idx = i;
+ else if (curwin->w_arg_idx > j)
+ --curwin->w_arg_idx;
+
+ --j;
+ }
+}
+
+/*
* ":argedit"
*/
void