diff --git a/src/extensions/default/InlineColorEditor/InlineColorEditor.js b/src/extensions/default/InlineColorEditor/InlineColorEditor.js index 666e40167ed..efa2fe3bc95 100644 --- a/src/extensions/default/InlineColorEditor/InlineColorEditor.js +++ b/src/extensions/default/InlineColorEditor/InlineColorEditor.js @@ -59,7 +59,7 @@ define(function (require, exports, module) { * rgb()/rgba() function format, or hsl()/hsla() function format. * @const @type {RegExp} */ - InlineColorEditor.COLOR_REGEX = /#[a-f0-9]{6}|#[a-f0-9]{3}|rgb\( ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?\)|rgba\( ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b(1|0|0\.[0-9]{1,3}) ?\)|hsl\( ?\b([0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9]|360)\b ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b([0-9]{1,2}|100)\b% ?\)|hsla\( ?\b([0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9]|360)\b ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b(1|0|0\.[0-9]{1,3}) ?\)/gi; + InlineColorEditor.COLOR_REGEX = /#[a-f0-9]{6}|#[a-f0-9]{3}|rgb\( ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?\)|rgba\( ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b ?, ?(1|0|0?\.[0-9]{1,3}) ?\)|hsl\( ?\b([0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9]|360)\b ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b([0-9]{1,2}|100)\b% ?\)|hsla\( ?\b([0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9]|360)\b ?, ?\b([0-9]{1,2}|100)\b% ?, ?\b([0-9]{1,2}|100)\b% ?, ?(1|0|0?\.[0-9]{1,3}) ?\)/gi; InlineColorEditor.prototype = Object.create(InlineWidget.prototype); InlineColorEditor.prototype.constructor = InlineColorEditor; diff --git a/src/extensions/default/InlineColorEditor/unittest-files/unittests.css b/src/extensions/default/InlineColorEditor/unittest-files/unittests.css index e259401d772..e4bf1ec40b1 100644 --- a/src/extensions/default/InlineColorEditor/unittest-files/unittests.css +++ b/src/extensions/default/InlineColorEditor/unittest-files/unittests.css @@ -40,4 +40,12 @@ .in-shorthand { border: 1px solid #0f0f0f; -} \ No newline at end of file +} + +.rgba-leading-period { + background: rgba(100, 200, 150, .5); +} + +.hsla-leading-period { + background: hsla(180, 50%, 50%, .5); +} diff --git a/src/extensions/default/InlineColorEditor/unittests.js b/src/extensions/default/InlineColorEditor/unittests.js index 69ab0aac418..ca97c75d5e3 100644 --- a/src/extensions/default/InlineColorEditor/unittests.js +++ b/src/extensions/default/InlineColorEditor/unittests.js @@ -143,6 +143,12 @@ define(function (require, exports, module) { it("should show the correct color when opened on a color in a shorthand property", function () { testOpenColor({line: 41, ch: 27}, "#0f0f0f"); }); + it("should show the correct color when opened on an rgba() color with a leading period in the alpha field", function () { + testOpenColor({line: 45, ch: 18}, "rgba(100, 200, 150, .5)"); + }); + it("should show the correct color when opened on an hsla() color with a leading period in the alpha field", function () { + testOpenColor({line: 49, ch: 18}, "hsla(180, 50%, 50%, .5)"); + }); it("should not open when not on a color", function () { makeColorEditor({line: 1, ch: 6}); @@ -1406,4 +1412,4 @@ define(function (require, exports, module) { }); }); }); -}); \ No newline at end of file +});