diff src/arglist.c @ 26719:2bdcce61a4e4 v8.2.3888

patch 8.2.3888: the argument list may contain duplicates Commit: https://github.com/vim/vim/commit/73a024209cbfbd5b39a2e974084d807c6131e2ed Author: Nir Lichtman <nir_lichtman@hotmail.com> Date: Fri Dec 24 20:28:03 2021 +0000 patch 8.2.3888: the argument list may contain duplicates Problem: The argument list may contain duplicates. Solution: Add the :argdedeupe command. (Nir Lichtman, closes https://github.com/vim/vim/issues/6235)
author Bram Moolenaar <Bram@vim.org>
date Fri, 24 Dec 2021 21:30:03 +0100
parents 5860bd619d30
children 2aeea8611342
line wrap: on
line diff
--- 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