Skip to content

Commit 9ef6af4

Browse files
committed
fix: doing that logic in getLanguageId was racy
1 parent bd21542 commit 9ef6af4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

extensions/vscode/src/language-server/languagePlugin.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ import { FILES_FOLDER, SOLUTION_FOLDER } from '../models/tree/constants';
66
export function frontmatterPlugin(_debug: (message: string) => void): LanguagePlugin<URI> {
77
return {
88
getLanguageId(uri) {
9-
// only match markdown files inside the src/content/tutorial folder
10-
if (!uri.path.match(/.*src\/content\/tutorial\/.*(content|meta)\.mdx?$/)) {
11-
return undefined;
12-
}
13-
14-
// but ignore all files under _files or _solution
15-
if (uri.path.includes(FILES_FOLDER) || uri.path.includes(SOLUTION_FOLDER)) {
16-
return undefined;
17-
}
18-
199
if (uri.path.endsWith('.md')) {
2010
return 'markdown';
2111
}
@@ -26,7 +16,17 @@ export function frontmatterPlugin(_debug: (message: string) => void): LanguagePl
2616

2717
return undefined;
2818
},
29-
createVirtualCode(_uri, languageId, snapshot) {
19+
createVirtualCode(uri, languageId, snapshot) {
20+
// only match markdown files inside the src/content/tutorial folder
21+
if (!uri.path.match(/.*src\/content\/tutorial\/.*(content|meta)\.mdx?$/)) {
22+
return undefined;
23+
}
24+
25+
// but ignore all files under _files or _solution
26+
if (uri.path.includes(FILES_FOLDER) || uri.path.includes(SOLUTION_FOLDER)) {
27+
return undefined;
28+
}
29+
3030
if (languageId === 'markdown' || languageId === 'mdx') {
3131
return new FrontMatterVirtualCode(snapshot);
3232
}

0 commit comments

Comments
 (0)