Skip to content

Commit

Permalink
[scss] Path resolver to include partial files support (#373)
Browse files Browse the repository at this point in the history
* Support partials on path resolver

* Inline SCSS extension removal in target URI parsing
  • Loading branch information
Dyhagho Briceño committed Nov 27, 2023
1 parent 8090d87 commit f86d093
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/services/scssNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand All @@ -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('_')) {
Expand Down
4 changes: 4 additions & 0 deletions src/test/scss/scssNavigation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
]);
Expand Down

0 comments on commit f86d093

Please sign in to comment.