@codingame/monaco-vscode-keybindings-service-override 1.85.0 → 1.85.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/keybindings.js +1 -0
- package/package.json +3 -3
- package/vscode/src/vs/workbench/contrib/commands/common/commands.contribution.js +146 -0
- package/vscode/src/vs/workbench/services/keybinding/browser/keybindingService.js +2 -2
- package/vscode/src/vs/workbench/services/keybinding/browser/keyboardLayoutService.js +2 -2
package/keybindings.js
CHANGED
|
@@ -27,6 +27,7 @@ import getServiceOverride$1, { initFile } from '@codingame/monaco-vscode-files-s
|
|
|
27
27
|
import { onRenderWorkbench } from 'vscode/lifecycle';
|
|
28
28
|
import 'vscode/vscode/vs/workbench/browser/workbench.contribution';
|
|
29
29
|
import './vscode/src/vs/workbench/contrib/keybindings/browser/keybindings.contribution.js';
|
|
30
|
+
import './vscode/src/vs/workbench/contrib/commands/common/commands.contribution.js';
|
|
30
31
|
|
|
31
32
|
const defaultUserKeybindindsFile = ( URI.from({ scheme: Schemas.vscodeUserData, path: '/User/keybindings.json' }));
|
|
32
33
|
async function initUserKeybindings(configurationJson, options, file = defaultUserKeybindindsFile) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-keybindings-service-override",
|
|
3
|
-
"version": "1.85.
|
|
3
|
+
"version": "1.85.2",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@1.85.
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@1.85.2",
|
|
22
22
|
"monaco-editor": "0.45.0",
|
|
23
|
-
"@codingame/monaco-vscode-files-service-override": "1.85.
|
|
23
|
+
"@codingame/monaco-vscode-files-service-override": "1.85.2"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
2
|
+
import { registerAction2, Action2 } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
3
|
+
import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
4
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
5
|
+
import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
6
|
+
|
|
7
|
+
class RunCommands extends Action2 {
|
|
8
|
+
constructor() {
|
|
9
|
+
super({
|
|
10
|
+
id: 'runCommands',
|
|
11
|
+
title: { value: ( nls.localizeWithPath(
|
|
12
|
+
'vs/workbench/contrib/commands/common/commands.contribution',
|
|
13
|
+
'runCommands',
|
|
14
|
+
"Run Commands"
|
|
15
|
+
)), original: 'Run Commands' },
|
|
16
|
+
f1: false,
|
|
17
|
+
metadata: {
|
|
18
|
+
description: ( nls.localizeWithPath(
|
|
19
|
+
'vs/workbench/contrib/commands/common/commands.contribution',
|
|
20
|
+
'runCommands.description',
|
|
21
|
+
"Run several commands"
|
|
22
|
+
)),
|
|
23
|
+
args: [
|
|
24
|
+
{
|
|
25
|
+
name: 'args',
|
|
26
|
+
schema: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
required: ['commands'],
|
|
29
|
+
properties: {
|
|
30
|
+
commands: {
|
|
31
|
+
type: 'array',
|
|
32
|
+
description: ( nls.localizeWithPath(
|
|
33
|
+
'vs/workbench/contrib/commands/common/commands.contribution',
|
|
34
|
+
'runCommands.commands',
|
|
35
|
+
"Commands to run"
|
|
36
|
+
)),
|
|
37
|
+
items: {
|
|
38
|
+
anyOf: [
|
|
39
|
+
{
|
|
40
|
+
$ref: 'vscode://schemas/keybindings#/definitions/commandNames'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'string',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: 'object',
|
|
47
|
+
required: ['command'],
|
|
48
|
+
properties: {
|
|
49
|
+
command: {
|
|
50
|
+
'anyOf': [
|
|
51
|
+
{
|
|
52
|
+
$ref: 'vscode://schemas/keybindings#/definitions/commandNames'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'string'
|
|
56
|
+
},
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
$ref: 'vscode://schemas/keybindings#/definitions/commandsSchemas'
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async run(accessor, args) {
|
|
73
|
+
const notificationService = accessor.get(INotificationService);
|
|
74
|
+
if (!this._isCommandArgs(args)) {
|
|
75
|
+
notificationService.error(( nls.localizeWithPath(
|
|
76
|
+
'vs/workbench/contrib/commands/common/commands.contribution',
|
|
77
|
+
'runCommands.invalidArgs',
|
|
78
|
+
"'runCommands' has received an argument with incorrect type. Please, review the argument passed to the command."
|
|
79
|
+
)));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (args.commands.length === 0) {
|
|
83
|
+
notificationService.warn(( nls.localizeWithPath(
|
|
84
|
+
'vs/workbench/contrib/commands/common/commands.contribution',
|
|
85
|
+
'runCommands.noCommandsToRun',
|
|
86
|
+
"'runCommands' has not received commands to run. Did you forget to pass commands in the 'runCommands' argument?"
|
|
87
|
+
)));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const commandService = accessor.get(ICommandService);
|
|
91
|
+
const logService = accessor.get(ILogService);
|
|
92
|
+
let i = 0;
|
|
93
|
+
try {
|
|
94
|
+
for (; i < args.commands.length; ++i) {
|
|
95
|
+
const cmd = args.commands[i];
|
|
96
|
+
logService.debug(`runCommands: executing ${i}-th command: ${JSON.stringify(cmd)}`);
|
|
97
|
+
const r = await this._runCommand(commandService, cmd);
|
|
98
|
+
logService.debug(`runCommands: executed ${i}-th command with return value: ${JSON.stringify(r)}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
logService.debug(`runCommands: executing ${i}-th command resulted in an error: ${err instanceof Error ? err.message : JSON.stringify(err)}`);
|
|
103
|
+
notificationService.error(err);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
_isCommandArgs(args) {
|
|
107
|
+
if (!args || typeof args !== 'object') {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (!('commands' in args) || !Array.isArray(args.commands)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
for (const cmd of args.commands) {
|
|
114
|
+
if (typeof cmd === 'string') {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (typeof cmd === 'object' && typeof cmd.command === 'string') {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
_runCommand(commandService, cmd) {
|
|
125
|
+
let commandID, commandArgs;
|
|
126
|
+
if (typeof cmd === 'string') {
|
|
127
|
+
commandID = cmd;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
commandID = cmd.command;
|
|
131
|
+
commandArgs = cmd.args;
|
|
132
|
+
}
|
|
133
|
+
if (commandArgs === undefined) {
|
|
134
|
+
return commandService.executeCommand(commandID);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
if (Array.isArray(commandArgs)) {
|
|
138
|
+
return commandService.executeCommand(commandID, ...commandArgs);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return commandService.executeCommand(commandID, commandArgs);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
registerAction2(RunCommands);
|
|
@@ -12,7 +12,7 @@ import { KeybindingParser } from '../../../../base/common/keybindingParser.js';
|
|
|
12
12
|
import { KeyCodeChord, ScanCodeChord } from 'monaco-editor/esm/vs/base/common/keybindings.js';
|
|
13
13
|
import { KeyCodeUtils, ScanCodeUtils, IMMUTABLE_CODE_TO_KEY_CODE } from 'monaco-editor/esm/vs/base/common/keyCodes.js';
|
|
14
14
|
import { DisposableStore, Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
15
|
-
import * as
|
|
15
|
+
import * as Objects from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
16
16
|
import { OS, isMacintosh } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
17
17
|
import { dirname } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
18
18
|
import { mainWindow } from 'monaco-editor/esm/vs/base/browser/window.js';
|
|
@@ -714,7 +714,7 @@ class UserKeybindings extends Disposable {
|
|
|
714
714
|
}
|
|
715
715
|
async reload() {
|
|
716
716
|
const newKeybindings = await this.readUserKeybindings();
|
|
717
|
-
if (
|
|
717
|
+
if (Objects.equals(this._rawKeybindings, newKeybindings)) {
|
|
718
718
|
return false;
|
|
719
719
|
}
|
|
720
720
|
this._rawKeybindings = newKeybindings;
|
|
@@ -12,7 +12,7 @@ import { MacLinuxKeyboardMapper } from '../common/macLinuxKeyboardMapper.js';
|
|
|
12
12
|
import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
|
|
13
13
|
import { RunOnceScheduler } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
14
14
|
import { parse, getNodeType } from 'monaco-editor/esm/vs/base/common/json.js';
|
|
15
|
-
import * as
|
|
15
|
+
import * as Objects from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
16
16
|
import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
|
|
17
17
|
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
18
18
|
import { Extensions } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
@@ -378,7 +378,7 @@ class UserKeyboardLayout extends Disposable {
|
|
|
378
378
|
catch (e) {
|
|
379
379
|
this._keyboardLayout = null;
|
|
380
380
|
}
|
|
381
|
-
return existing ? !
|
|
381
|
+
return existing ? !Objects.equals(existing, this._keyboardLayout) : true;
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
384
|
let BrowserKeyboardLayoutService = class BrowserKeyboardLayoutService extends Disposable {
|