diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-16 15:29:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 15:29:36 +0800 |
commit | da13ed43cb3593f6d50e08fc6e5f26760da63f84 (patch) | |
tree | e210a95266c01861b206479bcda6e3835d2ca4c7 /src/nvim/arglist.c | |
parent | cf3b871fa940c42e9c94257118f7d1131ebd362a (diff) | |
download | rneovim-da13ed43cb3593f6d50e08fc6e5f26760da63f84.tar.gz rneovim-da13ed43cb3593f6d50e08fc6e5f26760da63f84.tar.bz2 rneovim-da13ed43cb3593f6d50e08fc6e5f26760da63f84.zip |
vim-patch:8.2.3888: the argument list may contain duplicates (#19795)
Problem: The argument list may contain duplicates.
Solution: Add the :argdedeupe command. (Nir Lichtman, closes vim/vim#6235)
https://github.com/vim/vim/commit/73a024209cbfbd5b39a2e974084d807c6131e2ed
Use latest index.txt :argdedupe doc from Vim.
Diffstat (limited to 'src/nvim/arglist.c')
-rw-r--r-- | src/nvim/arglist.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index d19f6ed623..7d8917cc73 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -620,6 +620,29 @@ void ex_next(exarg_T *eap) } } +/// ":argdedupe" +void ex_argdedupe(exarg_T *eap FUNC_ATTR_UNUSED) +{ + for (int i = 0; i < ARGCOUNT; i++) { + for (int j = i + 1; j < ARGCOUNT; j++) { + if (FNAMECMP(ARGLIST[i].ae_fname, ARGLIST[j].ae_fname) == 0) { + xfree(ARGLIST[j].ae_fname); + memmove(ARGLIST + j, ARGLIST + j + 1, + (size_t)(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 ex_argedit(exarg_T *eap) { |