mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-30 13:31:07 +01:00
fix #41207
This commit is contained in:
@@ -141,7 +141,7 @@ export class SnippetFile {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
readonly filepath: string,
|
readonly filepath: string,
|
||||||
private readonly _defaultScope: string,
|
readonly defaultScopes: string[],
|
||||||
private readonly _extension: IExtensionDescription
|
private readonly _extension: IExtensionDescription
|
||||||
) {
|
) {
|
||||||
this.isGlobalSnippets = extname(filepath) === '.code-snippets';
|
this.isGlobalSnippets = extname(filepath) === '.code-snippets';
|
||||||
@@ -149,7 +149,7 @@ export class SnippetFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select(selector: string, bucket: Snippet[]): void {
|
select(selector: string, bucket: Snippet[]): void {
|
||||||
if (this.isGlobalSnippets) {
|
if (this.isGlobalSnippets || !this.isUserSnippets) {
|
||||||
this._scopeSelect(selector, bucket);
|
this._scopeSelect(selector, bucket);
|
||||||
} else {
|
} else {
|
||||||
this._filepathSelect(selector, bucket);
|
this._filepathSelect(selector, bucket);
|
||||||
@@ -229,8 +229,8 @@ export class SnippetFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let scopes: string[];
|
let scopes: string[];
|
||||||
if (this._defaultScope) {
|
if (this.defaultScopes) {
|
||||||
scopes = [this._defaultScope];
|
scopes = this.defaultScopes;
|
||||||
} else if (typeof snippet.scope === 'string') {
|
} else if (typeof snippet.scope === 'string') {
|
||||||
scopes = snippet.scope.split(',').filter(s => !isFalsyOrWhitespace(s));
|
scopes = snippet.scope.split(',').filter(s => !isFalsyOrWhitespace(s));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -163,7 +163,11 @@ class SnippetsService implements ISnippetsService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const file = new SnippetFile(contribution.path, contribution.language, extension.description);
|
if (this._files.has(contribution.path)) {
|
||||||
|
this._files.get(contribution.path).defaultScopes.push(contribution.language);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const file = new SnippetFile(contribution.path, [contribution.language], extension.description);
|
||||||
this._files.set(file.filepath, file);
|
this._files.set(file.filepath, file);
|
||||||
|
|
||||||
if (this._environmentService.isExtensionDevelopment) {
|
if (this._environmentService.isExtensionDevelopment) {
|
||||||
@@ -185,6 +189,8 @@ class SnippetsService implements ISnippetsService {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -195,7 +201,7 @@ class SnippetsService implements ISnippetsService {
|
|||||||
const ext = extname(filepath);
|
const ext = extname(filepath);
|
||||||
if (ext === '.json') {
|
if (ext === '.json') {
|
||||||
const langName = basename(filepath, '.json');
|
const langName = basename(filepath, '.json');
|
||||||
this._files.set(filepath, new SnippetFile(filepath, langName, undefined));
|
this._files.set(filepath, new SnippetFile(filepath, [langName], undefined));
|
||||||
|
|
||||||
} else if (ext === '.code-snippets') {
|
} else if (ext === '.code-snippets') {
|
||||||
this._files.set(filepath, new SnippetFile(filepath, undefined, undefined));
|
this._files.set(filepath, new SnippetFile(filepath, undefined, undefined));
|
||||||
|
|||||||
Reference in New Issue
Block a user