summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/textmodes/css-mode.el2
-rw-r--r--test/lisp/textmodes/css-mode-tests.el6
2 files changed, 7 insertions, 1 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 1de4ff0fca9..f2481da8aa1 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1037,7 +1037,7 @@ This recognizes CSS-color-4 extensions."
STR is the incoming CSS hex color.
This function simply drops any transparency."
;; Either #RGB or #RRGGBB, drop the "A" or "AA".
- (if (> (length str) 4)
+ (if (> (length str) 5)
(substring str 0 7)
(substring str 0 4)))
diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el
index 47cf5f9244b..1e58751f140 100644
--- a/test/lisp/textmodes/css-mode-tests.el
+++ b/test/lisp/textmodes/css-mode-tests.el
@@ -295,6 +295,12 @@
(insert input ")"))
(should (equal (css--hsl-color) "#ff0000")))))
+(ert-deftest css-test-hex-color ()
+ (should (equal (css--hex-color "#abc") "#abc"))
+ (should (equal (css--hex-color "#abcd") "#abc"))
+ (should (equal (css--hex-color "#aabbcc") "#aabbcc"))
+ (should (equal (css--hex-color "#aabbccdd") "#aabbcc")))
+
(ert-deftest css-test-named-color ()
(dolist (text '("@mixin black" "@include black"))
(with-temp-buffer