@codingame/monaco-vscode-snippets-service-override 11.1.1 → 12.0.0
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/index.d.ts +7 -2
- package/index.js +27 -1
- package/package.json +16 -8
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/configureSnippets.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/configureSnippets.js +28 -26
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/insertSnippet.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/insertSnippet.js +11 -12
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/surroundWithSnippet.d.ts +16 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/surroundWithSnippet.js +4 -3
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetCodeActionProvider.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetCodeActionProvider.js +20 -19
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetPicker.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippetPicker.js +14 -12
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippets.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/snippets.contribution.js +19 -16
- package/snippets.js +0 -25
package/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type IEditorOverrideServices } from "vscode/vscode/vs/editor/standalone/browser/standaloneServices";
|
|
2
|
+
interface ISnippetsExtensionPoint {
|
|
3
|
+
language: string;
|
|
4
|
+
path: string;
|
|
5
|
+
}
|
|
6
|
+
export default function getServiceOverride(): IEditorOverrideServices;
|
|
7
|
+
export type { ISnippetsExtensionPoint };
|
package/index.js
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { StandaloneServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
3
|
+
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
|
+
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
5
|
+
import { SnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsService';
|
|
6
|
+
import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
7
|
+
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
8
|
+
import getServiceOverride$1 from '@codingame/monaco-vscode-files-service-override';
|
|
9
|
+
import { registerServiceInitializeParticipant } from 'vscode/lifecycle';
|
|
10
|
+
import './vscode/src/vs/workbench/contrib/snippets/browser/snippets.contribution.js';
|
|
11
|
+
|
|
12
|
+
registerServiceInitializeParticipant(async (accessor) => {
|
|
13
|
+
void accessor
|
|
14
|
+
.get(ILifecycleService)
|
|
15
|
+
.when(LifecyclePhase.Ready)
|
|
16
|
+
.then(() => {
|
|
17
|
+
StandaloneServices.get(ISnippetsService);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
function getServiceOverride() {
|
|
21
|
+
return {
|
|
22
|
+
...getServiceOverride$1(),
|
|
23
|
+
[ISnippetsService.toString()]: new SyncDescriptor(SnippetsService, [], true)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { getServiceOverride as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-snippets-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "VSCode public API plugged on the monaco editor - snippets service-override",
|
|
4
6
|
"keywords": [],
|
|
5
7
|
"author": {
|
|
6
8
|
"name": "CodinGame",
|
|
@@ -12,8 +14,13 @@
|
|
|
12
14
|
"url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
|
|
13
15
|
},
|
|
14
16
|
"type": "module",
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common": "12.0.0",
|
|
19
|
+
"@codingame/monaco-vscode-files-service-override": "12.0.0",
|
|
20
|
+
"vscode": "npm:@codingame/monaco-vscode-api@12.0.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {},
|
|
23
|
+
"peerDependenciesMeta": {},
|
|
17
24
|
"main": "index.js",
|
|
18
25
|
"module": "index.js",
|
|
19
26
|
"types": "index.d.ts",
|
|
@@ -22,11 +29,12 @@
|
|
|
22
29
|
"default": "./index.js"
|
|
23
30
|
},
|
|
24
31
|
"./vscode/*": {
|
|
25
|
-
"default": "./vscode/src/*.js"
|
|
32
|
+
"default": "./vscode/src/*.js",
|
|
33
|
+
"types": "./vscode/src/*.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./*": {
|
|
36
|
+
"default": "./*.js",
|
|
37
|
+
"types": "./*.d.ts"
|
|
26
38
|
}
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@11.1.1",
|
|
30
|
-
"@codingame/monaco-vscode-files-service-override": "11.1.1"
|
|
31
39
|
}
|
|
32
40
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ServicesAccessor } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
|
|
2
|
+
import { SnippetsAction } from "@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions";
|
|
3
|
+
export declare class ConfigureSnippetsAction extends SnippetsAction {
|
|
4
|
+
constructor();
|
|
5
|
+
run(accessor: ServicesAccessor): Promise<any>;
|
|
6
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import { isValidBasename } from 'vscode/vscode/vs/base/common/extpath';
|
|
2
3
|
import { extname } from 'vscode/vscode/vs/base/common/path';
|
|
3
4
|
import { basename, joinPath } from 'vscode/vscode/vs/base/common/resources';
|
|
@@ -11,30 +12,31 @@ import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label.serv
|
|
|
11
12
|
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
|
|
12
13
|
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
13
14
|
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
14
|
-
import { SnippetsAction } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions';
|
|
15
|
+
import { SnippetsAction } from '@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions';
|
|
15
16
|
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
17
|
+
import { SnippetSource } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsFile';
|
|
16
18
|
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
|
|
17
19
|
import { IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
|
|
18
20
|
|
|
19
21
|
var ISnippetPick;
|
|
20
|
-
( (
|
|
22
|
+
(function (ISnippetPick) {
|
|
21
23
|
function is(thing) {
|
|
22
24
|
return !!thing && URI.isUri(thing.filepath);
|
|
23
25
|
}
|
|
24
26
|
ISnippetPick.is = is;
|
|
25
|
-
})(ISnippetPick || (ISnippetPick = {}))
|
|
27
|
+
})(ISnippetPick || (ISnippetPick = {}));
|
|
26
28
|
async function computePicks(snippetService, userDataProfileService, languageService, labelService) {
|
|
27
29
|
const existing = [];
|
|
28
30
|
const future = [];
|
|
29
|
-
const seen = (
|
|
30
|
-
const added = (
|
|
31
|
+
const seen = ( new Set());
|
|
32
|
+
const added = ( new Map());
|
|
31
33
|
for (const file of await snippetService.getSnippetFiles()) {
|
|
32
|
-
if (file.source ===
|
|
34
|
+
if (file.source === SnippetSource.Extension) {
|
|
33
35
|
continue;
|
|
34
36
|
}
|
|
35
37
|
if (file.isGlobalSnippets) {
|
|
36
38
|
await file.load();
|
|
37
|
-
const names = (
|
|
39
|
+
const names = ( new Set());
|
|
38
40
|
let source;
|
|
39
41
|
outer: for (const snippet of file.data) {
|
|
40
42
|
if (!source) {
|
|
@@ -57,15 +59,15 @@ async function computePicks(snippetService, userDataProfileService, languageServ
|
|
|
57
59
|
label: basename(file.location),
|
|
58
60
|
filepath: file.location,
|
|
59
61
|
description: names.size === 0
|
|
60
|
-
? ( localize(
|
|
61
|
-
: ( localize(
|
|
62
|
+
? ( localize(8857, "(global)"))
|
|
63
|
+
: ( localize(8858, "({0})", [...names].join(', ')))
|
|
62
64
|
};
|
|
63
65
|
existing.push(snippet);
|
|
64
66
|
if (!source) {
|
|
65
67
|
continue;
|
|
66
68
|
}
|
|
67
69
|
const detail = ( localize(
|
|
68
|
-
|
|
70
|
+
8859,
|
|
69
71
|
"({0}) {1}",
|
|
70
72
|
source,
|
|
71
73
|
labelService.getUriLabel(file.location, { relative: true })
|
|
@@ -90,7 +92,7 @@ async function computePicks(snippetService, userDataProfileService, languageServ
|
|
|
90
92
|
const dir = userDataProfileService.currentProfile.snippetsHome;
|
|
91
93
|
for (const languageId of languageService.getRegisteredLanguageIds()) {
|
|
92
94
|
const label = languageService.getLanguageName(languageId);
|
|
93
|
-
if (label && !(
|
|
95
|
+
if (label && !( seen.has(languageId))) {
|
|
94
96
|
future.push({
|
|
95
97
|
label: languageId,
|
|
96
98
|
description: `(${label})`,
|
|
@@ -127,16 +129,16 @@ async function createSnippetFile(scope, defaultPath, quickInputService, fileServ
|
|
|
127
129
|
}
|
|
128
130
|
await fileService.createFolder(defaultPath);
|
|
129
131
|
const input = await quickInputService.input({
|
|
130
|
-
placeHolder: ( localize(
|
|
132
|
+
placeHolder: ( localize(8860, "Type snippet file name")),
|
|
131
133
|
async validateInput(input) {
|
|
132
134
|
if (!input) {
|
|
133
|
-
return
|
|
135
|
+
return localize(8861, "Invalid file name");
|
|
134
136
|
}
|
|
135
137
|
if (!isValidBasename(input)) {
|
|
136
|
-
return
|
|
138
|
+
return localize(8862, "'{0}' is not a valid file name", input);
|
|
137
139
|
}
|
|
138
140
|
if (await fileService.exists(createSnippetUri(input))) {
|
|
139
|
-
return
|
|
141
|
+
return localize(8863, "'{0}' already exists", input);
|
|
140
142
|
}
|
|
141
143
|
return undefined;
|
|
142
144
|
}
|
|
@@ -195,10 +197,10 @@ class ConfigureSnippetsAction extends SnippetsAction {
|
|
|
195
197
|
constructor() {
|
|
196
198
|
super({
|
|
197
199
|
id: 'workbench.action.openSnippets',
|
|
198
|
-
title: ( localize2(
|
|
200
|
+
title: ( localize2(8864, "Configure Snippets")),
|
|
199
201
|
shortTitle: {
|
|
200
|
-
...( localize2(
|
|
201
|
-
mnemonicTitle: ( localize(
|
|
202
|
+
...( localize2(8865, "Snippets")),
|
|
203
|
+
mnemonicTitle: ( localize(8866, "&&Snippets")),
|
|
202
204
|
},
|
|
203
205
|
f1: true,
|
|
204
206
|
menu: [
|
|
@@ -220,27 +222,27 @@ class ConfigureSnippetsAction extends SnippetsAction {
|
|
|
220
222
|
const picks = await computePicks(snippetService, userDataProfileService, languageService, labelService);
|
|
221
223
|
const existing = picks.existing;
|
|
222
224
|
const globalSnippetPicks = [{
|
|
223
|
-
scope: ( localize(
|
|
224
|
-
label: ( localize(
|
|
225
|
+
scope: ( localize(8867, 'global')),
|
|
226
|
+
label: ( localize(8868, "New Global Snippets file...")),
|
|
225
227
|
uri: userDataProfileService.currentProfile.snippetsHome
|
|
226
228
|
}];
|
|
227
229
|
const workspaceSnippetPicks = [];
|
|
228
230
|
for (const folder of workspaceService.getWorkspace().folders) {
|
|
229
231
|
workspaceSnippetPicks.push({
|
|
230
|
-
scope: ( localize(
|
|
231
|
-
label: ( localize(
|
|
232
|
+
scope: ( localize(8869, "{0} workspace", folder.name)),
|
|
233
|
+
label: ( localize(8870, "New Snippets file for '{0}'...", folder.name)),
|
|
232
234
|
uri: folder.toResource('.vscode')
|
|
233
235
|
});
|
|
234
236
|
}
|
|
235
237
|
if (existing.length > 0) {
|
|
236
|
-
existing.unshift({ type: 'separator', label: ( localize(
|
|
237
|
-
existing.push({ type: 'separator', label: ( localize(
|
|
238
|
+
existing.unshift({ type: 'separator', label: ( localize(8871, "Existing Snippets")) });
|
|
239
|
+
existing.push({ type: 'separator', label: ( localize(8872, "New Snippets")) });
|
|
238
240
|
}
|
|
239
241
|
else {
|
|
240
|
-
existing.push({ type: 'separator', label: ( localize(
|
|
242
|
+
existing.push({ type: 'separator', label: ( localize(8872, "New Snippets")) });
|
|
241
243
|
}
|
|
242
244
|
const pick = await quickInputService.pick([].concat(existing, globalSnippetPicks, workspaceSnippetPicks, picks.future), {
|
|
243
|
-
placeHolder: ( localize(
|
|
245
|
+
placeHolder: ( localize(8873, "Select Snippets File or Create Snippets")),
|
|
244
246
|
matchOnDescription: true
|
|
245
247
|
});
|
|
246
248
|
if (globalSnippetPicks.indexOf(pick) >= 0) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ICodeEditor } from "vscode/vscode/vs/editor/browser/editorBrowser";
|
|
2
|
+
import { ServicesAccessor } from "vscode/vscode/vs/editor/browser/editorExtensions";
|
|
3
|
+
import { SnippetEditorAction } from "@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions";
|
|
4
|
+
export declare class InsertSnippetAction extends SnippetEditorAction {
|
|
5
|
+
constructor();
|
|
6
|
+
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, arg: any): Promise<void>;
|
|
7
|
+
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
|
|
1
2
|
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
2
3
|
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
3
4
|
import { SnippetController2 } from 'vscode/vscode/vs/editor/contrib/snippet/browser/snippetController2';
|
|
4
5
|
import { localize2 } from 'vscode/vscode/vs/nls';
|
|
5
6
|
import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService.service';
|
|
6
7
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
|
-
import { SnippetEditorAction } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions';
|
|
8
|
+
import { SnippetEditorAction } from '@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions';
|
|
8
9
|
import { pickSnippet } from '../snippetPicker.js';
|
|
9
10
|
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
10
|
-
import { Snippet } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsFile';
|
|
11
|
+
import { Snippet, SnippetSource } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsFile';
|
|
11
12
|
|
|
12
13
|
class Args {
|
|
13
14
|
static fromUser(arg) {
|
|
@@ -24,11 +25,9 @@ class Args {
|
|
|
24
25
|
if (typeof langId !== 'string') {
|
|
25
26
|
langId = undefined;
|
|
26
27
|
}
|
|
27
|
-
return (
|
|
28
|
-
(new Args(snippet, name, langId))
|
|
29
|
-
);
|
|
28
|
+
return ( new Args(snippet, name, langId));
|
|
30
29
|
}
|
|
31
|
-
static { this._empty = (
|
|
30
|
+
static { this._empty = ( new Args(undefined, undefined, undefined)); }
|
|
32
31
|
constructor(snippet, name, langId) {
|
|
33
32
|
this.snippet = snippet;
|
|
34
33
|
this.name = name;
|
|
@@ -39,7 +38,7 @@ class InsertSnippetAction extends SnippetEditorAction {
|
|
|
39
38
|
constructor() {
|
|
40
39
|
super({
|
|
41
40
|
id: 'editor.action.insertSnippet',
|
|
42
|
-
title: ( localize2(
|
|
41
|
+
title: ( localize2(8876, "Insert Snippet")),
|
|
43
42
|
f1: true,
|
|
44
43
|
precondition: EditorContextKeys.writable,
|
|
45
44
|
metadata: {
|
|
@@ -72,11 +71,11 @@ class InsertSnippetAction extends SnippetEditorAction {
|
|
|
72
71
|
}
|
|
73
72
|
const clipboardService = accessor.get(IClipboardService);
|
|
74
73
|
const instaService = accessor.get(IInstantiationService);
|
|
75
|
-
const snippet = await (
|
|
74
|
+
const snippet = await ( new Promise((resolve, reject) => {
|
|
76
75
|
const { lineNumber, column } = editor.getPosition();
|
|
77
76
|
const { snippet, name, langId } = Args.fromUser(arg);
|
|
78
77
|
if (snippet) {
|
|
79
|
-
return resolve((
|
|
78
|
+
return resolve(( new Snippet(
|
|
80
79
|
false,
|
|
81
80
|
[],
|
|
82
81
|
'',
|
|
@@ -84,9 +83,9 @@ class InsertSnippetAction extends SnippetEditorAction {
|
|
|
84
83
|
'',
|
|
85
84
|
snippet,
|
|
86
85
|
'',
|
|
87
|
-
|
|
86
|
+
SnippetSource.User,
|
|
88
87
|
`random/${Math.random()}`
|
|
89
|
-
)))
|
|
88
|
+
)));
|
|
90
89
|
}
|
|
91
90
|
let languageId;
|
|
92
91
|
if (langId) {
|
|
@@ -110,7 +109,7 @@ class InsertSnippetAction extends SnippetEditorAction {
|
|
|
110
109
|
else {
|
|
111
110
|
resolve(instaService.invokeFunction(pickSnippet, languageId));
|
|
112
111
|
}
|
|
113
|
-
}))
|
|
112
|
+
}));
|
|
114
113
|
if (!snippet) {
|
|
115
114
|
return;
|
|
116
115
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ICodeEditor } from "vscode/vscode/vs/editor/browser/editorBrowser";
|
|
2
|
+
import { Position } from "vscode/vscode/vs/editor/common/core/position";
|
|
3
|
+
import { ITextModel } from "vscode/vscode/vs/editor/common/model";
|
|
4
|
+
import { ServicesAccessor } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
|
|
5
|
+
import { SnippetEditorAction } from "@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions";
|
|
6
|
+
import { Snippet } from "vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsFile";
|
|
7
|
+
import { ISnippetsService } from "vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service";
|
|
8
|
+
export declare function getSurroundableSnippets(snippetsService: ISnippetsService, model: ITextModel, position: Position, includeDisabledSnippets: boolean): Promise<Snippet[]>;
|
|
9
|
+
export declare class SurroundWithSnippetEditorAction extends SnippetEditorAction {
|
|
10
|
+
static readonly options: {
|
|
11
|
+
id: string;
|
|
12
|
+
title: import("vscode/vscode/vs/nls").ILocalizedString;
|
|
13
|
+
};
|
|
14
|
+
constructor();
|
|
15
|
+
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void>;
|
|
16
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
|
|
1
2
|
import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
|
|
2
3
|
import { SnippetController2 } from 'vscode/vscode/vs/editor/contrib/snippet/browser/snippetController2';
|
|
3
4
|
import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService.service';
|
|
4
5
|
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
5
6
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
-
import { SnippetEditorAction } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions';
|
|
7
|
+
import { SnippetEditorAction } from '@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common/vscode/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions';
|
|
7
8
|
import { pickSnippet } from '../snippetPicker.js';
|
|
8
9
|
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
9
10
|
import { localize2 } from 'vscode/vscode/vs/nls';
|
|
@@ -18,12 +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: ( localize2(
|
|
22
|
+
title: ( localize2(8877, "Surround with Snippet..."))
|
|
22
23
|
}; }
|
|
23
24
|
constructor() {
|
|
24
25
|
super({
|
|
25
26
|
...SurroundWithSnippetEditorAction.options,
|
|
26
|
-
precondition: (
|
|
27
|
+
precondition: ( ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasNonEmptySelection)),
|
|
27
28
|
f1: true,
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ILanguageFeaturesService } from "vscode/vscode/vs/editor/common/services/languageFeatures";
|
|
2
|
+
import { IConfigurationService } from "vscode/vscode/vs/platform/configuration/common/configuration.service";
|
|
3
|
+
import { IInstantiationService } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
|
|
4
|
+
import { IWorkbenchContribution } from "vscode/vscode/vs/workbench/common/contributions";
|
|
5
|
+
export declare class SnippetCodeActions implements IWorkbenchContribution {
|
|
6
|
+
private readonly _store;
|
|
7
|
+
constructor(instantiationService: IInstantiationService, languageFeaturesService: ILanguageFeaturesService, configService: IConfigurationService);
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
4
|
import { Selection } from 'vscode/vscode/vs/editor/common/core/selection';
|
|
4
5
|
import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
|
|
@@ -6,7 +7,7 @@ import { CodeActionKind } from 'vscode/vscode/vs/editor/contrib/codeAction/commo
|
|
|
6
7
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
7
8
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
8
9
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
|
-
import { ApplyFileSnippetAction } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets';
|
|
10
|
+
import { ApplyFileSnippetAction } from '@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common/vscode/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets';
|
|
10
11
|
import { SurroundWithSnippetEditorAction, getSurroundableSnippets } from './commands/surroundWithSnippet.js';
|
|
11
12
|
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
12
13
|
|
|
@@ -16,7 +17,7 @@ let SurroundWithSnippetCodeActionProvider = class SurroundWithSnippetCodeActionP
|
|
|
16
17
|
static { this._MAX_CODE_ACTIONS = 4; }
|
|
17
18
|
static { this._overflowCommandCodeAction = {
|
|
18
19
|
kind: CodeActionKind.SurroundWith.value,
|
|
19
|
-
title: ( localize(
|
|
20
|
+
title: ( localize(8878, "More...")),
|
|
20
21
|
command: {
|
|
21
22
|
id: SurroundWithSnippetEditorAction.options.id,
|
|
22
23
|
title: SurroundWithSnippetEditorAction.options.title.value,
|
|
@@ -41,7 +42,7 @@ let SurroundWithSnippetCodeActionProvider = class SurroundWithSnippetCodeActionP
|
|
|
41
42
|
break;
|
|
42
43
|
}
|
|
43
44
|
actions.push({
|
|
44
|
-
title: ( localize(
|
|
45
|
+
title: ( localize(8879, "{0}", snippet.name)),
|
|
45
46
|
kind: CodeActionKind.SurroundWith.value,
|
|
46
47
|
edit: asWorkspaceEdit(model, range, snippet)
|
|
47
48
|
});
|
|
@@ -52,14 +53,14 @@ let SurroundWithSnippetCodeActionProvider = class SurroundWithSnippetCodeActionP
|
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
|
-
SurroundWithSnippetCodeActionProvider = SurroundWithSnippetCodeActionProvider_1 = (
|
|
56
|
-
(
|
|
57
|
-
], SurroundWithSnippetCodeActionProvider))
|
|
56
|
+
SurroundWithSnippetCodeActionProvider = SurroundWithSnippetCodeActionProvider_1 = ( __decorate([
|
|
57
|
+
( __param(0, ISnippetsService))
|
|
58
|
+
], SurroundWithSnippetCodeActionProvider));
|
|
58
59
|
let FileTemplateCodeActionProvider = class FileTemplateCodeActionProvider {
|
|
59
60
|
static { FileTemplateCodeActionProvider_1 = this; }
|
|
60
61
|
static { this._MAX_CODE_ACTIONS = 4; }
|
|
61
62
|
static { this._overflowCommandCodeAction = {
|
|
62
|
-
title: ( localize(
|
|
63
|
+
title: ( localize(8880, 'Start with Snippet')),
|
|
63
64
|
kind: CodeActionKind.SurroundWith.value,
|
|
64
65
|
command: {
|
|
65
66
|
id: ApplyFileSnippetAction.Id,
|
|
@@ -82,7 +83,7 @@ let FileTemplateCodeActionProvider = class FileTemplateCodeActionProvider {
|
|
|
82
83
|
break;
|
|
83
84
|
}
|
|
84
85
|
actions.push({
|
|
85
|
-
title: ( localize(
|
|
86
|
+
title: ( localize(8881, 'Start with: {0}', snippet.name)),
|
|
86
87
|
kind: CodeActionKind.SurroundWith.value,
|
|
87
88
|
edit: asWorkspaceEdit(model, model.getFullModelRange(), snippet)
|
|
88
89
|
});
|
|
@@ -93,9 +94,9 @@ let FileTemplateCodeActionProvider = class FileTemplateCodeActionProvider {
|
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
|
-
FileTemplateCodeActionProvider = FileTemplateCodeActionProvider_1 = (
|
|
97
|
-
(
|
|
98
|
-
], FileTemplateCodeActionProvider))
|
|
97
|
+
FileTemplateCodeActionProvider = FileTemplateCodeActionProvider_1 = ( __decorate([
|
|
98
|
+
( __param(0, ISnippetsService))
|
|
99
|
+
], FileTemplateCodeActionProvider));
|
|
99
100
|
function asWorkspaceEdit(model, range, snippet) {
|
|
100
101
|
return {
|
|
101
102
|
edits: [{
|
|
@@ -111,9 +112,9 @@ function asWorkspaceEdit(model, range, snippet) {
|
|
|
111
112
|
}
|
|
112
113
|
let SnippetCodeActions = class SnippetCodeActions {
|
|
113
114
|
constructor(instantiationService, languageFeaturesService, configService) {
|
|
114
|
-
this._store = (
|
|
115
|
+
this._store = ( new DisposableStore());
|
|
115
116
|
const setting = 'editor.snippets.codeActions.enabled';
|
|
116
|
-
const sessionStore = (
|
|
117
|
+
const sessionStore = ( new DisposableStore());
|
|
117
118
|
const update = () => {
|
|
118
119
|
sessionStore.clear();
|
|
119
120
|
if (configService.getValue(setting)) {
|
|
@@ -129,10 +130,10 @@ let SnippetCodeActions = class SnippetCodeActions {
|
|
|
129
130
|
this._store.dispose();
|
|
130
131
|
}
|
|
131
132
|
};
|
|
132
|
-
SnippetCodeActions = (
|
|
133
|
-
(
|
|
134
|
-
(
|
|
135
|
-
(
|
|
136
|
-
], SnippetCodeActions))
|
|
133
|
+
SnippetCodeActions = ( __decorate([
|
|
134
|
+
( __param(0, IInstantiationService)),
|
|
135
|
+
( __param(1, ILanguageFeaturesService)),
|
|
136
|
+
( __param(2, IConfigurationService))
|
|
137
|
+
], SnippetCodeActions));
|
|
137
138
|
|
|
138
139
|
export { SnippetCodeActions };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Snippet } from "vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsFile";
|
|
2
|
+
import { ServicesAccessor } from "vscode/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
export declare function pickSnippet(accessor: ServicesAccessor, languageIdOrSnippets: string | Snippet[]): Promise<Snippet | undefined>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
|
|
1
2
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
2
3
|
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
4
|
+
import { SnippetSource } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsFile';
|
|
3
5
|
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
4
6
|
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
5
7
|
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
@@ -29,31 +31,31 @@ async function pickSnippet(accessor, languageIdOrSnippets) {
|
|
|
29
31
|
if (!prevSnippet || prevSnippet.snippetSource !== snippet.snippetSource || prevSnippet.source !== snippet.source) {
|
|
30
32
|
let label = '';
|
|
31
33
|
switch (snippet.snippetSource) {
|
|
32
|
-
case
|
|
33
|
-
label = ( localize(
|
|
34
|
+
case SnippetSource.User:
|
|
35
|
+
label = ( localize(8884, "User Snippets"));
|
|
34
36
|
break;
|
|
35
|
-
case
|
|
37
|
+
case SnippetSource.Extension:
|
|
36
38
|
label = snippet.source;
|
|
37
39
|
break;
|
|
38
|
-
case
|
|
39
|
-
label = ( localize(
|
|
40
|
+
case SnippetSource.Workspace:
|
|
41
|
+
label = ( localize(8885, "Workspace Snippets"));
|
|
40
42
|
break;
|
|
41
43
|
}
|
|
42
44
|
result.push({ type: 'separator', label });
|
|
43
45
|
}
|
|
44
|
-
if (snippet.snippetSource ===
|
|
46
|
+
if (snippet.snippetSource === SnippetSource.Extension) {
|
|
45
47
|
const isEnabled = snippetService.isEnabled(snippet);
|
|
46
48
|
if (isEnabled) {
|
|
47
49
|
pick.buttons = [{
|
|
48
50
|
iconClass: ThemeIcon.asClassName(Codicon.eyeClosed),
|
|
49
|
-
tooltip: ( localize(
|
|
51
|
+
tooltip: ( localize(8886, 'Hide from IntelliSense'))
|
|
50
52
|
}];
|
|
51
53
|
}
|
|
52
54
|
else {
|
|
53
|
-
pick.description = ( localize(
|
|
55
|
+
pick.description = ( localize(8887, "(hidden from IntelliSense)"));
|
|
54
56
|
pick.buttons = [{
|
|
55
57
|
iconClass: ThemeIcon.asClassName(Codicon.eye),
|
|
56
|
-
tooltip: ( localize(
|
|
58
|
+
tooltip: ( localize(8888, 'Show in IntelliSense'))
|
|
57
59
|
}];
|
|
58
60
|
}
|
|
59
61
|
}
|
|
@@ -62,9 +64,9 @@ async function pickSnippet(accessor, languageIdOrSnippets) {
|
|
|
62
64
|
}
|
|
63
65
|
return result;
|
|
64
66
|
};
|
|
65
|
-
const disposables = (
|
|
67
|
+
const disposables = ( new DisposableStore());
|
|
66
68
|
const picker = disposables.add(quickInputService.createQuickPick({ useSeparators: true }));
|
|
67
|
-
picker.placeholder = ( localize(
|
|
69
|
+
picker.placeholder = ( localize(8889, "Select a snippet"));
|
|
68
70
|
picker.matchOnDetail = true;
|
|
69
71
|
picker.ignoreFocusOut = false;
|
|
70
72
|
picker.keepScrollPosition = true;
|
|
@@ -75,7 +77,7 @@ async function pickSnippet(accessor, languageIdOrSnippets) {
|
|
|
75
77
|
}));
|
|
76
78
|
picker.items = makeSnippetPicks();
|
|
77
79
|
if (!picker.items.length) {
|
|
78
|
-
picker.validationMessage = ( localize(
|
|
80
|
+
picker.validationMessage = ( localize(8890, "No snippet available"));
|
|
79
81
|
}
|
|
80
82
|
picker.show();
|
|
81
83
|
await Promise.race([Event.toPromise(picker.onDidAccept), Event.toPromise(picker.onDidHide)]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
|
|
1
2
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
2
3
|
import { registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
3
4
|
import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
5
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
4
6
|
import { Extensions as Extensions$2 } from 'vscode/vscode/vs/platform/jsonschemas/common/jsonContributionRegistry';
|
|
5
7
|
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
6
8
|
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
7
9
|
import { ConfigureSnippetsAction } from './commands/configureSnippets.js';
|
|
8
|
-
import { ApplyFileSnippetAction } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets';
|
|
10
|
+
import { ApplyFileSnippetAction } from '@codingame/monaco-vscode-4e719823-8b6e-554d-b01a-5670b53fbb19-common/vscode/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets';
|
|
9
11
|
import { InsertSnippetAction } from './commands/insertSnippet.js';
|
|
10
12
|
import { SurroundWithSnippetEditorAction } from './commands/surroundWithSnippet.js';
|
|
11
13
|
import { SnippetCodeActions } from './snippetCodeActionProvider.js';
|
|
12
14
|
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
13
15
|
import 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsService';
|
|
16
|
+
import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
14
17
|
import { Extensions as Extensions$1 } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
15
18
|
import 'vscode/vscode/vs/workbench/contrib/snippets/browser/tabCompletion';
|
|
16
19
|
import { editorConfigurationBaseNode } from 'vscode/vscode/vs/editor/common/config/editorConfigurationSchema';
|
|
@@ -20,16 +23,16 @@ CommandsRegistry.registerCommandAlias('editor.action.showSnippets', 'editor.acti
|
|
|
20
23
|
registerAction2(SurroundWithSnippetEditorAction);
|
|
21
24
|
registerAction2(ApplyFileSnippetAction);
|
|
22
25
|
registerAction2(ConfigureSnippetsAction);
|
|
23
|
-
const workbenchContribRegistry = (
|
|
24
|
-
workbenchContribRegistry.registerWorkbenchContribution(SnippetCodeActions,
|
|
25
|
-
(
|
|
26
|
-
.as(Extensions$1.Configuration))
|
|
26
|
+
const workbenchContribRegistry = ( Registry.as(Extensions.Workbench));
|
|
27
|
+
workbenchContribRegistry.registerWorkbenchContribution(SnippetCodeActions, LifecyclePhase.Restored);
|
|
28
|
+
( Registry
|
|
29
|
+
.as(Extensions$1.Configuration))
|
|
27
30
|
.registerConfiguration({
|
|
28
31
|
...editorConfigurationBaseNode,
|
|
29
32
|
'properties': {
|
|
30
33
|
'editor.snippets.codeActions.enabled': {
|
|
31
34
|
'description': ( localize(
|
|
32
|
-
|
|
35
|
+
8891,
|
|
33
36
|
'Controls if surround-with-snippets or file template snippets show as Code Actions.'
|
|
34
37
|
)),
|
|
35
38
|
'type': 'boolean',
|
|
@@ -40,16 +43,16 @@ workbenchContribRegistry.registerWorkbenchContribution(SnippetCodeActions, 3 );
|
|
|
40
43
|
const languageScopeSchemaId = 'vscode://schemas/snippets';
|
|
41
44
|
const snippetSchemaProperties = {
|
|
42
45
|
prefix: {
|
|
43
|
-
description: ( localize(
|
|
46
|
+
description: ( localize(8892, 'The prefix to use when selecting the snippet in intellisense')),
|
|
44
47
|
type: ['string', 'array']
|
|
45
48
|
},
|
|
46
49
|
isFileTemplate: {
|
|
47
|
-
description: ( localize(
|
|
50
|
+
description: ( localize(8893, 'The snippet is meant to populate or replace a whole file')),
|
|
48
51
|
type: 'boolean'
|
|
49
52
|
},
|
|
50
53
|
body: {
|
|
51
54
|
markdownDescription: ( localize(
|
|
52
|
-
|
|
55
|
+
8894,
|
|
53
56
|
'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`.'
|
|
54
57
|
)),
|
|
55
58
|
type: ['string', 'array'],
|
|
@@ -58,7 +61,7 @@ const snippetSchemaProperties = {
|
|
|
58
61
|
}
|
|
59
62
|
},
|
|
60
63
|
description: {
|
|
61
|
-
description: ( localize(
|
|
64
|
+
description: ( localize(8895, 'The snippet description.')),
|
|
62
65
|
type: ['string', 'array']
|
|
63
66
|
}
|
|
64
67
|
};
|
|
@@ -67,11 +70,11 @@ const languageScopeSchema = {
|
|
|
67
70
|
allowComments: true,
|
|
68
71
|
allowTrailingCommas: true,
|
|
69
72
|
defaultSnippets: [{
|
|
70
|
-
label: ( localize(
|
|
73
|
+
label: ( localize(8896, "Empty snippet")),
|
|
71
74
|
body: { '${1:snippetName}': { 'prefix': '${2:prefix}', 'body': '${3:snippet}', 'description': '${4:description}' } }
|
|
72
75
|
}],
|
|
73
76
|
type: 'object',
|
|
74
|
-
description: ( localize(
|
|
77
|
+
description: ( localize(8897, 'User snippet configuration')),
|
|
75
78
|
additionalProperties: {
|
|
76
79
|
type: 'object',
|
|
77
80
|
required: ['body'],
|
|
@@ -85,11 +88,11 @@ const globalSchema = {
|
|
|
85
88
|
allowComments: true,
|
|
86
89
|
allowTrailingCommas: true,
|
|
87
90
|
defaultSnippets: [{
|
|
88
|
-
label: ( localize(
|
|
91
|
+
label: ( localize(8896, "Empty snippet")),
|
|
89
92
|
body: { '${1:snippetName}': { 'scope': '${2:scope}', 'prefix': '${3:prefix}', 'body': '${4:snippet}', 'description': '${5:description}' } }
|
|
90
93
|
}],
|
|
91
94
|
type: 'object',
|
|
92
|
-
description: ( localize(
|
|
95
|
+
description: ( localize(8897, 'User snippet configuration')),
|
|
93
96
|
additionalProperties: {
|
|
94
97
|
type: 'object',
|
|
95
98
|
required: ['body'],
|
|
@@ -97,7 +100,7 @@ const globalSchema = {
|
|
|
97
100
|
...snippetSchemaProperties,
|
|
98
101
|
scope: {
|
|
99
102
|
description: ( localize(
|
|
100
|
-
|
|
103
|
+
8898,
|
|
101
104
|
"A list of language names to which this snippet applies, e.g. 'typescript,javascript'."
|
|
102
105
|
)),
|
|
103
106
|
type: 'string'
|
|
@@ -106,6 +109,6 @@ const globalSchema = {
|
|
|
106
109
|
additionalProperties: false
|
|
107
110
|
}
|
|
108
111
|
};
|
|
109
|
-
const reg = (
|
|
112
|
+
const reg = ( Registry.as(Extensions$2.JSONContribution));
|
|
110
113
|
reg.registerSchema(languageScopeSchemaId, languageScopeSchema);
|
|
111
114
|
reg.registerSchema(globalSchemaId, globalSchema);
|
package/snippets.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { StandaloneServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
2
|
-
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
3
|
-
import { ISnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippets.service';
|
|
4
|
-
import { SnippetsService } from 'vscode/vscode/vs/workbench/contrib/snippets/browser/snippetsService';
|
|
5
|
-
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
6
|
-
import getServiceOverride$1 from '@codingame/monaco-vscode-files-service-override';
|
|
7
|
-
import { registerServiceInitializeParticipant } from 'vscode/lifecycle';
|
|
8
|
-
import './vscode/src/vs/workbench/contrib/snippets/browser/snippets.contribution.js';
|
|
9
|
-
|
|
10
|
-
registerServiceInitializeParticipant(async (accessor) => {
|
|
11
|
-
void accessor
|
|
12
|
-
.get(ILifecycleService)
|
|
13
|
-
.when(2 )
|
|
14
|
-
.then(() => {
|
|
15
|
-
StandaloneServices.get(ISnippetsService);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
function getServiceOverride() {
|
|
19
|
-
return {
|
|
20
|
-
...getServiceOverride$1(),
|
|
21
|
-
[( ISnippetsService.toString())]: new SyncDescriptor(SnippetsService, [], true)
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { getServiceOverride as default };
|