File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ module.exports = {
88 if ( token [ 0 ] === 'word' && token [ 1 ] . slice ( 0 , 2 ) === '//' ) {
99 const first = token ;
1010 const bits = [ ] ;
11- let last ;
11+ let endOffset ;
1212 let remainingInput ;
1313
1414 while ( token ) {
@@ -20,7 +20,12 @@ module.exports = {
2020
2121 // Get remaining input and retokenize
2222 remainingInput = token [ 1 ] . substring ( token [ 1 ] . indexOf ( '\n' ) ) ;
23- remainingInput += this . input . css . valueOf ( ) . substring ( this . tokenizer . position ( ) ) ;
23+ const untokenizedRemainingInput = this . input . css
24+ . valueOf ( )
25+ . substring ( this . tokenizer . position ( ) ) ;
26+ remainingInput += untokenizedRemainingInput ;
27+
28+ endOffset = token [ 3 ] + untokenizedRemainingInput . length - remainingInput . length ;
2429 } else {
2530 // If the tokenizer went to the next line go back
2631 this . tokenizer . back ( token ) ;
@@ -29,11 +34,12 @@ module.exports = {
2934 }
3035
3136 bits . push ( token [ 1 ] ) ;
32- last = token ;
37+ // eslint-disable-next-line prefer-destructuring
38+ endOffset = token [ 2 ] ;
3339 token = this . tokenizer . nextToken ( { ignoreUnclosed : true } ) ;
3440 }
3541
36- const newToken = [ 'comment' , bits . join ( '' ) , first [ 2 ] , last [ 2 ] ] ;
42+ const newToken = [ 'comment' , bits . join ( '' ) , first [ 2 ] , endOffset ] ;
3743 this . inlineComment ( newToken ) ;
3844
3945 // Replace tokenizer to retokenize the rest of the string
Original file line number Diff line number Diff line change @@ -180,7 +180,7 @@ test('inline comments with asterisk are persisted (#135)', (t) => {
180180 t . is ( nodeToString ( root ) , less ) ;
181181} ) ;
182182
183- test . only ( 'handles single quotes in comments (#163)' , ( t ) => {
183+ test ( 'handles single quotes in comments (#163)' , ( t ) => {
184184 const less = `a {\n // '\n color: pink;\n}\n\n/** ' */` ;
185185
186186 const root = parse ( less ) ;
@@ -203,8 +203,7 @@ test.only('handles single quotes in comments (#163)', (t) => {
203203 t . is ( innerCommentNode . source . start . line , 2 ) ;
204204 t . is ( innerCommentNode . source . start . column , 3 ) ;
205205 t . is ( innerCommentNode . source . end . line , 2 ) ;
206- // TODO: this test is failing
207- // t.is(innerCommentNode.source.end.column, 6);
206+ t . is ( innerCommentNode . source . end . column , 6 ) ;
208207
209208 t . is ( declarationNode . source . start . line , 3 ) ;
210209 t . is ( declarationNode . source . start . column , 3 ) ;
You can’t perform that action at this time.
0 commit comments