Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow inline comments in CSS (for preprocessors like SCSS)

  • Loading branch information...
commit 2f836fb69bb49c214dc07417f3f53ac9ba233e36 1 parent 5d5e0f8
Sergey Chikuyonok sergeche authored
27 javascript/parsers/cssParser.js
View
@@ -163,19 +163,30 @@ var walker, tokens = [], isOp, isNameChar, isDigit;
conf = getConf();
cnext = w.nextChar();
-
- if (cnext !== '*') {
+
+ if (cnext === '/') {
+ // inline comment in SCSS and such
+ token += cnext;
+ var pk = w.peek();
+ while (pk && pk !== '\n') {
+ token += cnext;
+ cnext = w.nextChar();
+ pk = w.peek();
+ }
+ } else if (cnext === '*') {
+ // multiline CSS commment
+ while (!(c === "*" && cnext === "/")) {
+ token += cnext;
+ c = cnext;
+ cnext = w.nextChar();
+ }
+ } else {
// oops, not a comment, just a /
conf.charend = conf['char'];
conf.lineend = conf.line;
return tokener(token, token, conf);
}
-
- while (!(c === "*" && cnext === "/")) {
- token += cnext;
- c = cnext;
- cnext = w.nextChar();
- }
+
token += cnext;
w.nextChar();
tokener(token, 'comment', conf);
4 javascript/unittest/tests/css-resolver.js
View
@@ -116,6 +116,10 @@ test('Expand Abbreviation action handler', function() {
editorStub.replaceContent('margin: 0 !${0};');
run('expand_abbreviation');
equal(editorStub.getContent(), 'margin: 0 !important;', 'Added !important modifier');
+
+ editorStub.replaceContent('ul {\n\t// comment?\n\tp10${0}\n}');
+ run('expand_abbreviation');
+ equal(editorStub.getContent(), 'ul {\n\t// comment?\n\tpadding: 10px;\n}', 'Expanded abbreviation inside rule with inline SCSS comment');
editorStub.setSyntax('html');
});
Please sign in to comment.
Something went wrong with that request. Please try again.