Skip to content

Commit 30b5469

Browse files
author
Alasdair McLeay
committed
add some documentation
1 parent f0b9a60 commit 30b5469

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

extensions/css-language-features/server/src/utils/documentContext.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ export function getDocumentContext(documentUri: string, workspaceFolders: Worksp
4040
}
4141
}
4242
}
43+
// Following [css-loader](https://github.com/webpack-contrib/css-loader#url)
44+
// and [sass-loader's](https://github.com/webpack-contrib/sass-loader#imports)
45+
// convention, if an import path starts with ~ then use node module resolution
46+
// *unless* it starts with "~/" as this refers to the user's home directory.
4347
if (ref[0] === '~' && ref[1] !== '/') {
4448
const moduleName = getModuleNameFromPath(ref.substring(1));
4549
const modulePath = require.resolve(moduleName, { paths: [base] });
46-
const pathInModule = ref.substring(moduleName.length + 2);
47-
return url.resolve(modulePath, pathInModule);
50+
const pathWithinModule = ref.substring(moduleName.length + 2);
51+
return url.resolve(modulePath, pathWithinModule);
4852
}
4953
return url.resolve(base, ref);
5054
},

0 commit comments

Comments
 (0)