@@ -369,14 +369,14 @@ namespace Sass {
369369 }
370370 }
371371
372- void Node::emit_nested_css (stringstream& buf, size_t depth, bool at_toplevel, bool in_media_query)
372+ void Node::emit_nested_css (stringstream& buf, size_t depth, bool at_toplevel, bool in_media_query, bool source_comments )
373373 {
374374 switch (type ())
375375 {
376376 case root: {
377377 if (has_expansions ()) flatten ();
378378 for (size_t i = 0 , S = size (); i < S; ++i) {
379- at (i).emit_nested_css (buf, depth, true );
379+ at (i).emit_nested_css (buf, depth, true , false , source_comments );
380380 }
381381 } break ;
382382
@@ -386,6 +386,10 @@ namespace Sass {
386386
387387 if (block.has_expansions ()) block.flatten ();
388388 if (block.has_statements () || block.has_comments ()) {
389+ if (source_comments) {
390+ buf << string (2 *depth, ' ' );
391+ buf << " /* line " << sel_group.line () << " , " << sel_group.path () << " */" << endl;
392+ }
389393 buf << string (2 *depth, ' ' );
390394 buf << sel_group.to_string ();
391395 buf << " {" ;
@@ -401,7 +405,7 @@ namespace Sass {
401405 case block_directive:
402406 case blockless_directive:
403407 case warning: {
404- block[i].emit_nested_css (buf, depth+1 );
408+ block[i].emit_nested_css (buf, depth+1 , false , false , source_comments );
405409 } break ;
406410 default : break ;
407411 }
@@ -413,7 +417,7 @@ namespace Sass {
413417 if (block.has_blocks ()) {
414418 for (size_t i = 0 , S = block.size (); i < S; ++i) {
415419 if (block[i].type () == ruleset || block[i].type () == media_query) {
416- block[i].emit_nested_css (buf, depth, false , false ); // last arg should be in_media_query?
420+ block[i].emit_nested_css (buf, depth, false , false , source_comments ); // last arg should be in_media_query?
417421 }
418422 }
419423 }
@@ -435,7 +439,7 @@ namespace Sass {
435439 // just print out the comments without a block
436440 for (size_t i = 0 , S = block.size (); i < S; ++i) {
437441 if (block[i].type () == comment)
438- block[i].emit_nested_css (buf, depth+1 );
442+ block[i].emit_nested_css (buf, depth+1 , false , false , source_comments );
439443 }
440444 }
441445 if (has_statements) {
@@ -457,7 +461,7 @@ namespace Sass {
457461 case blockless_directive:
458462 case warning: {
459463 // if (stm_type != comment) buf << endl;
460- block[i].emit_nested_css (buf, depth+1 );
464+ block[i].emit_nested_css (buf, depth+1 , false , false , source_comments );
461465 } break ;
462466
463467 default : break ;
@@ -470,15 +474,15 @@ namespace Sass {
470474 Type stm_type = block[i].type ();
471475 if (stm_type == comment && !has_statements) {
472476 if (i > 0 && block[i-1 ].type () == ruleset) buf << endl;
473- block[i].emit_nested_css (buf, depth+1 , false , true );
477+ block[i].emit_nested_css (buf, depth+1 , false , true , source_comments );
474478 }
475479 if (stm_type == ruleset || stm_type == media_query) {
476480 buf << endl;
477481 if (i > 0 &&
478482 block[i-1 ].type () == ruleset &&
479483 !block[i-1 ][1 ].has_blocks ())
480484 { buf << endl; }
481- block[i].emit_nested_css (buf, depth+1 , false , true );
485+ block[i].emit_nested_css (buf, depth+1 , false , true , source_comments );
482486 }
483487 }
484488 }
@@ -510,7 +514,7 @@ namespace Sass {
510514 default :
511515 break ;
512516 }
513- block[i].emit_nested_css (buf, depth+1 , false , in_media_query);
517+ block[i].emit_nested_css (buf, depth+1 , false , in_media_query, source_comments );
514518 }
515519 buf << " }" << endl;
516520 if ((depth == 0 ) && at_toplevel && !in_media_query) buf << endl;
0 commit comments