diff --git a/src/cssLanguageService.ts b/src/cssLanguageService.ts index 010f2cf2..4589ddf8 100644 --- a/src/cssLanguageService.ts +++ b/src/cssLanguageService.ts @@ -116,7 +116,7 @@ export function getCSSLanguageService(options: LanguageServiceOptions = defaultL new Parser(), new CSSCompletion(null, options, cssDataManager), new CSSHover(options && options.clientCapabilities, cssDataManager), - new CSSNavigation(options && options.fileSystemProvider, false), + new CSSNavigation(options && options.fileSystemProvider, true), new CSSCodeActions(cssDataManager), new CSSValidation(cssDataManager), cssDataManager diff --git a/src/services/cssNavigation.ts b/src/services/cssNavigation.ts index b61d564c..8202e3da 100644 --- a/src/services/cssNavigation.ts +++ b/src/services/cssNavigation.ts @@ -593,7 +593,7 @@ function toTwoDigitHex(n: number): string { export function getModuleNameFromPath(path: string) { const firstSlash = path.indexOf('/'); if (firstSlash === -1) { - return ''; + return path; } // If a scoped module (starts with @) then get up until second instance of '/', or to the end of the string for root-level imports. diff --git a/src/test/css/navigation.test.ts b/src/test/css/navigation.test.ts index 9670ac40..4b17a50d 100644 --- a/src/test/css/navigation.test.ts +++ b/src/test/css/navigation.test.ts @@ -460,6 +460,16 @@ suite('CSS - Navigation', () => { [{ range: newRange(8, 24), target: getTestResource('green/c.css') }], 'css', testUri, workspaceFolder ); }); + + test('bare module specifier resolving', async function () { + const ls = getCSSLS(); + const testUri = getTestResource('about.css'); + const workspaceFolder = getTestResource(''); + + await assertLinks(ls, '@import "foo/bar.css"', + [{ range: newRange(8, 21), target: getTestResource('node_modules/foo/bar.css') }], 'css', testUri, workspaceFolder + ); + }); }); suite('Color', () => { diff --git a/test/linksTestFixtures/node_modules/foo/bar.css b/test/linksTestFixtures/node_modules/foo/bar.css new file mode 100644 index 00000000..0faf92b0 --- /dev/null +++ b/test/linksTestFixtures/node_modules/foo/bar.css @@ -0,0 +1 @@ +/* test fixture */