Skip to content

Commit 1823a09

Browse files
committed
Merge pull request #1138 from mgreter/bugfix/issue_1080
Fix order of top nodes (comments and imports)
2 parents 7f119a8 + 94cbc82 commit 1823a09

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

output.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ namespace Sass {
88
Output::Output(Context* ctx)
99
: Inspect(Emitter(ctx)),
1010
charset(""),
11-
top_imports(0),
12-
top_comments(0)
11+
top_nodes(0)
1312
{}
1413

1514
Output::~Output() { }
@@ -21,7 +20,7 @@ namespace Sass {
2120

2221
void Output::operator()(Import* imp)
2322
{
24-
top_imports.push_back(imp);
23+
top_nodes.push_back(imp);
2524
}
2625

2726
OutputBuffer Output::get_buffer(void)
@@ -30,15 +29,9 @@ namespace Sass {
3029
Emitter emitter(ctx);
3130
Inspect inspect(emitter);
3231

33-
size_t size_com = top_comments.size();
34-
for (size_t i = 0; i < size_com; i++) {
35-
top_comments[i]->perform(&inspect);
36-
inspect.append_mandatory_linefeed();
37-
}
38-
39-
size_t size_imp = top_imports.size();
40-
for (size_t i = 0; i < size_imp; i++) {
41-
top_imports[i]->perform(&inspect);
32+
size_t size_nodes = top_nodes.size();
33+
for (size_t i = 0; i < size_nodes; i++) {
34+
top_nodes[i]->perform(&inspect);
4235
inspect.append_mandatory_linefeed();
4336
}
4437

@@ -79,8 +72,8 @@ namespace Sass {
7972
// if (indentation && txt == "/**/") return;
8073
bool important = c->is_important();
8174
if (output_style() != COMPRESSED || important) {
82-
if (buffer().size() + top_imports.size() == 0) {
83-
top_comments.push_back(c);
75+
if (buffer().size() == 0) {
76+
top_nodes.push_back(c);
8477
} else {
8578
in_comment = true;
8679
append_indentation();

output.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ namespace Sass {
3030

3131
protected:
3232
string charset;
33-
vector<Import*> top_imports;
34-
vector<Comment*> top_comments;
33+
vector<AST_Node*> top_nodes;
3534

3635
public:
3736
OutputBuffer get_buffer(void);

0 commit comments

Comments
 (0)