未验证 提交 8e89438a 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #59092 from noamyogev84/feature_42838

Allow snippet json prefix to be an array to support multiple prefixes for the same snippet
......@@ -41,7 +41,7 @@ const languageScopeSchema: IJSONSchema = {
properties: {
prefix: {
description: nls.localize('snippetSchema.json.prefix', 'The prefix to used when selecting the snippet in intellisense'),
type: 'string'
type: ['string', 'array']
},
body: {
description: nls.localize('snippetSchema.json.body', 'The snippet content. Use \'$1\', \'${1:defaultText}\' to define cursor positions, use \'$0\' for the final cursor position. Insert variable values with \'${varName}\' and \'${varName:defaultText}\', e.g \'This is file: $TM_FILENAME\'.'),
......@@ -76,7 +76,7 @@ const globalSchema: IJSONSchema = {
properties: {
prefix: {
description: nls.localize('snippetSchema.json.prefix', 'The prefix to used when selecting the snippet in intellisense'),
type: 'string'
type: ['string', 'array']
},
scope: {
description: nls.localize('snippetSchema.json.scope', "A list of language names to which this snippet applies, e.g 'typescript,javascript'."),
......
......@@ -234,7 +234,7 @@ export class SnippetFile {
body = body.join('\n');
}
if (typeof prefix !== 'string' || typeof body !== 'string') {
if ((typeof prefix !== 'string' && !Array.isArray(prefix)) || typeof body !== 'string') {
return;
}
......@@ -264,14 +264,17 @@ export class SnippetFile {
}
}
bucket.push(new Snippet(
scopes,
name,
prefix,
description,
body,
source,
this.source
));
let prefixes = Array.isArray(prefix) ? prefix : [prefix];
prefixes.forEach(p => {
bucket.push(new Snippet(
scopes,
name,
p,
description,
body,
source,
this.source
));
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册