Skip to content

Commit

Permalink
Fix issue with compressed output mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Mar 4, 2021
1 parent dc92cb3 commit 64b1fc3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
1 change: 0 additions & 1 deletion include/sass/values.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ extern "C" {
SASS_ERROR,
SASS_WARNING,
SASS_FUNCTION,
SASS_PARENT,
};

// List separators
Expand Down
22 changes: 15 additions & 7 deletions src/emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Sass {
// add outstanding delimiter
void Emitter::finalize(bool final)
{
scheduled_space = 0;
scheduled_space = false;
if (output_style() == SASS_STYLE_COMPRESSED)
if (final) scheduled_delimiter = false;
if (scheduled_linefeed)
Expand All @@ -90,8 +90,8 @@ namespace Sass {

for (size_t i = 0; i < scheduled_linefeed; i++)
linefeeds += opt.linefeed;
scheduled_space = 0;
scheduled_linefeed = 0;
scheduled_space = false;
scheduled_linefeed = false;
if (scheduled_delimiter) {
scheduled_delimiter = false;
write_char(';');
Expand All @@ -101,7 +101,7 @@ namespace Sass {
}
else if (scheduled_space) {
sass::string spaces(scheduled_space, ' ');
scheduled_space = 0;
scheduled_space = false;
if (scheduled_delimiter) {
scheduled_delimiter = false;
write_char(';');
Expand Down Expand Up @@ -249,21 +249,29 @@ namespace Sass {

void Emitter::append_comma_separator()
{
// scheduled_space = 0;
scheduled_space = false;
append_char(',');
append_optional_space();
}

void Emitter::append_colon_separator()
{
scheduled_space = 0;
scheduled_space = false;
append_char(':');
if (!in_custom_property) append_optional_space();
}

void Emitter::append_mandatory_space()
{
scheduled_space = 1;
if (buffer().empty()) {
scheduled_space = true;
}
else {
unsigned char lst = buffer().at(buffer().length() - 1);
if (!isspace(lst)) {
scheduled_space = true;
}
}
}

void Emitter::append_optional_space()
Expand Down
6 changes: 3 additions & 3 deletions src/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace Sass {
if (iL == i + 1) break;
next = text[i+1];
if (isHex(next) || next == $space || next == $tab) {
append_char($space);
append_mandatory_space();
}
break;
case $backslash:
Expand Down Expand Up @@ -391,7 +391,7 @@ namespace Sass {
append_mandatory_space();
for (CssMediaQueryObj query : import->media()) {
if (first == false) {
append_char($comma);
append_comma_separator();
append_optional_space();
}
acceptCssMediaQuery(query);
Expand Down Expand Up @@ -488,7 +488,7 @@ namespace Sass {
append_optional_linefeed();
}
for (SelectorComponentObj& item : complex->elements()) {
if (many) append_optional_space();
if (many) append_mandatory_space();
if (SelectorCombinator* combinator = item->isaSelectorCombinator()) {
visitSelectorCombinator(combinator);
}
Expand Down

0 comments on commit 64b1fc3

Please sign in to comment.