diff options
| author | Simen Heggestøyl <simenheg@gmail.com> | 2018-01-28 13:03:05 +0100 |
|---|---|---|
| committer | Simen Heggestøyl <simenheg@gmail.com> | 2018-01-28 13:28:28 +0100 |
| commit | 97defdfc36d9a83a3081c5f76e249f908645f7ec (patch) | |
| tree | 8153be0281d8e52f9e3d32309347080242f65da4 | |
| parent | 9824885fabea53f8c4461d038f4c1edad1b8f591 (diff) | |
| download | emacs-97defdfc36d9a83a3081c5f76e249f908645f7ec.tar.gz | |
Fix off-by-one error in 'css--hex-to-rgb'
* lisp/textmodes/css-mode.el (css--hex-to-rgb): Fix off-by-one error.
* test/lisp/textmodes/css-mode-tests.el (css-test-hex-to-rgb): Add
regression tests for the above fix.
| -rw-r--r-- | lisp/textmodes/css-mode.el | 2 | ||||
| -rw-r--r-- | test/lisp/textmodes/css-mode-tests.el | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 6bd08f59190..135c0d5f928 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1458,7 +1458,7 @@ should not be mixed with those in color.el." (if-let* ((alpha (css--hex-alpha hex)) (a (css--format-rgba-alpha (/ (string-to-number alpha 16) - (float (expt 16 (length alpha))))))) + (float (- (expt 16 (length alpha)) 1)))))) (format "rgba(%d, %d, %d, %s)" r g b a) (format "rgb(%d, %d, %d)" r g b)) t)) diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 272d281217e..4883123843d 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -281,7 +281,9 @@ ("#fff" "rgb(255, 255, 255)") ("#ffffff" "rgb(255, 255, 255)") ("#ffffff80" "rgba(255, 255, 255, 0.5)") - ("#fff8" "rgba(255, 255, 255, 0.5)"))) + ("#fff0" "rgba(255, 255, 255, 0)") + ("#fff8" "rgba(255, 255, 255, 0.53)") + ("#ffff" "rgba(255, 255, 255, 1)"))) (with-temp-buffer (css-mode) (insert (nth 0 item)) |
