Hello Vim developers; attached is a patch to apply the P_NODUP flag to the 'backupskip' option to prevent duplicate paths being added to it, and a test for the same.

--
Tom Ryder <https://sanctum.geek.nz/>

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20190612120837.GA2593%40conan.
For more options, visit https://groups.google.com/d/optout.
>From 57f92ab5e975928ed6621f816db0719a1ec0622e Mon Sep 17 00:00:00 2001
From: Tom Ryder <[email protected]>
Date: Sun, 9 Jun 2019 02:15:05 +1200
Subject: [PATCH] Add P_NODUP flag to 'backupskip' for uniqueness

Without this flag, adding values to 'backupskip' using :set with the +=
or ^= operators, called repeatedly, stacks the same filename patterns
up without a filter for uniqueness:

    :set backupskip=/foo/bar/* backupskip?
      backupskip=/foo/bar/*
    :set backupskip^=/foo/bar/* backupskip?
      backupskip=/foo/bar/*,/foo/bar/*
    :set backupskip^=/foo/bar/* backupskip?
      backupskip=/foo/bar/*,/foo/bar/*,/foo/bar/*

Adding this flag corrects the issue, so that only one instance of any
file pattern is allowed.
---
 src/option.c                 | 2 +-
 src/testdir/test_options.vim | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/option.c b/src/option.c
index 2146be7ef..1d88ea473 100644
--- a/src/option.c
+++ b/src/option.c
@@ -616,7 +616,7 @@ static struct vimoption options[] =
                            (char_u *)"~",
 #endif
                                            (char_u *)0L} SCTX_INIT},
-    {"backupskip",  "bsk",  P_STRING|P_VI_DEF|P_ONECOMMA,
+    {"backupskip",  "bsk",  P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
 #ifdef FEAT_WILDIGN
                            (char_u *)&p_bsk, PV_NONE,
                            {(char_u *)"", (char_u *)0L}
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 13de71934..713c30553 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -419,6 +419,15 @@ func Test_backupskip()
       call assert_true(found, var . ' (' . varvalue . ') not in option bsk: ' 
. &bsk)
     endif
   endfor
+
+  " Duplicates should be filtered out (option has P_NODUP)
+  let backupskip = &backupskip
+  set backupskip=
+  set backupskip+=/test/dir
+  set backupskip+=/test/dir
+  call assert_equal(&backupskip, '/test/dir')
+  let &backupskip = backupskip
+
 endfunc
 
 func Test_copy_winopt()
-- 
2.21.0

Raspunde prin e-mail lui