Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Commit 870bc55

Browse files
committed
Make isLastDeclarationCompleted recognize declaration blocks
1 parent 400c41c commit 870bc55

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/utils/general.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ const reverseString = str => str.split('').reverse().join('')
4646
const isLastDeclarationCompleted = text => {
4747
const reversedText = reverseString(text)
4848
const lastNonWhitespaceChar = nextNonWhitespaceChar(reversedText)
49-
if (lastNonWhitespaceChar === ';' || lastNonWhitespaceChar === null) {
49+
if (
50+
lastNonWhitespaceChar === ';' ||
51+
lastNonWhitespaceChar === '}' ||
52+
lastNonWhitespaceChar === null
53+
) {
5054
return true
5155
} else {
5256
return false

test/utils.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,15 @@ describe('utils', () => {
290290
`)
291291
).toBe(true)
292292
})
293+
294+
it('handles declaration blocks', () => {
295+
const prevCSS = `
296+
@media screen and (max-width: 600px) {
297+
display: block;
298+
color: red;
299+
}
300+
`
301+
expect(fn(prevCSS)).toBe(true)
302+
})
293303
})
294304
})

0 commit comments

Comments
 (0)