From f86d0935acb74ad9237076600eed98c071caaa3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dyhagho=20Brice=C3=B1o?= Date: Mon, 27 Nov 2023 22:37:14 +0100 Subject: [PATCH] [scss] Path resolver to include partial files support (#373) * Support partials on path resolver * Inline SCSS extension removal in target URI parsing --- src/services/scssNavigation.ts | 6 +++--- src/test/scss/scssNavigation.test.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/services/scssNavigation.ts b/src/services/scssNavigation.ts index daf21699..fb9e57f8 100644 --- a/src/services/scssNavigation.ts +++ b/src/services/scssNavigation.ts @@ -44,8 +44,8 @@ export class SCSSNavigation extends CSSNavigation { } function toPathVariations(target: string): DocumentUri[] { - // No variation for links that ends with suffix - if (target.endsWith('.scss') || target.endsWith('.css')) { + // No variation for links that ends with .css suffix + if (target.endsWith('.css')) { return [target]; } @@ -54,7 +54,7 @@ function toPathVariations(target: string): DocumentUri[] { return [target + 'index.scss', target + '_index.scss']; } - const targetUri = URI.parse(target); + const targetUri = URI.parse(target.replace(/\.scss$/, '')); const basename = Utils.basename(targetUri); const dirname = Utils.dirname(targetUri); if (basename.startsWith('_')) { diff --git a/src/test/scss/scssNavigation.test.ts b/src/test/scss/scssNavigation.test.ts index 597e7236..922fafb2 100644 --- a/src/test/scss/scssNavigation.test.ts +++ b/src/test/scss/scssNavigation.test.ts @@ -154,6 +154,10 @@ suite('SCSS - Navigation', () => { { range: newRange(8, 13), target: getDocumentUri('./underscore/_foo.scss') } ]); + await assertDynamicLinks(getDocumentUri('./underscore/index.scss'), `@import 'foo.scss'`, [ + { range: newRange(8, 18), target: getDocumentUri('./underscore/_foo.scss') } + ]); + await assertDynamicLinks(getDocumentUri('./both/index.scss'), `@import 'foo'`, [ { range: newRange(8, 13), target: getDocumentUri('./both/foo.scss') } ]);