]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't let `css--property-values' return duplicates
authorSimen Heggestøyl <simenheg@gmail.com>
Sun, 24 Apr 2016 17:57:42 +0000 (19:57 +0200)
committerSimen Heggestøyl <simenheg@gmail.com>
Sun, 24 Apr 2016 17:58:36 +0000 (19:58 +0200)
* lisp/textmodes/css-mode.el (css--property-values): Don't return
duplicate values.

* test/lisp/textmodes/css-mode-tests.el (css-test-property-values):
Take the above into account.
(css-test-property-values-no-duplicates): Test that duplicates aren't
returned by `css--property-values'.

lisp/textmodes/css-mode.el
test/lisp/textmodes/css-mode-tests.el

index 8a4daac353a15d61be9a47f578dd3912d7a4c183..608462b36a6244d5552a240ccd0b049398bc2482 100644 (file)
@@ -793,13 +793,14 @@ Completion candidates are looked up in `css-property-alist' by
 the string PROPERTY."
   (or (gethash property css--property-value-cache)
       (let ((values
-             (seq-mapcat
-              (lambda (value)
-                (if (stringp value)
-                    (list value)
-                  (or (css--value-class-lookup value)
-                      (css--property-values (symbol-name value)))))
-              (cdr (assoc property css-property-alist)))))
+             (seq-uniq
+              (seq-mapcat
+               (lambda (value)
+                 (if (stringp value)
+                     (list value)
+                   (or (css--value-class-lookup value)
+                       (css--property-values (symbol-name value)))))
+               (cdr (assoc property css-property-alist))))))
         (puthash property values css--property-value-cache))))
 
 (defun css--complete-property-value ()
index 805364c9f4216e4212c4e2315716d5e95f6bdf7a..5d5873b301bfc9efe2766de2401c45689187695e 100644 (file)
@@ -24,8 +24,9 @@
 
 ;;; Code:
 
-(require 'ert)
 (require 'css-mode)
+(require 'ert)
+(require 'seq)
 
 (ert-deftest css-test-property-values ()
   ;; The `float' property has a flat value list.
   ;; The `list-style' property refers to several other properties.
   (should
    (equal (sort (css--property-values "list-style") #'string-lessp)
-          (sort (append (css--property-values "list-style-type")
-                        (css--property-values "list-style-position")
-                        (css--property-values "list-style-image"))
+          (sort (seq-uniq
+                 (append (css--property-values "list-style-type")
+                         (css--property-values "list-style-position")
+                         (css--property-values "list-style-image")))
                 #'string-lessp)))
 
   ;; The `position' property is tricky because it's also the name of a
     (should (equal (gethash "word-wrap" css--property-value-cache)
                    word-wrap-values))))
 
+(ert-deftest css-test-property-values-no-duplicates ()
+  "Test that `css--property-values' returns no duplicates."
+  ;; The `flex' property is prone to duplicate values; if they aren't
+  ;; removed, it'll contain at least two instances of `auto'.
+  (should
+   (equal (sort (css--property-values "flex") #'string-lessp)
+          '("auto" "content" "none"))))
+
 (ert-deftest css-test-value-class-lookup ()
   (should
    (equal (sort (css--value-class-lookup 'position) #'string-lessp)