@codingame/monaco-vscode-snippets-service-override 4.5.1 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/configureSnippets.js +26 -98
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/insertSnippet.js +10 -11
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/surroundWithSnippet.js +3 -6
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetCodeActionProvider.js +18 -35
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetPicker.js +8 -35
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippets.contribution.js +19 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-snippets-service-override",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.2",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@4.5.
|
|
30
|
-
"@codingame/monaco-vscode-files-service-override": "4.5.
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@4.5.2",
|
|
30
|
+
"@codingame/monaco-vscode-files-service-override": "4.5.2"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -15,25 +15,26 @@ import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/br
|
|
|
15
15
|
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
|
|
16
16
|
import { IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
|
|
17
17
|
|
|
18
|
+
const _moduleId = "vs/workbench/contrib/snippets/browser/commands/configureSnippets";
|
|
18
19
|
var ISnippetPick;
|
|
19
|
-
( (function(ISnippetPick) {
|
|
20
|
+
( ((function(ISnippetPick) {
|
|
20
21
|
function is(thing) {
|
|
21
22
|
return !!thing && URI.isUri(thing.filepath);
|
|
22
23
|
}
|
|
23
24
|
ISnippetPick.is = is;
|
|
24
|
-
})(ISnippetPick || (ISnippetPick = {})));
|
|
25
|
+
})(ISnippetPick || (ISnippetPick = {}))));
|
|
25
26
|
async function computePicks(snippetService, userDataProfileService, languageService, labelService) {
|
|
26
27
|
const existing = [];
|
|
27
28
|
const future = [];
|
|
28
|
-
const seen = ( new Set());
|
|
29
|
-
const added = ( new Map());
|
|
29
|
+
const seen = ( (new Set()));
|
|
30
|
+
const added = ( (new Map()));
|
|
30
31
|
for (const file of await snippetService.getSnippetFiles()) {
|
|
31
32
|
if (file.source === 3 ) {
|
|
32
33
|
continue;
|
|
33
34
|
}
|
|
34
35
|
if (file.isGlobalSnippets) {
|
|
35
36
|
await file.load();
|
|
36
|
-
const names = ( new Set());
|
|
37
|
+
const names = ( (new Set()));
|
|
37
38
|
let source;
|
|
38
39
|
outer: for (const snippet of file.data) {
|
|
39
40
|
if (!source) {
|
|
@@ -56,25 +57,16 @@ async function computePicks(snippetService, userDataProfileService, languageServ
|
|
|
56
57
|
label: basename(file.location),
|
|
57
58
|
filepath: file.location,
|
|
58
59
|
description: names.size === 0
|
|
59
|
-
? ( localizeWithPath(
|
|
60
|
-
'
|
|
61
|
-
'global.scope',
|
|
62
|
-
"(global)"
|
|
63
|
-
))
|
|
64
|
-
: ( localizeWithPath(
|
|
65
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
66
|
-
'global.1',
|
|
67
|
-
"({0})",
|
|
68
|
-
[...names].join(', ')
|
|
69
|
-
))
|
|
60
|
+
? ( localizeWithPath(_moduleId, 0, "(global)"))
|
|
61
|
+
: ( localizeWithPath(_moduleId, 1, "({0})", [...names].join(', ')))
|
|
70
62
|
};
|
|
71
63
|
existing.push(snippet);
|
|
72
64
|
if (!source) {
|
|
73
65
|
continue;
|
|
74
66
|
}
|
|
75
67
|
const detail = ( localizeWithPath(
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
_moduleId,
|
|
69
|
+
2,
|
|
78
70
|
"({0}) {1}",
|
|
79
71
|
source,
|
|
80
72
|
labelService.getUriLabel(file.location, { relative: true })
|
|
@@ -99,7 +91,7 @@ async function computePicks(snippetService, userDataProfileService, languageServ
|
|
|
99
91
|
const dir = userDataProfileService.currentProfile.snippetsHome;
|
|
100
92
|
for (const languageId of languageService.getRegisteredLanguageIds()) {
|
|
101
93
|
const label = languageService.getLanguageName(languageId);
|
|
102
|
-
if (label && !( seen.has(languageId))) {
|
|
94
|
+
if (label && !( (seen.has(languageId)))) {
|
|
103
95
|
future.push({
|
|
104
96
|
label: languageId,
|
|
105
97
|
description: `(${label})`,
|
|
@@ -135,34 +127,16 @@ async function createSnippetFile(scope, defaultPath, quickInputService, fileServ
|
|
|
135
127
|
}
|
|
136
128
|
await fileService.createFolder(defaultPath);
|
|
137
129
|
const input = await quickInputService.input({
|
|
138
|
-
placeHolder: ( localizeWithPath(
|
|
139
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
140
|
-
'name',
|
|
141
|
-
"Type snippet file name"
|
|
142
|
-
)),
|
|
130
|
+
placeHolder: ( localizeWithPath(_moduleId, 3, "Type snippet file name")),
|
|
143
131
|
async validateInput(input) {
|
|
144
132
|
if (!input) {
|
|
145
|
-
return ( localizeWithPath(
|
|
146
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
147
|
-
'bad_name1',
|
|
148
|
-
"Invalid file name"
|
|
149
|
-
));
|
|
133
|
+
return ( localizeWithPath(_moduleId, 4, "Invalid file name"));
|
|
150
134
|
}
|
|
151
135
|
if (!isValidBasename(input)) {
|
|
152
|
-
return ( localizeWithPath(
|
|
153
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
154
|
-
'bad_name2',
|
|
155
|
-
"'{0}' is not a valid file name",
|
|
156
|
-
input
|
|
157
|
-
));
|
|
136
|
+
return ( localizeWithPath(_moduleId, 5, "'{0}' is not a valid file name", input));
|
|
158
137
|
}
|
|
159
138
|
if (await fileService.exists(createSnippetUri(input))) {
|
|
160
|
-
return ( localizeWithPath(
|
|
161
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
162
|
-
'bad_name3',
|
|
163
|
-
"'{0}' already exists",
|
|
164
|
-
input
|
|
165
|
-
));
|
|
139
|
+
return ( localizeWithPath(_moduleId, 6, "'{0}' already exists", input));
|
|
166
140
|
}
|
|
167
141
|
return undefined;
|
|
168
142
|
}
|
|
@@ -221,22 +195,10 @@ class ConfigureSnippetsAction extends SnippetsAction {
|
|
|
221
195
|
constructor() {
|
|
222
196
|
super({
|
|
223
197
|
id: 'workbench.action.openSnippets',
|
|
224
|
-
title: ( localize2WithPath(
|
|
225
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
226
|
-
'openSnippet.label',
|
|
227
|
-
"Configure User Snippets"
|
|
228
|
-
)),
|
|
198
|
+
title: ( localize2WithPath(_moduleId, 7, "Configure User Snippets")),
|
|
229
199
|
shortTitle: {
|
|
230
|
-
...( localize2WithPath(
|
|
231
|
-
|
|
232
|
-
'userSnippets',
|
|
233
|
-
"User Snippets"
|
|
234
|
-
)),
|
|
235
|
-
mnemonicTitle: ( localizeWithPath(
|
|
236
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
237
|
-
{ key: 'miOpenSnippets', comment: ['&& denotes a mnemonic'] },
|
|
238
|
-
"User &&Snippets"
|
|
239
|
-
)),
|
|
200
|
+
...( localize2WithPath(_moduleId, 8, "User Snippets")),
|
|
201
|
+
mnemonicTitle: ( localizeWithPath(_moduleId, 9, "User &&Snippets")),
|
|
240
202
|
},
|
|
241
203
|
f1: true,
|
|
242
204
|
menu: [
|
|
@@ -258,61 +220,27 @@ class ConfigureSnippetsAction extends SnippetsAction {
|
|
|
258
220
|
const picks = await computePicks(snippetService, userDataProfileService, languageService, labelService);
|
|
259
221
|
const existing = picks.existing;
|
|
260
222
|
const globalSnippetPicks = [{
|
|
261
|
-
scope: ( localizeWithPath(
|
|
262
|
-
|
|
263
|
-
'new.global_scope',
|
|
264
|
-
'global'
|
|
265
|
-
)),
|
|
266
|
-
label: ( localizeWithPath(
|
|
267
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
268
|
-
'new.global',
|
|
269
|
-
"New Global Snippets file..."
|
|
270
|
-
)),
|
|
223
|
+
scope: ( localizeWithPath(_moduleId, 10, 'global')),
|
|
224
|
+
label: ( localizeWithPath(_moduleId, 11, "New Global Snippets file...")),
|
|
271
225
|
uri: userDataProfileService.currentProfile.snippetsHome
|
|
272
226
|
}];
|
|
273
227
|
const workspaceSnippetPicks = [];
|
|
274
228
|
for (const folder of workspaceService.getWorkspace().folders) {
|
|
275
229
|
workspaceSnippetPicks.push({
|
|
276
|
-
scope: ( localizeWithPath(
|
|
277
|
-
|
|
278
|
-
'new.workspace_scope',
|
|
279
|
-
"{0} workspace",
|
|
280
|
-
folder.name
|
|
281
|
-
)),
|
|
282
|
-
label: ( localizeWithPath(
|
|
283
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
284
|
-
'new.folder',
|
|
285
|
-
"New Snippets file for '{0}'...",
|
|
286
|
-
folder.name
|
|
287
|
-
)),
|
|
230
|
+
scope: ( localizeWithPath(_moduleId, 12, "{0} workspace", folder.name)),
|
|
231
|
+
label: ( localizeWithPath(_moduleId, 13, "New Snippets file for '{0}'...", folder.name)),
|
|
288
232
|
uri: folder.toResource('.vscode')
|
|
289
233
|
});
|
|
290
234
|
}
|
|
291
235
|
if (existing.length > 0) {
|
|
292
|
-
existing.unshift({ type: 'separator', label: ( localizeWithPath(
|
|
293
|
-
|
|
294
|
-
'group.global',
|
|
295
|
-
"Existing Snippets"
|
|
296
|
-
)) });
|
|
297
|
-
existing.push({ type: 'separator', label: ( localizeWithPath(
|
|
298
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
299
|
-
'new.global.sep',
|
|
300
|
-
"New Snippets"
|
|
301
|
-
)) });
|
|
236
|
+
existing.unshift({ type: 'separator', label: ( localizeWithPath(_moduleId, 14, "Existing Snippets")) });
|
|
237
|
+
existing.push({ type: 'separator', label: ( localizeWithPath(_moduleId, 15, "New Snippets")) });
|
|
302
238
|
}
|
|
303
239
|
else {
|
|
304
|
-
existing.push({ type: 'separator', label: ( localizeWithPath(
|
|
305
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
306
|
-
'new.global.sep',
|
|
307
|
-
"New Snippets"
|
|
308
|
-
)) });
|
|
240
|
+
existing.push({ type: 'separator', label: ( localizeWithPath(_moduleId, 15, "New Snippets")) });
|
|
309
241
|
}
|
|
310
242
|
const pick = await quickInputService.pick([].concat(existing, globalSnippetPicks, workspaceSnippetPicks, picks.future), {
|
|
311
|
-
placeHolder: ( localizeWithPath(
|
|
312
|
-
'vs/workbench/contrib/snippets/browser/commands/configureSnippets',
|
|
313
|
-
'openSnippet.pickLanguage',
|
|
314
|
-
"Select Snippets File or Create Snippets"
|
|
315
|
-
)),
|
|
243
|
+
placeHolder: ( localizeWithPath(_moduleId, 16, "Select Snippets File or Create Snippets")),
|
|
316
244
|
matchOnDescription: true
|
|
317
245
|
});
|
|
318
246
|
if (globalSnippetPicks.indexOf(pick) >= 0) {
|
|
@@ -9,6 +9,7 @@ import { pickSnippet } from '../snippetPicker.js';
|
|
|
9
9
|
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
10
10
|
import { Snippet } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsFile';
|
|
11
11
|
|
|
12
|
+
const _moduleId = "vs/workbench/contrib/snippets/browser/commands/insertSnippet";
|
|
12
13
|
class Args {
|
|
13
14
|
static fromUser(arg) {
|
|
14
15
|
if (!arg || typeof arg !== 'object') {
|
|
@@ -24,9 +25,11 @@ class Args {
|
|
|
24
25
|
if (typeof langId !== 'string') {
|
|
25
26
|
langId = undefined;
|
|
26
27
|
}
|
|
27
|
-
return (
|
|
28
|
+
return (
|
|
29
|
+
(new Args(snippet, name, langId))
|
|
30
|
+
);
|
|
28
31
|
}
|
|
29
|
-
static { this._empty = ( new Args(undefined, undefined, undefined)); }
|
|
32
|
+
static { this._empty = ( (new Args(undefined, undefined, undefined))); }
|
|
30
33
|
constructor(snippet, name, langId) {
|
|
31
34
|
this.snippet = snippet;
|
|
32
35
|
this.name = name;
|
|
@@ -37,11 +40,7 @@ class InsertSnippetAction extends SnippetEditorAction {
|
|
|
37
40
|
constructor() {
|
|
38
41
|
super({
|
|
39
42
|
id: 'editor.action.insertSnippet',
|
|
40
|
-
title: ( localize2WithPath(
|
|
41
|
-
'vs/workbench/contrib/snippets/browser/commands/insertSnippet',
|
|
42
|
-
'snippet.suggestions.label',
|
|
43
|
-
"Insert Snippet"
|
|
44
|
-
)),
|
|
43
|
+
title: ( localize2WithPath(_moduleId, 0, "Insert Snippet")),
|
|
45
44
|
f1: true,
|
|
46
45
|
precondition: EditorContextKeys.writable,
|
|
47
46
|
metadata: {
|
|
@@ -74,11 +73,11 @@ class InsertSnippetAction extends SnippetEditorAction {
|
|
|
74
73
|
}
|
|
75
74
|
const clipboardService = accessor.get(IClipboardService);
|
|
76
75
|
const instaService = accessor.get(IInstantiationService);
|
|
77
|
-
const snippet = await ( new Promise((resolve, reject) => {
|
|
76
|
+
const snippet = await ( (new Promise((resolve, reject) => {
|
|
78
77
|
const { lineNumber, column } = editor.getPosition();
|
|
79
78
|
const { snippet, name, langId } = Args.fromUser(arg);
|
|
80
79
|
if (snippet) {
|
|
81
|
-
return resolve(( new Snippet(
|
|
80
|
+
return resolve(( (new Snippet(
|
|
82
81
|
false,
|
|
83
82
|
[],
|
|
84
83
|
'',
|
|
@@ -88,7 +87,7 @@ class InsertSnippetAction extends SnippetEditorAction {
|
|
|
88
87
|
'',
|
|
89
88
|
1 ,
|
|
90
89
|
`random/${Math.random()}`
|
|
91
|
-
)));
|
|
90
|
+
))));
|
|
92
91
|
}
|
|
93
92
|
let languageId;
|
|
94
93
|
if (langId) {
|
|
@@ -112,7 +111,7 @@ class InsertSnippetAction extends SnippetEditorAction {
|
|
|
112
111
|
else {
|
|
113
112
|
resolve(instaService.invokeFunction(pickSnippet, languageId));
|
|
114
113
|
}
|
|
115
|
-
}));
|
|
114
|
+
})));
|
|
116
115
|
if (!snippet) {
|
|
117
116
|
return;
|
|
118
117
|
}
|
|
@@ -8,6 +8,7 @@ import { pickSnippet } from '../snippetPicker.js';
|
|
|
8
8
|
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
9
9
|
import { localize2WithPath } from 'vscode/vscode/vs/nls';
|
|
10
10
|
|
|
11
|
+
const _moduleId = "vs/workbench/contrib/snippets/browser/commands/surroundWithSnippet";
|
|
11
12
|
async function getSurroundableSnippets(snippetsService, model, position, includeDisabledSnippets) {
|
|
12
13
|
const { lineNumber, column } = position;
|
|
13
14
|
model.tokenization.tokenizeIfCheap(lineNumber);
|
|
@@ -18,16 +19,12 @@ async function getSurroundableSnippets(snippetsService, model, position, include
|
|
|
18
19
|
class SurroundWithSnippetEditorAction extends SnippetEditorAction {
|
|
19
20
|
static { this.options = {
|
|
20
21
|
id: 'editor.action.surroundWithSnippet',
|
|
21
|
-
title: ( localize2WithPath(
|
|
22
|
-
'vs/workbench/contrib/snippets/browser/commands/surroundWithSnippet',
|
|
23
|
-
'label',
|
|
24
|
-
"Surround with Snippet..."
|
|
25
|
-
))
|
|
22
|
+
title: ( localize2WithPath(_moduleId, 0, "Surround with Snippet..."))
|
|
26
23
|
}; }
|
|
27
24
|
constructor() {
|
|
28
25
|
super({
|
|
29
26
|
...SurroundWithSnippetEditorAction.options,
|
|
30
|
-
precondition: ( ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasNonEmptySelection)),
|
|
27
|
+
precondition: ( (ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasNonEmptySelection))),
|
|
31
28
|
f1: true,
|
|
32
29
|
});
|
|
33
30
|
}
|
|
@@ -11,16 +11,13 @@ import { SurroundWithSnippetEditorAction, getSurroundableSnippets } from './comm
|
|
|
11
11
|
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
12
12
|
|
|
13
13
|
var SurroundWithSnippetCodeActionProvider_1, FileTemplateCodeActionProvider_1;
|
|
14
|
+
const _moduleId = "vs/workbench/contrib/snippets/browser/snippetCodeActionProvider";
|
|
14
15
|
let SurroundWithSnippetCodeActionProvider = class SurroundWithSnippetCodeActionProvider {
|
|
15
16
|
static { SurroundWithSnippetCodeActionProvider_1 = this; }
|
|
16
17
|
static { this._MAX_CODE_ACTIONS = 4; }
|
|
17
18
|
static { this._overflowCommandCodeAction = {
|
|
18
19
|
kind: CodeActionKind.SurroundWith.value,
|
|
19
|
-
title: ( localizeWithPath(
|
|
20
|
-
'vs/workbench/contrib/snippets/browser/snippetCodeActionProvider',
|
|
21
|
-
'more',
|
|
22
|
-
"More..."
|
|
23
|
-
)),
|
|
20
|
+
title: ( localizeWithPath(_moduleId, 0, "More...")),
|
|
24
21
|
command: {
|
|
25
22
|
id: SurroundWithSnippetEditorAction.options.id,
|
|
26
23
|
title: SurroundWithSnippetEditorAction.options.title.value,
|
|
@@ -45,12 +42,7 @@ let SurroundWithSnippetCodeActionProvider = class SurroundWithSnippetCodeActionP
|
|
|
45
42
|
break;
|
|
46
43
|
}
|
|
47
44
|
actions.push({
|
|
48
|
-
title: ( localizeWithPath(
|
|
49
|
-
'vs/workbench/contrib/snippets/browser/snippetCodeActionProvider',
|
|
50
|
-
'codeAction',
|
|
51
|
-
"{0}",
|
|
52
|
-
snippet.name
|
|
53
|
-
)),
|
|
45
|
+
title: ( localizeWithPath(_moduleId, 1, "{0}", snippet.name)),
|
|
54
46
|
kind: CodeActionKind.SurroundWith.value,
|
|
55
47
|
edit: asWorkspaceEdit(model, range, snippet)
|
|
56
48
|
});
|
|
@@ -61,18 +53,14 @@ let SurroundWithSnippetCodeActionProvider = class SurroundWithSnippetCodeActionP
|
|
|
61
53
|
};
|
|
62
54
|
}
|
|
63
55
|
};
|
|
64
|
-
SurroundWithSnippetCodeActionProvider = SurroundWithSnippetCodeActionProvider_1 = ( __decorate([
|
|
65
|
-
( __param(0, ISnippetsService))
|
|
66
|
-
], SurroundWithSnippetCodeActionProvider));
|
|
56
|
+
SurroundWithSnippetCodeActionProvider = SurroundWithSnippetCodeActionProvider_1 = ( (__decorate([
|
|
57
|
+
( (__param(0, ISnippetsService)))
|
|
58
|
+
], SurroundWithSnippetCodeActionProvider)));
|
|
67
59
|
let FileTemplateCodeActionProvider = class FileTemplateCodeActionProvider {
|
|
68
60
|
static { FileTemplateCodeActionProvider_1 = this; }
|
|
69
61
|
static { this._MAX_CODE_ACTIONS = 4; }
|
|
70
62
|
static { this._overflowCommandCodeAction = {
|
|
71
|
-
title: ( localizeWithPath(
|
|
72
|
-
'vs/workbench/contrib/snippets/browser/snippetCodeActionProvider',
|
|
73
|
-
'overflow.start.title',
|
|
74
|
-
'Start with Snippet'
|
|
75
|
-
)),
|
|
63
|
+
title: ( localizeWithPath(_moduleId, 2, 'Start with Snippet')),
|
|
76
64
|
kind: CodeActionKind.SurroundWith.value,
|
|
77
65
|
command: {
|
|
78
66
|
id: ApplyFileSnippetAction.Id,
|
|
@@ -95,12 +83,7 @@ let FileTemplateCodeActionProvider = class FileTemplateCodeActionProvider {
|
|
|
95
83
|
break;
|
|
96
84
|
}
|
|
97
85
|
actions.push({
|
|
98
|
-
title: ( localizeWithPath(
|
|
99
|
-
'vs/workbench/contrib/snippets/browser/snippetCodeActionProvider',
|
|
100
|
-
'title',
|
|
101
|
-
'Start with: {0}',
|
|
102
|
-
snippet.name
|
|
103
|
-
)),
|
|
86
|
+
title: ( localizeWithPath(_moduleId, 3, 'Start with: {0}', snippet.name)),
|
|
104
87
|
kind: CodeActionKind.SurroundWith.value,
|
|
105
88
|
edit: asWorkspaceEdit(model, model.getFullModelRange(), snippet)
|
|
106
89
|
});
|
|
@@ -111,9 +94,9 @@ let FileTemplateCodeActionProvider = class FileTemplateCodeActionProvider {
|
|
|
111
94
|
};
|
|
112
95
|
}
|
|
113
96
|
};
|
|
114
|
-
FileTemplateCodeActionProvider = FileTemplateCodeActionProvider_1 = ( __decorate([
|
|
115
|
-
( __param(0, ISnippetsService))
|
|
116
|
-
], FileTemplateCodeActionProvider));
|
|
97
|
+
FileTemplateCodeActionProvider = FileTemplateCodeActionProvider_1 = ( (__decorate([
|
|
98
|
+
( (__param(0, ISnippetsService)))
|
|
99
|
+
], FileTemplateCodeActionProvider)));
|
|
117
100
|
function asWorkspaceEdit(model, range, snippet) {
|
|
118
101
|
return {
|
|
119
102
|
edits: [{
|
|
@@ -129,9 +112,9 @@ function asWorkspaceEdit(model, range, snippet) {
|
|
|
129
112
|
}
|
|
130
113
|
let SnippetCodeActions = class SnippetCodeActions {
|
|
131
114
|
constructor(instantiationService, languageFeaturesService, configService) {
|
|
132
|
-
this._store = ( new DisposableStore());
|
|
115
|
+
this._store = ( (new DisposableStore()));
|
|
133
116
|
const setting = 'editor.snippets.codeActions.enabled';
|
|
134
|
-
const sessionStore = ( new DisposableStore());
|
|
117
|
+
const sessionStore = ( (new DisposableStore()));
|
|
135
118
|
const update = () => {
|
|
136
119
|
sessionStore.clear();
|
|
137
120
|
if (configService.getValue(setting)) {
|
|
@@ -147,10 +130,10 @@ let SnippetCodeActions = class SnippetCodeActions {
|
|
|
147
130
|
this._store.dispose();
|
|
148
131
|
}
|
|
149
132
|
};
|
|
150
|
-
SnippetCodeActions = ( __decorate([
|
|
151
|
-
( __param(0, IInstantiationService)),
|
|
152
|
-
( __param(1, ILanguageFeaturesService)),
|
|
153
|
-
( __param(2, IConfigurationService))
|
|
154
|
-
], SnippetCodeActions));
|
|
133
|
+
SnippetCodeActions = ( (__decorate([
|
|
134
|
+
( (__param(0, IInstantiationService))),
|
|
135
|
+
( (__param(1, ILanguageFeaturesService))),
|
|
136
|
+
( (__param(2, IConfigurationService)))
|
|
137
|
+
], SnippetCodeActions)));
|
|
155
138
|
|
|
156
139
|
export { SnippetCodeActions };
|
|
@@ -5,6 +5,7 @@ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
|
5
5
|
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
6
6
|
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
7
7
|
|
|
8
|
+
const _moduleId = "vs/workbench/contrib/snippets/browser/snippetPicker";
|
|
8
9
|
async function pickSnippet(accessor, languageIdOrSnippets) {
|
|
9
10
|
const snippetService = accessor.get(ISnippetsService);
|
|
10
11
|
const quickInputService = accessor.get(IQuickInputService);
|
|
@@ -29,21 +30,13 @@ async function pickSnippet(accessor, languageIdOrSnippets) {
|
|
|
29
30
|
let label = '';
|
|
30
31
|
switch (snippet.snippetSource) {
|
|
31
32
|
case 1 :
|
|
32
|
-
label = ( localizeWithPath(
|
|
33
|
-
'vs/workbench/contrib/snippets/browser/snippetPicker',
|
|
34
|
-
'sep.userSnippet',
|
|
35
|
-
"User Snippets"
|
|
36
|
-
));
|
|
33
|
+
label = ( localizeWithPath(_moduleId, 0, "User Snippets"));
|
|
37
34
|
break;
|
|
38
35
|
case 3 :
|
|
39
36
|
label = snippet.source;
|
|
40
37
|
break;
|
|
41
38
|
case 2 :
|
|
42
|
-
label = ( localizeWithPath(
|
|
43
|
-
'vs/workbench/contrib/snippets/browser/snippetPicker',
|
|
44
|
-
'sep.workspaceSnippet',
|
|
45
|
-
"Workspace Snippets"
|
|
46
|
-
));
|
|
39
|
+
label = ( localizeWithPath(_moduleId, 1, "Workspace Snippets"));
|
|
47
40
|
break;
|
|
48
41
|
}
|
|
49
42
|
result.push({ type: 'separator', label });
|
|
@@ -53,26 +46,14 @@ async function pickSnippet(accessor, languageIdOrSnippets) {
|
|
|
53
46
|
if (isEnabled) {
|
|
54
47
|
pick.buttons = [{
|
|
55
48
|
iconClass: ThemeIcon.asClassName(Codicon.eyeClosed),
|
|
56
|
-
tooltip: ( localizeWithPath(
|
|
57
|
-
'vs/workbench/contrib/snippets/browser/snippetPicker',
|
|
58
|
-
'disableSnippet',
|
|
59
|
-
'Hide from IntelliSense'
|
|
60
|
-
))
|
|
49
|
+
tooltip: ( localizeWithPath(_moduleId, 2, 'Hide from IntelliSense'))
|
|
61
50
|
}];
|
|
62
51
|
}
|
|
63
52
|
else {
|
|
64
|
-
pick.description = ( localizeWithPath(
|
|
65
|
-
'vs/workbench/contrib/snippets/browser/snippetPicker',
|
|
66
|
-
'isDisabled',
|
|
67
|
-
"(hidden from IntelliSense)"
|
|
68
|
-
));
|
|
53
|
+
pick.description = ( localizeWithPath(_moduleId, 3, "(hidden from IntelliSense)"));
|
|
69
54
|
pick.buttons = [{
|
|
70
55
|
iconClass: ThemeIcon.asClassName(Codicon.eye),
|
|
71
|
-
tooltip: ( localizeWithPath(
|
|
72
|
-
'vs/workbench/contrib/snippets/browser/snippetPicker',
|
|
73
|
-
'enable.snippet',
|
|
74
|
-
'Show in IntelliSense'
|
|
75
|
-
))
|
|
56
|
+
tooltip: ( localizeWithPath(_moduleId, 4, 'Show in IntelliSense'))
|
|
76
57
|
}];
|
|
77
58
|
}
|
|
78
59
|
}
|
|
@@ -82,11 +63,7 @@ async function pickSnippet(accessor, languageIdOrSnippets) {
|
|
|
82
63
|
return result;
|
|
83
64
|
};
|
|
84
65
|
const picker = quickInputService.createQuickPick();
|
|
85
|
-
picker.placeholder = ( localizeWithPath(
|
|
86
|
-
'vs/workbench/contrib/snippets/browser/snippetPicker',
|
|
87
|
-
'pick.placeholder',
|
|
88
|
-
"Select a snippet"
|
|
89
|
-
));
|
|
66
|
+
picker.placeholder = ( localizeWithPath(_moduleId, 5, "Select a snippet"));
|
|
90
67
|
picker.matchOnDetail = true;
|
|
91
68
|
picker.ignoreFocusOut = false;
|
|
92
69
|
picker.keepScrollPosition = true;
|
|
@@ -97,11 +74,7 @@ async function pickSnippet(accessor, languageIdOrSnippets) {
|
|
|
97
74
|
});
|
|
98
75
|
picker.items = makeSnippetPicks();
|
|
99
76
|
if (!picker.items.length) {
|
|
100
|
-
picker.validationMessage = ( localizeWithPath(
|
|
101
|
-
'vs/workbench/contrib/snippets/browser/snippetPicker',
|
|
102
|
-
'pick.noSnippetAvailable',
|
|
103
|
-
"No snippet available"
|
|
104
|
-
));
|
|
77
|
+
picker.validationMessage = ( localizeWithPath(_moduleId, 6, "No snippet available"));
|
|
105
78
|
}
|
|
106
79
|
picker.show();
|
|
107
80
|
await Promise.race([Event.toPromise(picker.onDidAccept), Event.toPromise(picker.onDidHide)]);
|
|
@@ -15,22 +15,23 @@ import { Extensions as Extensions$1 } from 'vscode/vscode/vs/platform/configurat
|
|
|
15
15
|
import 'vscode/vscode/vs/workbench/contrib/snippets/browser/tabCompletion';
|
|
16
16
|
import { editorConfigurationBaseNode } from 'vscode/vscode/vs/editor/common/config/editorConfigurationSchema';
|
|
17
17
|
|
|
18
|
+
const _moduleId = "vs/workbench/contrib/snippets/browser/snippets.contribution";
|
|
18
19
|
registerAction2(InsertSnippetAction);
|
|
19
20
|
CommandsRegistry.registerCommandAlias('editor.action.showSnippets', 'editor.action.insertSnippet');
|
|
20
21
|
registerAction2(SurroundWithSnippetEditorAction);
|
|
21
22
|
registerAction2(ApplyFileSnippetAction);
|
|
22
23
|
registerAction2(ConfigureSnippetsAction);
|
|
23
|
-
const workbenchContribRegistry = ( Registry.as(Extensions.Workbench));
|
|
24
|
+
const workbenchContribRegistry = ( (Registry.as(Extensions.Workbench)));
|
|
24
25
|
workbenchContribRegistry.registerWorkbenchContribution(SnippetCodeActions, 3 );
|
|
25
|
-
( Registry
|
|
26
|
-
.as(Extensions$1.Configuration))
|
|
26
|
+
( (Registry
|
|
27
|
+
.as(Extensions$1.Configuration)))
|
|
27
28
|
.registerConfiguration({
|
|
28
29
|
...editorConfigurationBaseNode,
|
|
29
30
|
'properties': {
|
|
30
31
|
'editor.snippets.codeActions.enabled': {
|
|
31
32
|
'description': ( localizeWithPath(
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
_moduleId,
|
|
34
|
+
0,
|
|
34
35
|
'Controls if surround-with-snippets or file template snippets show as Code Actions.'
|
|
35
36
|
)),
|
|
36
37
|
'type': 'boolean',
|
|
@@ -42,24 +43,20 @@ const languageScopeSchemaId = 'vscode://schemas/snippets';
|
|
|
42
43
|
const snippetSchemaProperties = {
|
|
43
44
|
prefix: {
|
|
44
45
|
description: ( localizeWithPath(
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
_moduleId,
|
|
47
|
+
1,
|
|
47
48
|
'The prefix to use when selecting the snippet in intellisense'
|
|
48
49
|
)),
|
|
49
50
|
type: ['string', 'array']
|
|
50
51
|
},
|
|
51
52
|
isFileTemplate: {
|
|
52
|
-
description: ( localizeWithPath(
|
|
53
|
-
'vs/workbench/contrib/snippets/browser/snippets.contribution',
|
|
54
|
-
'snippetSchema.json.isFileTemplate',
|
|
55
|
-
'The snippet is meant to populate or replace a whole file'
|
|
56
|
-
)),
|
|
53
|
+
description: ( localizeWithPath(_moduleId, 2, 'The snippet is meant to populate or replace a whole file')),
|
|
57
54
|
type: 'boolean'
|
|
58
55
|
},
|
|
59
56
|
body: {
|
|
60
57
|
markdownDescription: ( localizeWithPath(
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
_moduleId,
|
|
59
|
+
3,
|
|
63
60
|
'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`.'
|
|
64
61
|
)),
|
|
65
62
|
type: ['string', 'array'],
|
|
@@ -68,11 +65,7 @@ const snippetSchemaProperties = {
|
|
|
68
65
|
}
|
|
69
66
|
},
|
|
70
67
|
description: {
|
|
71
|
-
description: ( localizeWithPath(
|
|
72
|
-
'vs/workbench/contrib/snippets/browser/snippets.contribution',
|
|
73
|
-
'snippetSchema.json.description',
|
|
74
|
-
'The snippet description.'
|
|
75
|
-
)),
|
|
68
|
+
description: ( localizeWithPath(_moduleId, 4, 'The snippet description.')),
|
|
76
69
|
type: ['string', 'array']
|
|
77
70
|
}
|
|
78
71
|
};
|
|
@@ -81,19 +74,11 @@ const languageScopeSchema = {
|
|
|
81
74
|
allowComments: true,
|
|
82
75
|
allowTrailingCommas: true,
|
|
83
76
|
defaultSnippets: [{
|
|
84
|
-
label: ( localizeWithPath(
|
|
85
|
-
'vs/workbench/contrib/snippets/browser/snippets.contribution',
|
|
86
|
-
'snippetSchema.json.default',
|
|
87
|
-
"Empty snippet"
|
|
88
|
-
)),
|
|
77
|
+
label: ( localizeWithPath(_moduleId, 5, "Empty snippet")),
|
|
89
78
|
body: { '${1:snippetName}': { 'prefix': '${2:prefix}', 'body': '${3:snippet}', 'description': '${4:description}' } }
|
|
90
79
|
}],
|
|
91
80
|
type: 'object',
|
|
92
|
-
description: ( localizeWithPath(
|
|
93
|
-
'vs/workbench/contrib/snippets/browser/snippets.contribution',
|
|
94
|
-
'snippetSchema.json',
|
|
95
|
-
'User snippet configuration'
|
|
96
|
-
)),
|
|
81
|
+
description: ( localizeWithPath(_moduleId, 6, 'User snippet configuration')),
|
|
97
82
|
additionalProperties: {
|
|
98
83
|
type: 'object',
|
|
99
84
|
required: ['body'],
|
|
@@ -107,19 +92,11 @@ const globalSchema = {
|
|
|
107
92
|
allowComments: true,
|
|
108
93
|
allowTrailingCommas: true,
|
|
109
94
|
defaultSnippets: [{
|
|
110
|
-
label: ( localizeWithPath(
|
|
111
|
-
'vs/workbench/contrib/snippets/browser/snippets.contribution',
|
|
112
|
-
'snippetSchema.json.default',
|
|
113
|
-
"Empty snippet"
|
|
114
|
-
)),
|
|
95
|
+
label: ( localizeWithPath(_moduleId, 5, "Empty snippet")),
|
|
115
96
|
body: { '${1:snippetName}': { 'scope': '${2:scope}', 'prefix': '${3:prefix}', 'body': '${4:snippet}', 'description': '${5:description}' } }
|
|
116
97
|
}],
|
|
117
98
|
type: 'object',
|
|
118
|
-
description: ( localizeWithPath(
|
|
119
|
-
'vs/workbench/contrib/snippets/browser/snippets.contribution',
|
|
120
|
-
'snippetSchema.json',
|
|
121
|
-
'User snippet configuration'
|
|
122
|
-
)),
|
|
99
|
+
description: ( localizeWithPath(_moduleId, 6, 'User snippet configuration')),
|
|
123
100
|
additionalProperties: {
|
|
124
101
|
type: 'object',
|
|
125
102
|
required: ['body'],
|
|
@@ -127,8 +104,8 @@ const globalSchema = {
|
|
|
127
104
|
...snippetSchemaProperties,
|
|
128
105
|
scope: {
|
|
129
106
|
description: ( localizeWithPath(
|
|
130
|
-
|
|
131
|
-
|
|
107
|
+
_moduleId,
|
|
108
|
+
7,
|
|
132
109
|
"A list of language names to which this snippet applies, e.g. 'typescript,javascript'."
|
|
133
110
|
)),
|
|
134
111
|
type: 'string'
|
|
@@ -137,6 +114,6 @@ const globalSchema = {
|
|
|
137
114
|
additionalProperties: false
|
|
138
115
|
}
|
|
139
116
|
};
|
|
140
|
-
const reg = ( Registry.as(Extensions$2.JSONContribution));
|
|
117
|
+
const reg = ( (Registry.as(Extensions$2.JSONContribution)));
|
|
141
118
|
reg.registerSchema(languageScopeSchemaId, languageScopeSchema);
|
|
142
119
|
reg.registerSchema(globalSchemaId, globalSchema);
|