Skip to content

Commit d7f40ee

Browse files
mariovalneyjdalton
authored andcommitted
Fix line-between broking when file start with comment
Issue 525
1 parent 38cd55e commit d7f40ee

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

src/options/lines-between-rulesets.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ let option = {
236236
if (this.prevLineIsComment(node, index) || this.isComment(prevChild)) {
237237
let lastNonCommentIndex = this.findLatestNonCommentNode(node, index);
238238
prevChild = node.get(lastNonCommentIndex);
239+
240+
if (!prevChild) {
241+
return;
242+
}
239243
}
240244

241245
if (prevChild.is('space')) {

test/options/lines-between-rulesets/process/css/2-lines-between-rulesets.expected.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*comment*/
12
.foo {background: red;}
23

34

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/*comment*/
12
.foo {background: red;}/*comment*/.bar{border: 1px solid red;}.baz{color: #fff;}

test/options/lines-between-rulesets/process/css/lines-between-rulesets.expected.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*comment*/
12
.foo {background: red;}
23

34
/*comment*/.bar{border: 1px solid red;}

0 commit comments

Comments
 (0)