Skip to content

Conversation

ramya-rao-a
Copy link

@ramya-rao-a ramya-rao-a commented Aug 11, 2017

The css parser fails to parse the below less example from http://lesscss.org/features/#loops-feature

.generate-columns(4);

.generate-columns(@n, @i: 1) when (@i =< @n) {
  .column-@{i} {
    width: (@i * 100% / @n);
  }
  .generate-columns(@n, (@i + 1));
}

This PR will fix the parsing issue

cc @sergeche

@sergeche
Copy link
Member

Have to check it more thoroughly, I’m developing a new Emmet feature for LESS and SCSS based on CSS parser, might be already solved

@ramya-rao-a
Copy link
Author

ramya-rao-a commented Aug 14, 2017

The current fix is pretty harmless. It ensures that tokens array is not empty before trying to access tokens[0]

@rzhao271
Copy link

rzhao271 commented Jan 4, 2021

Have to check it more thoroughly, I’m developing a new Emmet feature for LESS and SCSS based on CSS parser, might be already solved

@sergeche any updates on this repo for LESS and SCSS, or is the new feature within the main Emmet repo?

@sergeche
Copy link
Member

sergeche commented Jan 5, 2021

Is this issue reproducible in new Emmet?

@rzhao271
Copy link

Sorry, didn't realize that new changes were added to this repo since v0.4.0 😅
I have been working on other parts of vscode and haven't tried reproducing this issue yet, though.

@rzhao271
Copy link

Alright, just tested it with v0.4.0.
I created a new LESS file with the same contents as #1 (comment).

Then, I tried expanding an abbreviation, which causes the parser to run, and I see the following error:

TypeError: Cannot read property 'type' of undefined
        at parseStylesheet (/home/node/workspace/vscode/extensions/emmet/node_modules/@emmetio/css-parser/dist/css-parser.cjs.js:1490:22)
        at Object.getRootNode (/home/node/workspace/vscode/extensions/emmet/out/parseDocument.js:24:26)
        at getRootNode (/home/node/workspace/vscode/extensions/emmet/out/abbreviationActions.js:324:40)
        at /home/node/workspace/vscode/extensions/emmet/out/abbreviationActions.js:338:46
        at Array.forEach (<anonymous>)
        at Obj…/ipc/common/ipc.net.js:189:37)
        at /home/node/workspace/vscode/out/vs/base/parts/ipc/common/ipc.net.js:158:61
        at Socket.listener (/home/node/workspace/vscode/out/vs/base/parts/ipc/node/ipc.net.js:17:40)
        at Socket.emit (events.js:315:20)
        at addChunk (_stream_readable.js:295:12)
        at readableAddChunk (_stream_readable.js:271:9)
        at Socket.push (_stream_readable.js:212:10)
        at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
        at Pipe.callbackTrampoline (internal/async_hooks.js:120:14)

I also confirmed that this error does not show up with Ramya's patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants