microsoft / vscode-css-languageservice

CSS, LESS & SCSS language service extracted from VSCode to be reused, e.g in the Monaco editor.
MIT License
317 stars 176 forks source link

scss: ctrl+click on import from node_modules not working on nested folders #316

Open lucas-labs opened 1 year ago

lucas-labs commented 1 year ago

Ctrl/cmd+Click links to node_modules on imports/use only works in .scss files located at the same level as the node_modules folder, but it doesn't work if the scss is inside a nested folder. Consider this scenario:

project
├── node_modules
│   └── @scope
│       └── lib
│           └── index.scss
│  
│  
├── here-it-works.scss   <---- at project root, when node_modules is located in the same folder
│                              as the file, Ctrl+click will work 
│              
└── folder
    └── here-it-doesnt.scss  <-- one level deeper into the folder structure, it doesn't work anymore :(
// /here-it-works.scss

@use "@scope/lib"; // Ctrl+Click here will redirect you to node_modules/@scope/lib/index.scss
// /folder/here-it-doesnt-work.scss

@use "@scope/lib"; // Ctrl+Click will try to locate a file called
                   // "lib" in /folder/@scope/lib instead of 
                   // looking into root-level node_modules

A screenrecored gif to further explain what I'm talking about (this was recorded on a clean vscode instance, without any extensions installed, by runing it with the --profile-temp flag):

vscode-scss-issue