Repository navigation
#163967 css alias - #460
Simon Stranks (SStranks) wants to merge 19 commits into
Conversation
fix(): folder reference now '/' from '/*'
| } from '../languageFacts/facts.js'; | ||
| import { startsWith } from '../utils/strings.js'; | ||
| import { dirname, joinPath } from '../utils/resources.js'; | ||
| import { readFile } from 'node:fs/promises'; |
There was a problem hiding this comment.
We must not use nodejs functionality as the code can also run in the browser.
To read files use the fileSystemProvider
|
Finding and loading settings should not be part of the vscode-css-languageservice. That should be done outside, by the client of the service. |
Martin Aeschlimann (aeschli)
left a comment
There was a problem hiding this comment.
Finding and loading settings should not be part of the vscode-css-languageservice. That should be done outside, by the client of the service.
vscode-css-languageservice should just get the AliasSettings
| const json = JSON.parse(text); | ||
| return json; | ||
| } catch (error) { | ||
| console.warn(`Failed to read ${candidate}:`, error); |
There was a problem hiding this comment.
remove console statement
| const root = URI.parse(workspaceFolder); | ||
| let current = document; | ||
|
|
||
| while (current.path.startsWith(root.path)) { |
There was a problem hiding this comment.
Should be a proper isEqualOrParent
https://github.com/microsoft/vscode/blob/62fb9237b776e53ecfbdac4050dd55c61912e3d8/src/vs/base/common/extpath.ts#L227
In conjunction with Pull Request #197033 on the vscode repository.
I reworked the previous merged code for this feature so that it now handles single-root, multi-root, and mono-repo project structures.
To clarify, aliases for css/scss are specified in the
.vscode/settings.jsonunder 'importAliases' for each language as before - I have updated the tool-tip descriptions in the package.nls.json file, and made code changes to cssServer to accommodate the functionality in the current PR - see PR 197033 above.Functionality
.vscode/settings.jsonfrom document towards workspace root.clearCache()method toCSSNavigation; to be called when settings.json changes (see limitations section below)Changes
Limitations
clearCache()method only fires when settings files tracked by vscode are changed. Settings files discovered by lookup in cssNavigation are not covered. I didn't see a straightforward way to implement this; vscode cssServer importsconnection.onDidChangeConfigurationfrom vscode-languageserver, and handles the watcher. Willing to make further changes if someone can suggest how/where to look.