Skip to content

Commit

Permalink
Merge pull request #5 from wkillerud/fix/namespace-file-is-index
Browse files Browse the repository at this point in the history
Fix a bug when namespace file is `_index.scss`
  • Loading branch information
wkillerud authored May 29, 2022
2 parents 96f9ece + 4fa6f91 commit fe165ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "some-sass",
"displayName": "Some Sass",
"description": "Autocompletion, refactoring, and documentation support for SCSS",
"version": "2.1.0",
"description": "Provides code suggestions, documentation and code navigation for modern SCSS",
"version": "2.1.1",
"publisher": "SomewhatStationery",
"license": "MIT",
"engines": {
Expand Down
13 changes: 11 additions & 2 deletions src/unsafe/services/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,18 @@ function getNamespaceFromLink(link: DocumentLink): string | undefined {

const lastSlash = link.target.lastIndexOf('/');
const extension = link.target.lastIndexOf('.');
const candidate = link.target.substring(lastSlash + 1, extension);
let candidate = link.target.substring(lastSlash + 1, extension);

return candidate.startsWith("_") ? candidate.substring(1) : candidate;
candidate = candidate.startsWith("_") ? candidate.substring(1) : candidate;

if (candidate === "index") {
// The link points to an index file. Use the folder name above as a namespace.
const linkOmitIndex = link.target.substring(0, lastSlash);
const newLastSlash = linkOmitIndex.lastIndexOf('/');
candidate = linkOmitIndex.substring(newLastSlash + 1);
}

return candidate;
}

function ensureScssExtension(target: string): string {
Expand Down

0 comments on commit fe165ab

Please sign in to comment.