diff options
author | Nir Lichtman <nir_lichtman@hotmail.com> | 2021-12-24 20:28:03 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-24 20:28:03 +0000 |
commit | 73a024209cbfbd5b39a2e974084d807c6131e2ed (patch) | |
tree | 3fc4d2207a59fd3b0bb04e92d1a282e64e61c4a2 /src/arglist.c | |
parent | 806da5176e9e9ab011d927c4ca33a8dde1769539 (diff) | |
download | vim-git-73a024209cbfbd5b39a2e974084d807c6131e2ed.tar.gz |
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.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/arglist.c b/src/arglist.c index af8ce740f..90ee4796b 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 |