@codingame/monaco-vscode-keybindings-service-override 25.1.2 → 26.0.1
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/platform/keyboardLayout/common/keyboardConfig.js +20 -17
- package/vscode/src/vs/workbench/contrib/commands/common/commands.contribution.js +45 -56
- package/vscode/src/vs/workbench/contrib/keybindings/browser/keybindings.contribution.js +25 -17
- package/vscode/src/vs/workbench/contrib/preferences/browser/keybindingsEditorContribution.js +39 -36
- package/vscode/src/vs/workbench/contrib/preferences/common/smartSnippetInserter.js +37 -40
- package/vscode/src/vs/workbench/services/actions/common/menusExtensionPoint.js +678 -724
- package/vscode/src/vs/workbench/services/commands/common/commandService.js +13 -17
- package/vscode/src/vs/workbench/services/keybinding/browser/keybindingService.js +245 -208
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.js +64 -71
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayouts/_.contribution.js +3 -1
- package/vscode/src/vs/workbench/services/keybinding/common/keybindingIO.js +20 -25
- package/vscode/src/vs/workbench/services/keybinding/common/keymapInfo.js +21 -22
- package/vscode/src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.js +185 -173
- package/vscode/src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.js +49 -45
|
@@ -46,96 +46,97 @@ import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/s
|
|
|
46
46
|
import { IUserDataProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
|
|
47
47
|
import { OutputBuilder, KeybindingIO } from '../common/keybindingIO.js';
|
|
48
48
|
import { getAllUnboundCommands } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/keybinding/browser/unboundCommands';
|
|
49
|
+
import { EditorContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/editorContextKeys';
|
|
49
50
|
|
|
50
51
|
var WorkbenchKeybindingService_1;
|
|
51
52
|
function isValidContributedKeyBinding(keyBinding, rejects) {
|
|
52
53
|
if (!keyBinding) {
|
|
53
|
-
rejects.push(( localize(
|
|
54
|
+
rejects.push(( localize(14505, "expected non-empty value.")));
|
|
54
55
|
return false;
|
|
55
56
|
}
|
|
56
|
-
if (typeof keyBinding.command !==
|
|
57
|
+
if (typeof keyBinding.command !== "string") {
|
|
57
58
|
rejects.push(( localize(
|
|
58
|
-
|
|
59
|
+
14506,
|
|
59
60
|
"property `{0}` is mandatory and must be of type `string`",
|
|
60
|
-
|
|
61
|
+
"command"
|
|
61
62
|
)));
|
|
62
63
|
return false;
|
|
63
64
|
}
|
|
64
|
-
if (keyBinding.key && typeof keyBinding.key !==
|
|
65
|
-
rejects.push(( localize(
|
|
65
|
+
if (keyBinding.key && typeof keyBinding.key !== "string") {
|
|
66
|
+
rejects.push(( localize(14507, "property `{0}` can be omitted or must be of type `string`", "key")));
|
|
66
67
|
return false;
|
|
67
68
|
}
|
|
68
|
-
if (keyBinding.when && typeof keyBinding.when !==
|
|
69
|
-
rejects.push(( localize(
|
|
69
|
+
if (keyBinding.when && typeof keyBinding.when !== "string") {
|
|
70
|
+
rejects.push(( localize(14507, "property `{0}` can be omitted or must be of type `string`", "when")));
|
|
70
71
|
return false;
|
|
71
72
|
}
|
|
72
|
-
if (keyBinding.mac && typeof keyBinding.mac !==
|
|
73
|
-
rejects.push(( localize(
|
|
73
|
+
if (keyBinding.mac && typeof keyBinding.mac !== "string") {
|
|
74
|
+
rejects.push(( localize(14507, "property `{0}` can be omitted or must be of type `string`", "mac")));
|
|
74
75
|
return false;
|
|
75
76
|
}
|
|
76
|
-
if (keyBinding.linux && typeof keyBinding.linux !==
|
|
77
|
+
if (keyBinding.linux && typeof keyBinding.linux !== "string") {
|
|
77
78
|
rejects.push(( localize(
|
|
78
|
-
|
|
79
|
+
14507,
|
|
79
80
|
"property `{0}` can be omitted or must be of type `string`",
|
|
80
|
-
|
|
81
|
+
"linux"
|
|
81
82
|
)));
|
|
82
83
|
return false;
|
|
83
84
|
}
|
|
84
|
-
if (keyBinding.win && typeof keyBinding.win !==
|
|
85
|
-
rejects.push(( localize(
|
|
85
|
+
if (keyBinding.win && typeof keyBinding.win !== "string") {
|
|
86
|
+
rejects.push(( localize(14507, "property `{0}` can be omitted or must be of type `string`", "win")));
|
|
86
87
|
return false;
|
|
87
88
|
}
|
|
88
89
|
return true;
|
|
89
90
|
}
|
|
90
91
|
const keybindingType = {
|
|
91
|
-
type:
|
|
92
|
-
default: {
|
|
93
|
-
|
|
92
|
+
type: "object",
|
|
93
|
+
default: {
|
|
94
|
+
command: "",
|
|
95
|
+
key: ""
|
|
96
|
+
},
|
|
97
|
+
required: ["command", "key"],
|
|
94
98
|
properties: {
|
|
95
99
|
command: {
|
|
96
|
-
description: ( localize(
|
|
97
|
-
type:
|
|
100
|
+
description: ( localize(14508, "Identifier of the command to run when keybinding is triggered.")),
|
|
101
|
+
type: "string"
|
|
98
102
|
},
|
|
99
103
|
args: {
|
|
100
|
-
description: ( localize(
|
|
104
|
+
description: ( localize(14509, "Arguments to pass to the command to execute."))
|
|
101
105
|
},
|
|
102
106
|
key: {
|
|
103
107
|
description: ( localize(
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
14510,
|
|
109
|
+
"Key or key sequence (separate keys with plus-sign and sequences with space, e.g. Ctrl+O and Ctrl+L L for a chord)."
|
|
106
110
|
)),
|
|
107
|
-
type:
|
|
111
|
+
type: "string"
|
|
108
112
|
},
|
|
109
113
|
mac: {
|
|
110
|
-
description: ( localize(
|
|
111
|
-
type:
|
|
114
|
+
description: ( localize(14511, "Mac specific key or key sequence.")),
|
|
115
|
+
type: "string"
|
|
112
116
|
},
|
|
113
117
|
linux: {
|
|
114
|
-
description: ( localize(
|
|
115
|
-
type:
|
|
118
|
+
description: ( localize(14512, "Linux specific key or key sequence.")),
|
|
119
|
+
type: "string"
|
|
116
120
|
},
|
|
117
121
|
win: {
|
|
118
|
-
description: ( localize(
|
|
119
|
-
type:
|
|
122
|
+
description: ( localize(14513, "Windows specific key or key sequence.")),
|
|
123
|
+
type: "string"
|
|
120
124
|
},
|
|
121
125
|
when: {
|
|
122
|
-
description: ( localize(
|
|
123
|
-
type:
|
|
124
|
-
}
|
|
126
|
+
description: ( localize(14514, "Condition when the key is active.")),
|
|
127
|
+
type: "string"
|
|
128
|
+
}
|
|
125
129
|
}
|
|
126
130
|
};
|
|
127
131
|
const keybindingsExtPoint = ExtensionsRegistry.registerExtensionPoint({
|
|
128
|
-
extensionPoint:
|
|
132
|
+
extensionPoint: "keybindings",
|
|
129
133
|
deps: [commandsExtensionPoint],
|
|
130
134
|
jsonSchema: {
|
|
131
|
-
description: ( localize(
|
|
132
|
-
oneOf: [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
items: keybindingType
|
|
137
|
-
}
|
|
138
|
-
]
|
|
135
|
+
description: ( localize(14515, "Contributes keybindings.")),
|
|
136
|
+
oneOf: [keybindingType, {
|
|
137
|
+
type: "array",
|
|
138
|
+
items: keybindingType
|
|
139
|
+
}]
|
|
139
140
|
}
|
|
140
141
|
});
|
|
141
142
|
const NUMPAD_PRINTABLE_SCANCODES = [
|
|
@@ -167,12 +168,30 @@ otherMacNumpadMapping.set(ScanCode.Numpad8, KeyCode.Digit8);
|
|
|
167
168
|
otherMacNumpadMapping.set(ScanCode.Numpad9, KeyCode.Digit9);
|
|
168
169
|
otherMacNumpadMapping.set(ScanCode.Numpad0, KeyCode.Digit0);
|
|
169
170
|
let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchKeybindingService extends AbstractKeybindingService {
|
|
170
|
-
constructor(
|
|
171
|
-
|
|
171
|
+
constructor(
|
|
172
|
+
contextKeyService,
|
|
173
|
+
commandService,
|
|
174
|
+
telemetryService,
|
|
175
|
+
notificationService,
|
|
176
|
+
userDataProfileService,
|
|
177
|
+
hostService,
|
|
178
|
+
extensionService,
|
|
179
|
+
fileService,
|
|
180
|
+
uriIdentityService,
|
|
181
|
+
logService,
|
|
182
|
+
keyboardLayoutService
|
|
183
|
+
) {
|
|
184
|
+
super(
|
|
185
|
+
contextKeyService,
|
|
186
|
+
commandService,
|
|
187
|
+
telemetryService,
|
|
188
|
+
notificationService,
|
|
189
|
+
logService
|
|
190
|
+
);
|
|
172
191
|
this.hostService = hostService;
|
|
173
192
|
this.keyboardLayoutService = keyboardLayoutService;
|
|
174
193
|
this._contributions = [];
|
|
175
|
-
this.isComposingGlobalContextKey = contextKeyService.createKey(
|
|
194
|
+
this.isComposingGlobalContextKey = contextKeyService.createKey(EditorContextKeys.isComposing.key, false);
|
|
176
195
|
this.kbsJsonSchema = ( new KeybindingsJsonSchema());
|
|
177
196
|
this.updateKeybindingsJsonSchema();
|
|
178
197
|
this._keyboardMapper = this.keyboardLayoutService.getKeyboardMapper();
|
|
@@ -189,20 +208,36 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
189
208
|
}
|
|
190
209
|
});
|
|
191
210
|
this._register(this.userKeybindings.onDidChange(() => {
|
|
192
|
-
logService.debug(
|
|
211
|
+
logService.debug("User keybindings changed");
|
|
193
212
|
this.updateResolver();
|
|
194
213
|
}));
|
|
195
|
-
keybindingsExtPoint.setHandler(
|
|
214
|
+
keybindingsExtPoint.setHandler(extensions => {
|
|
196
215
|
const keybindings = [];
|
|
197
216
|
for (const extension of extensions) {
|
|
198
|
-
this._handleKeybindingsExtensionPointUser(
|
|
217
|
+
this._handleKeybindingsExtensionPointUser(
|
|
218
|
+
extension.description.identifier,
|
|
219
|
+
extension.description.isBuiltin,
|
|
220
|
+
extension.value,
|
|
221
|
+
extension.collector,
|
|
222
|
+
keybindings
|
|
223
|
+
);
|
|
199
224
|
}
|
|
200
225
|
KeybindingsRegistry.setExtensionKeybindings(keybindings);
|
|
201
226
|
this.updateResolver();
|
|
202
227
|
});
|
|
203
228
|
this.updateKeybindingsJsonSchema();
|
|
204
|
-
this._register(
|
|
205
|
-
|
|
229
|
+
this._register(
|
|
230
|
+
extensionService.onDidRegisterExtensions(() => this.updateKeybindingsJsonSchema())
|
|
231
|
+
);
|
|
232
|
+
this._register(Event.runAndSubscribe(onDidRegisterWindow, (
|
|
233
|
+
{
|
|
234
|
+
window,
|
|
235
|
+
disposables
|
|
236
|
+
}
|
|
237
|
+
) => disposables.add(this._registerKeyListeners(window)), {
|
|
238
|
+
window: mainWindow,
|
|
239
|
+
disposables: this._store
|
|
240
|
+
}));
|
|
206
241
|
this._register(onDidChangeFullscreen(windowId => {
|
|
207
242
|
if (windowId !== mainWindow.vscodeWindowId) {
|
|
208
243
|
return;
|
|
@@ -210,7 +245,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
210
245
|
if (BrowserFeatures.keyboard === KeyboardSupport.None) {
|
|
211
246
|
return;
|
|
212
247
|
}
|
|
213
|
-
this.lockKeyCodes(isFullscreen(mainWindow) ? [
|
|
248
|
+
this.lockKeyCodes(isFullscreen(mainWindow) ? ["Escape"] : []);
|
|
214
249
|
this._cachedResolver = null;
|
|
215
250
|
this._onDidUpdateKeybindings.fire();
|
|
216
251
|
}));
|
|
@@ -219,8 +254,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
219
254
|
const keyboard = mainWindow.navigator.keyboard;
|
|
220
255
|
if (keyCodes.length > 0) {
|
|
221
256
|
keyboard?.lock(keyCodes);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
257
|
+
} else {
|
|
224
258
|
keyboard?.unlock();
|
|
225
259
|
}
|
|
226
260
|
}
|
|
@@ -231,7 +265,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
231
265
|
}
|
|
232
266
|
_registerKeyListeners(window) {
|
|
233
267
|
const disposables = ( new DisposableStore());
|
|
234
|
-
disposables.add(addDisposableListener(window, EventType.KEY_DOWN,
|
|
268
|
+
disposables.add(addDisposableListener(window, EventType.KEY_DOWN, e => {
|
|
235
269
|
if (this._keybindingHoldMode) {
|
|
236
270
|
return;
|
|
237
271
|
}
|
|
@@ -245,7 +279,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
245
279
|
}
|
|
246
280
|
this.isComposingGlobalContextKey.set(false);
|
|
247
281
|
}));
|
|
248
|
-
disposables.add(addDisposableListener(window, EventType.KEY_UP,
|
|
282
|
+
disposables.add(addDisposableListener(window, EventType.KEY_UP, e => {
|
|
249
283
|
this._resetKeybindingHoldMode();
|
|
250
284
|
this.isComposingGlobalContextKey.set(e.isComposing);
|
|
251
285
|
const keyEvent = ( new StandardKeyboardEvent(e));
|
|
@@ -259,7 +293,10 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
259
293
|
}
|
|
260
294
|
registerSchemaContribution(contribution) {
|
|
261
295
|
const listener = contribution.onDidChange?.(() => this.updateKeybindingsJsonSchema());
|
|
262
|
-
const entry = {
|
|
296
|
+
const entry = {
|
|
297
|
+
listener,
|
|
298
|
+
contribution
|
|
299
|
+
};
|
|
263
300
|
this._contributions.push(entry);
|
|
264
301
|
this.updateKeybindingsJsonSchema();
|
|
265
302
|
return toDisposable(() => {
|
|
@@ -272,26 +309,28 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
272
309
|
this.kbsJsonSchema.updateSchema(this._contributions.flatMap(x => x.contribution.getSchemaAdditions()));
|
|
273
310
|
}
|
|
274
311
|
_printKeybinding(keybinding) {
|
|
275
|
-
return UserSettingsLabelProvider.toLabel(OS, keybinding.chords,
|
|
312
|
+
return UserSettingsLabelProvider.toLabel(OS, keybinding.chords, chord => {
|
|
276
313
|
if (chord instanceof KeyCodeChord) {
|
|
277
314
|
return ( KeyCodeUtils.toString(chord.keyCode));
|
|
278
315
|
}
|
|
279
316
|
return ( ScanCodeUtils.toString(chord.scanCode));
|
|
280
|
-
}) ||
|
|
317
|
+
}) || "[null]";
|
|
281
318
|
}
|
|
282
319
|
_printResolvedKeybinding(resolvedKeybinding) {
|
|
283
|
-
return ( resolvedKeybinding.getDispatchChords().map(x => x ||
|
|
320
|
+
return ( resolvedKeybinding.getDispatchChords().map(x => x || "[null]")).join(" ");
|
|
284
321
|
}
|
|
285
322
|
_printResolvedKeybindings(output, input, resolvedKeybindings) {
|
|
286
323
|
const padLength = 35;
|
|
287
|
-
const firstRow = `${input.padStart(padLength,
|
|
324
|
+
const firstRow = `${input.padStart(padLength, " ")} => `;
|
|
288
325
|
if (resolvedKeybindings.length === 0) {
|
|
289
|
-
output.push(`${firstRow}${
|
|
326
|
+
output.push(`${firstRow}${"[NO BINDING]".padStart(padLength, " ")}`);
|
|
290
327
|
return;
|
|
291
328
|
}
|
|
292
329
|
for (const resolvedKeybinding of resolvedKeybindings) {
|
|
293
330
|
{
|
|
294
|
-
output.push(
|
|
331
|
+
output.push(
|
|
332
|
+
`${firstRow}${this._printResolvedKeybinding(resolvedKeybinding).padStart(padLength, " ")}`
|
|
333
|
+
);
|
|
295
334
|
}
|
|
296
335
|
}
|
|
297
336
|
}
|
|
@@ -316,7 +355,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
316
355
|
if (!item.keybinding) {
|
|
317
356
|
continue;
|
|
318
357
|
}
|
|
319
|
-
const input = item._sourceKey ??
|
|
358
|
+
const input = item._sourceKey ?? "Impossible: missing source key, but has keybinding";
|
|
320
359
|
if (( seenBindings.has(input))) {
|
|
321
360
|
continue;
|
|
322
361
|
}
|
|
@@ -324,13 +363,13 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
324
363
|
const resolvedKeybindings = this._keyboardMapper.resolveKeybinding(item.keybinding);
|
|
325
364
|
this._printResolvedKeybindings(result, input, resolvedKeybindings);
|
|
326
365
|
}
|
|
327
|
-
return result.join(
|
|
366
|
+
return result.join("\n");
|
|
328
367
|
}
|
|
329
368
|
_dumpDebugInfo() {
|
|
330
|
-
const layoutInfo = JSON.stringify(this.keyboardLayoutService.getCurrentKeyboardLayout(), null,
|
|
369
|
+
const layoutInfo = JSON.stringify(this.keyboardLayoutService.getCurrentKeyboardLayout(), null, "\t");
|
|
331
370
|
const mapperInfo = this._keyboardMapper.dumpDebugInfo();
|
|
332
371
|
const resolvedKeybindings = this._dumpResolveKeybindingDebugInfo();
|
|
333
|
-
const rawMapping = JSON.stringify(this.keyboardLayoutService.getRawKeyboardMapping(), null,
|
|
372
|
+
const rawMapping = JSON.stringify(this.keyboardLayoutService.getRawKeyboardMapping(), null, "\t");
|
|
334
373
|
return `Layout info:\n${layoutInfo}\n\n${resolvedKeybindings}\n\n${mapperInfo}\n\nRaw mapping:\n${rawMapping}`;
|
|
335
374
|
}
|
|
336
375
|
_dumpDebugInfoJSON() {
|
|
@@ -338,7 +377,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
338
377
|
layout: this.keyboardLayoutService.getCurrentKeyboardLayout(),
|
|
339
378
|
rawMapping: this.keyboardLayoutService.getRawKeyboardMapping()
|
|
340
379
|
};
|
|
341
|
-
return JSON.stringify(info, null,
|
|
380
|
+
return JSON.stringify(info, null, "\t");
|
|
342
381
|
}
|
|
343
382
|
enableKeybindingHoldMode(commandId) {
|
|
344
383
|
if (this._currentlyDispatchingCommandId !== commandId) {
|
|
@@ -374,7 +413,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
374
413
|
if (!this._cachedResolver) {
|
|
375
414
|
const defaults = this._resolveKeybindingItems(KeybindingsRegistry.getDefaultKeybindings(), true);
|
|
376
415
|
const overrides = this.getUserKeybindingItems();
|
|
377
|
-
this._cachedResolver = ( new KeybindingResolver(defaults, overrides,
|
|
416
|
+
this._cachedResolver = ( new KeybindingResolver(defaults, overrides, str => this._log(str)));
|
|
378
417
|
}
|
|
379
418
|
return this._cachedResolver;
|
|
380
419
|
}
|
|
@@ -397,8 +436,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
397
436
|
item.extensionId,
|
|
398
437
|
item.isBuiltinExtension
|
|
399
438
|
));
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
439
|
+
} else {
|
|
402
440
|
if (this._assertBrowserConflicts(keybinding)) {
|
|
403
441
|
continue;
|
|
404
442
|
}
|
|
@@ -426,8 +464,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
426
464
|
const when = item.when || undefined;
|
|
427
465
|
if (!item.keybinding) {
|
|
428
466
|
result[resultLen++] = ( new ResolvedKeybindingItem(undefined, item.command, item.commandArgs, when, isDefault, null, false));
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
467
|
+
} else {
|
|
431
468
|
const resolvedKeybindings = this._keyboardMapper.resolveKeybinding(item.keybinding);
|
|
432
469
|
for (const resolvedKeybinding of resolvedKeybindings) {
|
|
433
470
|
result[resultLen++] = ( new ResolvedKeybindingItem(
|
|
@@ -504,8 +541,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
504
541
|
for (let i = 0, len = keybindings.length; i < len; i++) {
|
|
505
542
|
this._handleKeybinding(extensionId, isBuiltin, i + 1, keybindings[i], collector, result);
|
|
506
543
|
}
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
544
|
+
} else {
|
|
509
545
|
this._handleKeybinding(extensionId, isBuiltin, 1, keybindings, collector, result);
|
|
510
546
|
}
|
|
511
547
|
}
|
|
@@ -519,10 +555,10 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
519
555
|
}
|
|
520
556
|
if (rejects.length > 0) {
|
|
521
557
|
collector.error(( localize(
|
|
522
|
-
|
|
558
|
+
14516,
|
|
523
559
|
"Invalid `contributes.{0}`: {1}",
|
|
524
560
|
keybindingsExtPoint.name,
|
|
525
|
-
rejects.join(
|
|
561
|
+
rejects.join("\n")
|
|
526
562
|
)));
|
|
527
563
|
}
|
|
528
564
|
}
|
|
@@ -531,13 +567,11 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
531
567
|
if (win) {
|
|
532
568
|
return win;
|
|
533
569
|
}
|
|
534
|
-
}
|
|
535
|
-
else if (OS === OperatingSystem.Macintosh) {
|
|
570
|
+
} else if (OS === OperatingSystem.Macintosh) {
|
|
536
571
|
if (mac) {
|
|
537
572
|
return mac;
|
|
538
573
|
}
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
574
|
+
} else {
|
|
541
575
|
if (linux) {
|
|
542
576
|
return linux;
|
|
543
577
|
}
|
|
@@ -545,7 +579,15 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
545
579
|
return key;
|
|
546
580
|
}
|
|
547
581
|
_asCommandRule(extensionId, isBuiltin, idx, binding) {
|
|
548
|
-
const {
|
|
582
|
+
const {
|
|
583
|
+
command,
|
|
584
|
+
args,
|
|
585
|
+
when,
|
|
586
|
+
key,
|
|
587
|
+
mac,
|
|
588
|
+
linux,
|
|
589
|
+
win
|
|
590
|
+
} = binding;
|
|
549
591
|
const keybinding = WorkbenchKeybindingService_1.bindToCurrentPlatform(key, mac, linux, win);
|
|
550
592
|
if (!keybinding) {
|
|
551
593
|
return undefined;
|
|
@@ -553,8 +595,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
553
595
|
let weight;
|
|
554
596
|
if (isBuiltin) {
|
|
555
597
|
weight = KeybindingWeight.BuiltinExtension + idx;
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
598
|
+
} else {
|
|
558
599
|
weight = KeybindingWeight.ExternalExtension + idx;
|
|
559
600
|
}
|
|
560
601
|
const commandAction = MenuRegistry.getCommand(command);
|
|
@@ -562,11 +603,9 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
562
603
|
let fullWhen;
|
|
563
604
|
if (when && precondition) {
|
|
564
605
|
fullWhen = ( ContextKeyExpr.and(precondition, ContextKeyExpr.deserialize(when)));
|
|
565
|
-
}
|
|
566
|
-
else if (when) {
|
|
606
|
+
} else if (when) {
|
|
567
607
|
fullWhen = ContextKeyExpr.deserialize(when);
|
|
568
|
-
}
|
|
569
|
-
else if (precondition) {
|
|
608
|
+
} else if (precondition) {
|
|
570
609
|
fullWhen = precondition;
|
|
571
610
|
}
|
|
572
611
|
const desc = {
|
|
@@ -584,30 +623,27 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
584
623
|
const resolver = this._getResolver();
|
|
585
624
|
const defaultKeybindings = resolver.getDefaultKeybindings();
|
|
586
625
|
const boundCommands = resolver.getDefaultBoundCommands();
|
|
587
|
-
return (WorkbenchKeybindingService_1._getDefaultKeybindings(defaultKeybindings)
|
|
588
|
-
+ '\n\n'
|
|
589
|
-
+ WorkbenchKeybindingService_1._getAllCommandsAsComment(boundCommands));
|
|
626
|
+
return (WorkbenchKeybindingService_1._getDefaultKeybindings(defaultKeybindings) + "\n\n" + WorkbenchKeybindingService_1._getAllCommandsAsComment(boundCommands));
|
|
590
627
|
}
|
|
591
628
|
static _getDefaultKeybindings(defaultKeybindings) {
|
|
592
629
|
const out = ( new OutputBuilder());
|
|
593
|
-
out.writeLine(
|
|
630
|
+
out.writeLine("[");
|
|
594
631
|
const lastIndex = defaultKeybindings.length - 1;
|
|
595
632
|
defaultKeybindings.forEach((k, index) => {
|
|
596
633
|
KeybindingIO.writeKeybindingItem(out, k);
|
|
597
634
|
if (index !== lastIndex) {
|
|
598
|
-
out.writeLine(
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
635
|
+
out.writeLine(",");
|
|
636
|
+
} else {
|
|
601
637
|
out.writeLine();
|
|
602
638
|
}
|
|
603
639
|
});
|
|
604
|
-
out.writeLine(
|
|
640
|
+
out.writeLine("]");
|
|
605
641
|
return ( out.toString());
|
|
606
642
|
}
|
|
607
643
|
static _getAllCommandsAsComment(boundCommands) {
|
|
608
644
|
const unboundCommands = getAllUnboundCommands(boundCommands);
|
|
609
|
-
const pretty = unboundCommands.sort().join(
|
|
610
|
-
return
|
|
645
|
+
const pretty = unboundCommands.sort().join("\n// - ");
|
|
646
|
+
return "// " + ( localize(14517, "Here are other available commands: ")) + "\n// - " + pretty;
|
|
611
647
|
}
|
|
612
648
|
mightProducePrintableCharacter(event) {
|
|
613
649
|
if (event.ctrlKey || event.metaKey || event.altKey) {
|
|
@@ -641,21 +677,11 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
|
|
|
641
677
|
return true;
|
|
642
678
|
}
|
|
643
679
|
};
|
|
644
|
-
WorkbenchKeybindingService = WorkbenchKeybindingService_1 = ( __decorate([
|
|
645
|
-
( __param(0, IContextKeyService)),
|
|
646
|
-
( __param(1, ICommandService)),
|
|
647
|
-
( __param(2, ITelemetryService)),
|
|
648
|
-
( __param(3, INotificationService)),
|
|
649
|
-
( __param(4, IUserDataProfileService)),
|
|
650
|
-
( __param(5, IHostService)),
|
|
651
|
-
( __param(6, IExtensionService)),
|
|
652
|
-
( __param(7, IFileService)),
|
|
653
|
-
( __param(8, IUriIdentityService)),
|
|
654
|
-
( __param(9, ILogService)),
|
|
655
|
-
( __param(10, IKeyboardLayoutService))
|
|
656
|
-
], WorkbenchKeybindingService));
|
|
680
|
+
WorkbenchKeybindingService = WorkbenchKeybindingService_1 = ( __decorate([( __param(0, IContextKeyService)), ( __param(1, ICommandService)), ( __param(2, ITelemetryService)), ( __param(3, INotificationService)), ( __param(4, IUserDataProfileService)), ( __param(5, IHostService)), ( __param(6, IExtensionService)), ( __param(7, IFileService)), ( __param(8, IUriIdentityService)), ( __param(9, ILogService)), ( __param(10, IKeyboardLayoutService))], WorkbenchKeybindingService));
|
|
657
681
|
class UserKeybindings extends Disposable {
|
|
658
|
-
get keybindings() {
|
|
682
|
+
get keybindings() {
|
|
683
|
+
return this._keybindings;
|
|
684
|
+
}
|
|
659
685
|
constructor(userDataProfileService, uriIdentityService, fileService, logService) {
|
|
660
686
|
super();
|
|
661
687
|
this.userDataProfileService = userDataProfileService;
|
|
@@ -672,13 +698,16 @@ class UserKeybindings extends Disposable {
|
|
|
672
698
|
this._onDidChange.fire();
|
|
673
699
|
}
|
|
674
700
|
}), 50)));
|
|
675
|
-
this._register(Event.filter(
|
|
676
|
-
|
|
701
|
+
this._register(Event.filter(
|
|
702
|
+
this.fileService.onDidFilesChange,
|
|
703
|
+
e => e.contains(this.userDataProfileService.currentProfile.keybindingsResource)
|
|
704
|
+
)(() => {
|
|
705
|
+
logService.debug("Keybindings file changed");
|
|
677
706
|
this.reloadConfigurationScheduler.schedule();
|
|
678
707
|
}));
|
|
679
|
-
this._register(this.fileService.onDidRunOperation(
|
|
708
|
+
this._register(this.fileService.onDidRunOperation(e => {
|
|
680
709
|
if (e.operation === FileOperation.WRITE && ( e.resource.toString()) === ( this.userDataProfileService.currentProfile.keybindingsResource.toString())) {
|
|
681
|
-
logService.debug(
|
|
710
|
+
logService.debug("Keybindings file written");
|
|
682
711
|
this.reloadConfigurationScheduler.schedule();
|
|
683
712
|
}
|
|
684
713
|
}));
|
|
@@ -694,8 +723,12 @@ class UserKeybindings extends Disposable {
|
|
|
694
723
|
}
|
|
695
724
|
watch() {
|
|
696
725
|
this.watchDisposables.clear();
|
|
697
|
-
this.watchDisposables.add(
|
|
698
|
-
|
|
726
|
+
this.watchDisposables.add(
|
|
727
|
+
this.fileService.watch(dirname(this.userDataProfileService.currentProfile.keybindingsResource))
|
|
728
|
+
);
|
|
729
|
+
this.watchDisposables.add(
|
|
730
|
+
this.fileService.watch(this.userDataProfileService.currentProfile.keybindingsResource)
|
|
731
|
+
);
|
|
699
732
|
}
|
|
700
733
|
async initialize() {
|
|
701
734
|
await this.reload();
|
|
@@ -706,24 +739,25 @@ class UserKeybindings extends Disposable {
|
|
|
706
739
|
return false;
|
|
707
740
|
}
|
|
708
741
|
this._rawKeybindings = newKeybindings;
|
|
709
|
-
this._keybindings = ( this._rawKeybindings.map(
|
|
742
|
+
this._keybindings = ( this._rawKeybindings.map(k => KeybindingIO.readUserKeybindingItem(k)));
|
|
710
743
|
return true;
|
|
711
744
|
}
|
|
712
745
|
async readUserKeybindings() {
|
|
713
746
|
try {
|
|
714
747
|
const content = await this.fileService.readFile(this.userDataProfileService.currentProfile.keybindingsResource);
|
|
715
748
|
const value = parse(( content.value.toString()));
|
|
716
|
-
return Array.isArray(value)
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
720
|
-
catch (e) {
|
|
749
|
+
return Array.isArray(value) ? value.filter(
|
|
750
|
+
v => v && typeof v === "object"
|
|
751
|
+
) : [];
|
|
752
|
+
} catch (e) {
|
|
721
753
|
return [];
|
|
722
754
|
}
|
|
723
755
|
}
|
|
724
756
|
}
|
|
725
757
|
class KeybindingsJsonSchema {
|
|
726
|
-
static {
|
|
758
|
+
static {
|
|
759
|
+
this.schemaId = "vscode://schemas/keybindings";
|
|
760
|
+
}
|
|
727
761
|
constructor() {
|
|
728
762
|
this.commandsSchemas = [];
|
|
729
763
|
this.commandsEnum = [];
|
|
@@ -731,96 +765,95 @@ class KeybindingsJsonSchema {
|
|
|
731
765
|
this.commandsEnumDescriptions = [];
|
|
732
766
|
this.schema = {
|
|
733
767
|
id: KeybindingsJsonSchema.schemaId,
|
|
734
|
-
type:
|
|
735
|
-
title: ( localize(
|
|
768
|
+
type: "array",
|
|
769
|
+
title: ( localize(14518, "Keybindings configuration")),
|
|
736
770
|
allowTrailingCommas: true,
|
|
737
771
|
allowComments: true,
|
|
738
772
|
definitions: {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
773
|
+
"editorGroupsSchema": {
|
|
774
|
+
"type": "array",
|
|
775
|
+
"items": {
|
|
776
|
+
"type": "object",
|
|
777
|
+
"properties": {
|
|
778
|
+
"groups": {
|
|
779
|
+
"$ref": "#/definitions/editorGroupsSchema",
|
|
780
|
+
"default": [{}, {}]
|
|
747
781
|
},
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
782
|
+
"size": {
|
|
783
|
+
"type": "number",
|
|
784
|
+
"default": 0.5
|
|
751
785
|
}
|
|
752
786
|
}
|
|
753
787
|
}
|
|
754
788
|
},
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
789
|
+
"commandNames": {
|
|
790
|
+
"type": "string",
|
|
791
|
+
"enum": this.commandsEnum,
|
|
792
|
+
"enumDescriptions": this.commandsEnumDescriptions,
|
|
793
|
+
"description": ( localize(14519, "Name of the command to execute"))
|
|
760
794
|
},
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
{
|
|
773
|
-
'type': 'string'
|
|
774
|
-
},
|
|
775
|
-
]
|
|
795
|
+
"commandType": {
|
|
796
|
+
"anyOf": [{
|
|
797
|
+
$ref: "#/definitions/commandNames"
|
|
798
|
+
}, {
|
|
799
|
+
"type": "string",
|
|
800
|
+
"enum": this.removalCommandsEnum,
|
|
801
|
+
"enumDescriptions": this.commandsEnumDescriptions,
|
|
802
|
+
"description": ( localize(14520, "Name of the command to remove keyboard shortcut for"))
|
|
803
|
+
}, {
|
|
804
|
+
"type": "string"
|
|
805
|
+
}]
|
|
776
806
|
},
|
|
777
|
-
|
|
778
|
-
|
|
807
|
+
"commandsSchemas": {
|
|
808
|
+
"allOf": this.commandsSchemas
|
|
779
809
|
}
|
|
780
810
|
},
|
|
781
811
|
items: {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
812
|
+
"required": ["key"],
|
|
813
|
+
"type": "object",
|
|
814
|
+
"defaultSnippets": [{
|
|
815
|
+
"body": {
|
|
816
|
+
"key": "$1",
|
|
817
|
+
"command": "$2",
|
|
818
|
+
"when": "$3"
|
|
819
|
+
}
|
|
820
|
+
}],
|
|
821
|
+
"properties": {
|
|
822
|
+
"key": {
|
|
823
|
+
"type": "string",
|
|
824
|
+
"description": ( localize(14521, "Key or key sequence (separated by space)"))
|
|
789
825
|
},
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
{
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
'type': 'array'
|
|
799
|
-
},
|
|
800
|
-
'errorMessage': ( localize(
|
|
801
|
-
14133,
|
|
802
|
-
"Incorrect type. Expected \"{0}\". The field 'command' does not support running multiple commands. Use command 'runCommands' to pass it multiple commands to run.",
|
|
803
|
-
'string'
|
|
804
|
-
))
|
|
826
|
+
"command": {
|
|
827
|
+
"anyOf": [{
|
|
828
|
+
"if": {
|
|
829
|
+
"type": "array"
|
|
830
|
+
},
|
|
831
|
+
"then": {
|
|
832
|
+
"not": {
|
|
833
|
+
"type": "array"
|
|
805
834
|
},
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
835
|
+
"errorMessage": ( localize(
|
|
836
|
+
14522,
|
|
837
|
+
"Incorrect type. Expected \"{0}\". The field 'command' does not support running multiple commands. Use command 'runCommands' to pass it multiple commands to run.",
|
|
838
|
+
"string"
|
|
839
|
+
))
|
|
809
840
|
},
|
|
810
|
-
{
|
|
811
|
-
|
|
841
|
+
"else": {
|
|
842
|
+
"$ref": "#/definitions/commandType"
|
|
812
843
|
}
|
|
813
|
-
|
|
844
|
+
}, {
|
|
845
|
+
"$ref": "#/definitions/commandType"
|
|
846
|
+
}]
|
|
814
847
|
},
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
848
|
+
"when": {
|
|
849
|
+
"type": "string",
|
|
850
|
+
"description": ( localize(14523, "Condition when the key is active."))
|
|
818
851
|
},
|
|
819
|
-
|
|
820
|
-
|
|
852
|
+
"args": {
|
|
853
|
+
"description": ( localize(14524, "Arguments to pass to the command to execute."))
|
|
821
854
|
}
|
|
822
855
|
},
|
|
823
|
-
|
|
856
|
+
"$ref": "#/definitions/commandsSchemas"
|
|
824
857
|
}
|
|
825
858
|
};
|
|
826
859
|
this.schemaRegistry = ( Registry.as(Extensions.JSONContribution));
|
|
@@ -837,9 +870,10 @@ class KeybindingsJsonSchema {
|
|
|
837
870
|
if (!( knownCommands.has(commandId))) {
|
|
838
871
|
knownCommands.add(commandId);
|
|
839
872
|
this.commandsEnum.push(commandId);
|
|
840
|
-
this.commandsEnumDescriptions.push(
|
|
841
|
-
?
|
|
842
|
-
: (isLocalizedString(description) ? description.value : description)
|
|
873
|
+
this.commandsEnumDescriptions.push(
|
|
874
|
+
description === undefined ?
|
|
875
|
+
"" : (isLocalizedString(description) ? description.value : description)
|
|
876
|
+
);
|
|
843
877
|
this.removalCommandsEnum.push(`-${commandId}`);
|
|
844
878
|
}
|
|
845
879
|
}
|
|
@@ -847,25 +881,28 @@ class KeybindingsJsonSchema {
|
|
|
847
881
|
const allCommands = CommandsRegistry.getCommands();
|
|
848
882
|
for (const [commandId, command] of allCommands) {
|
|
849
883
|
const commandMetadata = command.metadata;
|
|
850
|
-
addKnownCommand(
|
|
884
|
+
addKnownCommand(
|
|
885
|
+
commandId,
|
|
886
|
+
commandMetadata?.description ?? MenuRegistry.getCommand(commandId)?.title
|
|
887
|
+
);
|
|
851
888
|
if (!commandMetadata || !commandMetadata.args || commandMetadata.args.length !== 1 || !commandMetadata.args[0].schema) {
|
|
852
889
|
continue;
|
|
853
890
|
}
|
|
854
891
|
const argsSchema = commandMetadata.args[0].schema;
|
|
855
|
-
const argsRequired = ((typeof commandMetadata.args[0].isOptional !==
|
|
856
|
-
? (!commandMetadata.args[0].isOptional)
|
|
857
|
-
: (Array.isArray(argsSchema.required) && argsSchema.required.length > 0));
|
|
892
|
+
const argsRequired = ((typeof commandMetadata.args[0].isOptional !== "undefined") ? (!commandMetadata.args[0].isOptional) : (Array.isArray(argsSchema.required) && argsSchema.required.length > 0));
|
|
858
893
|
const addition = {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
894
|
+
"if": {
|
|
895
|
+
"required": ["command"],
|
|
896
|
+
"properties": {
|
|
897
|
+
"command": {
|
|
898
|
+
"const": commandId
|
|
899
|
+
}
|
|
863
900
|
}
|
|
864
901
|
},
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
902
|
+
"then": {
|
|
903
|
+
"required": [].concat(argsRequired ? ["args"] : []),
|
|
904
|
+
"properties": {
|
|
905
|
+
"args": argsSchema
|
|
869
906
|
}
|
|
870
907
|
}
|
|
871
908
|
};
|