@codingame/monaco-vscode-keybindings-service-override 18.3.1 → 19.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.
@@ -1,4 +1,5 @@
1
1
  import { Keybinding, ResolvedKeybinding } from "@codingame/monaco-vscode-api/vscode/vs/base/common/keybindings";
2
+ import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
3
  import { ICommandService } from "@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service";
3
4
  import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
4
5
  import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
@@ -14,11 +15,9 @@ import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/plat
14
15
  import { IExtensionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service";
15
16
  import { IHostService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service";
16
17
  import { IUserDataProfileService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service";
17
- import { ILayoutService } from "@codingame/monaco-vscode-api/vscode/vs/platform/layout/browser/layoutService.service";
18
18
  export declare class WorkbenchKeybindingService extends AbstractKeybindingService {
19
19
  private readonly hostService;
20
20
  private readonly keyboardLayoutService;
21
- private readonly layoutService;
22
21
  private _keyboardMapper;
23
22
  private _cachedResolver;
24
23
  private userKeybindings;
@@ -26,9 +25,10 @@ export declare class WorkbenchKeybindingService extends AbstractKeybindingServic
26
25
  private _keybindingHoldMode;
27
26
  private readonly _contributions;
28
27
  private readonly kbsJsonSchema;
29
- constructor(contextKeyService: IContextKeyService, commandService: ICommandService, telemetryService: ITelemetryService, notificationService: INotificationService, userDataProfileService: IUserDataProfileService, hostService: IHostService, extensionService: IExtensionService, fileService: IFileService, uriIdentityService: IUriIdentityService, logService: ILogService, keyboardLayoutService: IKeyboardLayoutService, layoutService: ILayoutService);
28
+ constructor(contextKeyService: IContextKeyService, commandService: ICommandService, telemetryService: ITelemetryService, notificationService: INotificationService, userDataProfileService: IUserDataProfileService, hostService: IHostService, extensionService: IExtensionService, fileService: IFileService, uriIdentityService: IUriIdentityService, logService: ILogService, keyboardLayoutService: IKeyboardLayoutService);
29
+ dispose(): void;
30
30
  private _registerKeyListeners;
31
- registerSchemaContribution(contribution: KeybindingsSchemaContribution): void;
31
+ registerSchemaContribution(contribution: KeybindingsSchemaContribution): IDisposable;
32
32
  private updateKeybindingsJsonSchema;
33
33
  private _printKeybinding;
34
34
  private _printResolvedKeybinding;
@@ -5,6 +5,7 @@ import { onDidChangeFullscreen, isFullscreen } from '@codingame/monaco-vscode-ap
5
5
  import { BrowserFeatures, KeyboardSupport } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/canIUse';
6
6
  import { onDidRegisterWindow, addDisposableListener, EventType, trackFocus, getWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
7
7
  import { StandardKeyboardEvent, printKeyboardEvent, printStandardKeyboardEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/keyboardEvent';
8
+ import { mainWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/window';
8
9
  import { DeferredPromise, RunOnceScheduler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
9
10
  import { Event, Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
10
11
  import { parse } from '@codingame/monaco-vscode-api/vscode/vs/base/common/json';
@@ -12,11 +13,11 @@ import { UserSettingsLabelProvider } from '@codingame/monaco-vscode-api/vscode/v
12
13
  import { KeybindingParser } from '@codingame/monaco-vscode-2a22c7b4-b906-5914-8cd1-3ed912fb738f-common/vscode/vs/base/common/keybindingParser';
13
14
  import { KeyCodeChord, ScanCodeChord } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keybindings';
14
15
  import { ScanCode, KeyCode, KeyCodeUtils, ScanCodeUtils, KeyMod, IMMUTABLE_CODE_TO_KEY_CODE } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
15
- import { DisposableStore, Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
16
+ import { DisposableStore, toDisposable, Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
16
17
  import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
17
18
  import { OS, OperatingSystem, isMacintosh } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
18
19
  import { dirname } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
19
- import { mainWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/window';
20
+ import { isLocalizedString } from '@codingame/monaco-vscode-api/vscode/vs/platform/action/common/action';
20
21
  import { MenuRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
21
22
  import { CommandsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands';
22
23
  import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
@@ -37,52 +38,51 @@ import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/pla
37
38
  import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
38
39
  import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
39
40
  import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
40
- import { isLocalizedString } from '@codingame/monaco-vscode-api/vscode/vs/platform/action/common/action';
41
+ import { remove } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
41
42
  import { commandsExtensionPoint } from '../../actions/common/menusExtensionPoint.js';
42
43
  import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
43
44
  import { ExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
44
45
  import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
45
- import { getAllUnboundCommands } from '@codingame/monaco-vscode-d609a7d3-bf87-551a-884f-550a8b327ec5-common/vscode/vs/workbench/services/keybinding/browser/unboundCommands';
46
- import { OutputBuilder, KeybindingIO } from '../common/keybindingIO.js';
47
46
  import { IUserDataProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
48
- import { ILayoutService } from '@codingame/monaco-vscode-api/vscode/vs/platform/layout/browser/layoutService.service';
47
+ import { OutputBuilder, KeybindingIO } from '../common/keybindingIO.js';
48
+ import { getAllUnboundCommands } from '@codingame/monaco-vscode-d609a7d3-bf87-551a-884f-550a8b327ec5-common/vscode/vs/workbench/services/keybinding/browser/unboundCommands';
49
49
 
50
50
  var WorkbenchKeybindingService_1;
51
51
  function isValidContributedKeyBinding(keyBinding, rejects) {
52
52
  if (!keyBinding) {
53
- rejects.push(( localize(12708, "expected non-empty value.")));
53
+ rejects.push(( localize(12983, "expected non-empty value.")));
54
54
  return false;
55
55
  }
56
56
  if (typeof keyBinding.command !== 'string') {
57
57
  rejects.push(( localize(
58
- 12709,
58
+ 12984,
59
59
  "property `{0}` is mandatory and must be of type `string`",
60
60
  'command'
61
61
  )));
62
62
  return false;
63
63
  }
64
64
  if (keyBinding.key && typeof keyBinding.key !== 'string') {
65
- rejects.push(( localize(12710, "property `{0}` can be omitted or must be of type `string`", 'key')));
65
+ rejects.push(( localize(12985, "property `{0}` can be omitted or must be of type `string`", 'key')));
66
66
  return false;
67
67
  }
68
68
  if (keyBinding.when && typeof keyBinding.when !== 'string') {
69
- rejects.push(( localize(12710, "property `{0}` can be omitted or must be of type `string`", 'when')));
69
+ rejects.push(( localize(12985, "property `{0}` can be omitted or must be of type `string`", 'when')));
70
70
  return false;
71
71
  }
72
72
  if (keyBinding.mac && typeof keyBinding.mac !== 'string') {
73
- rejects.push(( localize(12710, "property `{0}` can be omitted or must be of type `string`", 'mac')));
73
+ rejects.push(( localize(12985, "property `{0}` can be omitted or must be of type `string`", 'mac')));
74
74
  return false;
75
75
  }
76
76
  if (keyBinding.linux && typeof keyBinding.linux !== 'string') {
77
77
  rejects.push(( localize(
78
- 12710,
78
+ 12985,
79
79
  "property `{0}` can be omitted or must be of type `string`",
80
80
  'linux'
81
81
  )));
82
82
  return false;
83
83
  }
84
84
  if (keyBinding.win && typeof keyBinding.win !== 'string') {
85
- rejects.push(( localize(12710, "property `{0}` can be omitted or must be of type `string`", 'win')));
85
+ rejects.push(( localize(12985, "property `{0}` can be omitted or must be of type `string`", 'win')));
86
86
  return false;
87
87
  }
88
88
  return true;
@@ -92,33 +92,33 @@ const keybindingType = {
92
92
  default: { command: '', key: '' },
93
93
  properties: {
94
94
  command: {
95
- description: ( localize(12711, 'Identifier of the command to run when keybinding is triggered.')),
95
+ description: ( localize(12986, 'Identifier of the command to run when keybinding is triggered.')),
96
96
  type: 'string'
97
97
  },
98
98
  args: {
99
- description: ( localize(12712, "Arguments to pass to the command to execute."))
99
+ description: ( localize(12987, "Arguments to pass to the command to execute."))
100
100
  },
101
101
  key: {
102
102
  description: ( localize(
103
- 12713,
103
+ 12988,
104
104
  'Key or key sequence (separate keys with plus-sign and sequences with space, e.g. Ctrl+O and Ctrl+L L for a chord).'
105
105
  )),
106
106
  type: 'string'
107
107
  },
108
108
  mac: {
109
- description: ( localize(12714, 'Mac specific key or key sequence.')),
109
+ description: ( localize(12989, 'Mac specific key or key sequence.')),
110
110
  type: 'string'
111
111
  },
112
112
  linux: {
113
- description: ( localize(12715, 'Linux specific key or key sequence.')),
113
+ description: ( localize(12990, 'Linux specific key or key sequence.')),
114
114
  type: 'string'
115
115
  },
116
116
  win: {
117
- description: ( localize(12716, 'Windows specific key or key sequence.')),
117
+ description: ( localize(12991, 'Windows specific key or key sequence.')),
118
118
  type: 'string'
119
119
  },
120
120
  when: {
121
- description: ( localize(12717, 'Condition when the key is active.')),
121
+ description: ( localize(12992, 'Condition when the key is active.')),
122
122
  type: 'string'
123
123
  },
124
124
  }
@@ -127,7 +127,7 @@ const keybindingsExtPoint = ExtensionsRegistry.registerExtensionPoint({
127
127
  extensionPoint: 'keybindings',
128
128
  deps: [commandsExtensionPoint],
129
129
  jsonSchema: {
130
- description: ( localize(12718, "Contributes keybindings.")),
130
+ description: ( localize(12993, "Contributes keybindings.")),
131
131
  oneOf: [
132
132
  keybindingType,
133
133
  {
@@ -166,11 +166,10 @@ otherMacNumpadMapping.set(ScanCode.Numpad8, KeyCode.Digit8);
166
166
  otherMacNumpadMapping.set(ScanCode.Numpad9, KeyCode.Digit9);
167
167
  otherMacNumpadMapping.set(ScanCode.Numpad0, KeyCode.Digit0);
168
168
  let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchKeybindingService extends AbstractKeybindingService {
169
- constructor(contextKeyService, commandService, telemetryService, notificationService, userDataProfileService, hostService, extensionService, fileService, uriIdentityService, logService, keyboardLayoutService, layoutService) {
169
+ constructor(contextKeyService, commandService, telemetryService, notificationService, userDataProfileService, hostService, extensionService, fileService, uriIdentityService, logService, keyboardLayoutService) {
170
170
  super(contextKeyService, commandService, telemetryService, notificationService, logService);
171
171
  this.hostService = hostService;
172
172
  this.keyboardLayoutService = keyboardLayoutService;
173
- this.layoutService = layoutService;
174
173
  this._contributions = [];
175
174
  this.isComposingGlobalContextKey = contextKeyService.createKey('isComposing', false);
176
175
  this.kbsJsonSchema = ( new KeybindingsJsonSchema());
@@ -221,10 +220,14 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
221
220
  this._onDidUpdateKeybindings.fire();
222
221
  }));
223
222
  }
223
+ dispose() {
224
+ this._contributions.forEach(c => c.listener?.dispose());
225
+ this._contributions.length = 0;
226
+ super.dispose();
227
+ }
224
228
  _registerKeyListeners(window) {
225
229
  const disposables = ( new DisposableStore());
226
- const container = this.layoutService.getContainer(window);
227
- disposables.add(addDisposableListener(container, EventType.KEY_DOWN, (e) => {
230
+ disposables.add(addDisposableListener(window, EventType.KEY_DOWN, (e) => {
228
231
  if (this._keybindingHoldMode) {
229
232
  return;
230
233
  }
@@ -238,7 +241,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
238
241
  }
239
242
  this.isComposingGlobalContextKey.set(false);
240
243
  }));
241
- disposables.add(addDisposableListener(container, EventType.KEY_UP, (e) => {
244
+ disposables.add(addDisposableListener(window, EventType.KEY_UP, (e) => {
242
245
  this._resetKeybindingHoldMode();
243
246
  this.isComposingGlobalContextKey.set(e.isComposing);
244
247
  const keyEvent = ( new StandardKeyboardEvent(e));
@@ -251,14 +254,18 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
251
254
  return disposables;
252
255
  }
253
256
  registerSchemaContribution(contribution) {
254
- this._contributions.push(contribution);
255
- if (contribution.onDidChange) {
256
- this._register(contribution.onDidChange(() => this.updateKeybindingsJsonSchema()));
257
- }
257
+ const listener = contribution.onDidChange?.(() => this.updateKeybindingsJsonSchema());
258
+ const entry = { listener, contribution };
259
+ this._contributions.push(entry);
258
260
  this.updateKeybindingsJsonSchema();
261
+ return toDisposable(() => {
262
+ listener?.dispose();
263
+ remove(this._contributions, entry);
264
+ this.updateKeybindingsJsonSchema();
265
+ });
259
266
  }
260
267
  updateKeybindingsJsonSchema() {
261
- this.kbsJsonSchema.updateSchema(this._contributions.flatMap(x => x.getSchemaAdditions()));
268
+ this.kbsJsonSchema.updateSchema(this._contributions.flatMap(x => x.contribution.getSchemaAdditions()));
262
269
  }
263
270
  _printKeybinding(keybinding) {
264
271
  return UserSettingsLabelProvider.toLabel(OS, keybinding.chords, (chord) => {
@@ -508,7 +515,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
508
515
  }
509
516
  if (rejects.length > 0) {
510
517
  collector.error(( localize(
511
- 12719,
518
+ 12994,
512
519
  "Invalid `contributes.{0}`: {1}",
513
520
  keybindingsExtPoint.name,
514
521
  rejects.join('\n')
@@ -596,7 +603,7 @@ let WorkbenchKeybindingService = WorkbenchKeybindingService_1 = class WorkbenchK
596
603
  static _getAllCommandsAsComment(boundCommands) {
597
604
  const unboundCommands = getAllUnboundCommands(boundCommands);
598
605
  const pretty = unboundCommands.sort().join('\n// - ');
599
- return '// ' + ( localize(12720, "Here are other available commands: ")) + '\n// - ' + pretty;
606
+ return '// ' + ( localize(12995, "Here are other available commands: ")) + '\n// - ' + pretty;
600
607
  }
601
608
  mightProducePrintableCharacter(event) {
602
609
  if (event.ctrlKey || event.metaKey || event.altKey) {
@@ -641,8 +648,7 @@ WorkbenchKeybindingService = WorkbenchKeybindingService_1 = ( __decorate([
641
648
  ( __param(7, IFileService)),
642
649
  ( __param(8, IUriIdentityService)),
643
650
  ( __param(9, ILogService)),
644
- ( __param(10, IKeyboardLayoutService)),
645
- ( __param(11, ILayoutService))
651
+ ( __param(10, IKeyboardLayoutService))
646
652
  ], WorkbenchKeybindingService));
647
653
  class UserKeybindings extends Disposable {
648
654
  get keybindings() { return this._keybindings; }
@@ -722,7 +728,7 @@ class KeybindingsJsonSchema {
722
728
  this.schema = {
723
729
  id: KeybindingsJsonSchema.schemaId,
724
730
  type: 'array',
725
- title: ( localize(12721, "Keybindings configuration")),
731
+ title: ( localize(12996, "Keybindings configuration")),
726
732
  allowTrailingCommas: true,
727
733
  allowComments: true,
728
734
  definitions: {
@@ -746,7 +752,7 @@ class KeybindingsJsonSchema {
746
752
  'type': 'string',
747
753
  'enum': this.commandsEnum,
748
754
  'enumDescriptions': this.commandsEnumDescriptions,
749
- 'description': ( localize(12722, "Name of the command to execute")),
755
+ 'description': ( localize(12997, "Name of the command to execute")),
750
756
  },
751
757
  'commandType': {
752
758
  'anyOf': [
@@ -757,7 +763,7 @@ class KeybindingsJsonSchema {
757
763
  'type': 'string',
758
764
  'enum': this.removalCommandsEnum,
759
765
  'enumDescriptions': this.commandsEnumDescriptions,
760
- 'description': ( localize(12723, "Name of the command to remove keyboard shortcut for")),
766
+ 'description': ( localize(12998, "Name of the command to remove keyboard shortcut for")),
761
767
  },
762
768
  {
763
769
  'type': 'string'
@@ -775,7 +781,7 @@ class KeybindingsJsonSchema {
775
781
  'properties': {
776
782
  'key': {
777
783
  'type': 'string',
778
- 'description': ( localize(12724, "Key or key sequence (separated by space)")),
784
+ 'description': ( localize(12999, "Key or key sequence (separated by space)")),
779
785
  },
780
786
  'command': {
781
787
  'anyOf': [
@@ -788,7 +794,7 @@ class KeybindingsJsonSchema {
788
794
  'type': 'array'
789
795
  },
790
796
  'errorMessage': ( localize(
791
- 12725,
797
+ 13000,
792
798
  "Incorrect type. Expected \"{0}\". The field 'command' does not support running multiple commands. Use command 'runCommands' to pass it multiple commands to run.",
793
799
  'string'
794
800
  ))
@@ -804,10 +810,10 @@ class KeybindingsJsonSchema {
804
810
  },
805
811
  'when': {
806
812
  'type': 'string',
807
- 'description': ( localize(12726, "Condition when the key is active."))
813
+ 'description': ( localize(13001, "Condition when the key is active."))
808
814
  },
809
815
  'args': {
810
- 'description': ( localize(12727, "Arguments to pass to the command to execute."))
816
+ 'description': ( localize(13002, "Arguments to pass to the command to execute."))
811
817
  }
812
818
  },
813
819
  '$ref': '#/definitions/commandsSchemas'
@@ -483,12 +483,12 @@ const keyboardConfiguration = {
483
483
  'id': 'keyboard',
484
484
  'order': 15,
485
485
  'type': 'object',
486
- 'title': ( localize(12728, "Keyboard")),
486
+ 'title': ( localize(13003, "Keyboard")),
487
487
  'properties': {
488
488
  'keyboard.layout': {
489
489
  'type': 'string',
490
490
  'default': 'autodetect',
491
- 'description': ( localize(12729, "Control the keyboard layout used in web."))
491
+ 'description': ( localize(13004, "Control the keyboard layout used in web."))
492
492
  }
493
493
  }
494
494
  };