From 0790fc84245b7242a4ee03b045961ad01319cae4 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Tue, 29 Oct 2019 13:49:53 +0100 Subject: [PATCH 1/2] Fix indentation for parents with newlines in nested mode Fixes https://github.com/sass/libsass/issues/3018 --- src/inspect.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/inspect.cpp b/src/inspect.cpp index d2c7e1b75..6dd7f6a92 100644 --- a/src/inspect.cpp +++ b/src/inspect.cpp @@ -1056,6 +1056,9 @@ namespace Sass { { if (sel->hasPreLineFeed()) { append_optional_linefeed(); + if (output_style() == NESTED) { + append_indentation(); + } } const SelectorComponent* prev = nullptr; for (auto& item : sel->elements()) { From 5c267e129d4d16eff74f5ea3339e282deb35b00d Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Tue, 29 Oct 2019 14:34:31 +0100 Subject: [PATCH 2/2] Preserve indentation for media rules in nested mode --- src/inspect.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/inspect.cpp b/src/inspect.cpp index 6dd7f6a92..e581edc42 100644 --- a/src/inspect.cpp +++ b/src/inspect.cpp @@ -72,8 +72,6 @@ namespace Sass { append_indentation(); append_token("@media", rule); append_mandatory_space(); - in_media_block = true; - in_media_block = false; if (rule->block()) { rule->block()->perform(this); } @@ -81,6 +79,8 @@ namespace Sass { void Inspect::operator()(CssMediaRule* rule) { + if (output_style() == NESTED) + indentation += rule->tabs(); append_indentation(); append_token("@media", rule); append_mandatory_space(); @@ -97,6 +97,9 @@ namespace Sass { if (rule->block()) { rule->block()->perform(this); } + in_media_block = false; + if (output_style() == NESTED) + indentation -= rule->tabs(); } void Inspect::operator()(CssMediaQuery* query) @@ -1056,7 +1059,7 @@ namespace Sass { { if (sel->hasPreLineFeed()) { append_optional_linefeed(); - if (output_style() == NESTED) { + if (!in_wrapped && output_style() == NESTED) { append_indentation(); } }