1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-13 09:32:47 +00:00

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.
This commit is contained in:
Simen Heggestøyl 2018-01-28 13:03:05 +01:00
parent 9824885fab
commit 97defdfc36
2 changed files with 4 additions and 2 deletions

View File

@ -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))

View File

@ -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))