diff --git a/js/src/css/beautifier.js b/js/src/css/beautifier.js index 997eeb78e..37c3c2c67 100644 --- a/js/src/css/beautifier.js +++ b/js/src/css/beautifier.js @@ -443,7 +443,12 @@ Beautifier.prototype.beautify = function() { } } } else { - this.preserveSingleSpace(isAfterSpace); + var space_needed = false; + if (this._input.lookBack("with")) { + // look back is not an accurate solution, we need tokens to confirm without whitespaces + space_needed = true; + } + this.preserveSingleSpace(isAfterSpace || space_needed); this.print_string(this._ch); // handle scss/sass map diff --git a/python/cssbeautifier/css/beautifier.py b/python/cssbeautifier/css/beautifier.py index f5e1d03a0..011c00a72 100644 --- a/python/cssbeautifier/css/beautifier.py +++ b/python/cssbeautifier/css/beautifier.py @@ -462,7 +462,11 @@ def beautify(self): parenLevel -= 1 self.outdent() else: - self.preserveSingleSpace(isAfterSpace) + space_needed = False + if self._input.lookBack("with"): + # look back is not an accurate solution, we need tokens to confirm without whitespaces + space_needed = True + self.preserveSingleSpace(isAfterSpace or space_needed) self.print_string(self._ch) # handle scss/sass map diff --git a/test/data/css/tests.js b/test/data/css/tests.js index e04190872..38190b052 100644 --- a/test/data/css/tests.js +++ b/test/data/css/tests.js @@ -1504,10 +1504,19 @@ exports.test_data = { ] }] }, { - name: "Issue #1798 - space after strings in preserved", + name: "Regression tests - with default options", description: "", tests: [{ + comment: "Issue #1798 - space after strings in preserved", unchanged: '@use "variables" as *;' + }, { + comment: "Issue #1976 - support the new @forwards syntax", + input: [ + '@forwards "a" with (', + ' $a: 2', + ');' + ], + output: '@forwards "a" with ($a: 2);' }] }, { name: "Issue #1817",