@lvce-editor/editor-worker 18.22.0 → 18.24.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/dist/editorWorkerMain.js +494 -557
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1,58 +1,122 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
if (line.startsWith('VError: ')) {
|
|
6
|
-
return line.slice('VError: '.length);
|
|
7
|
-
}
|
|
8
|
-
return line;
|
|
9
|
-
};
|
|
10
|
-
const getCombinedMessage = (error, message) => {
|
|
11
|
-
const stringifiedError = normalizeLine(`${error}`);
|
|
12
|
-
if (message) {
|
|
13
|
-
return `${message}: ${stringifiedError}`;
|
|
14
|
-
}
|
|
15
|
-
return stringifiedError;
|
|
1
|
+
const toCommandId = key => {
|
|
2
|
+
const dotIndex = key.indexOf('.');
|
|
3
|
+
return key.slice(dotIndex + 1);
|
|
16
4
|
};
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
5
|
+
const create$j = () => {
|
|
6
|
+
const states = Object.create(null);
|
|
7
|
+
const commandMapRef = {};
|
|
8
|
+
return {
|
|
9
|
+
clear() {
|
|
10
|
+
for (const key of Object.keys(states)) {
|
|
11
|
+
delete states[key];
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
diff(uid, modules, numbers) {
|
|
15
|
+
const {
|
|
16
|
+
newState,
|
|
17
|
+
oldState
|
|
18
|
+
} = states[uid];
|
|
19
|
+
const diffResult = [];
|
|
20
|
+
for (let i = 0; i < modules.length; i++) {
|
|
21
|
+
const fn = modules[i];
|
|
22
|
+
if (!fn(oldState, newState)) {
|
|
23
|
+
diffResult.push(numbers[i]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return diffResult;
|
|
27
|
+
},
|
|
28
|
+
dispose(uid) {
|
|
29
|
+
delete states[uid];
|
|
30
|
+
},
|
|
31
|
+
get(uid) {
|
|
32
|
+
return states[uid];
|
|
33
|
+
},
|
|
34
|
+
getCommandIds() {
|
|
35
|
+
const keys = Object.keys(commandMapRef);
|
|
36
|
+
const ids = keys.map(toCommandId);
|
|
37
|
+
return ids;
|
|
38
|
+
},
|
|
39
|
+
getKeys() {
|
|
40
|
+
return Object.keys(states).map(key => {
|
|
41
|
+
return Number.parseFloat(key);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
registerCommands(commandMap) {
|
|
45
|
+
Object.assign(commandMapRef, commandMap);
|
|
46
|
+
},
|
|
47
|
+
set(uid, oldState, newState) {
|
|
48
|
+
states[uid] = {
|
|
49
|
+
newState,
|
|
50
|
+
oldState
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
wrapCommand(fn) {
|
|
54
|
+
const wrapped = async (uid, ...args) => {
|
|
55
|
+
const {
|
|
56
|
+
newState,
|
|
57
|
+
oldState
|
|
58
|
+
} = states[uid];
|
|
59
|
+
const newerState = await fn(newState, ...args);
|
|
60
|
+
if (oldState === newerState || newState === newerState) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const latestOld = states[uid];
|
|
64
|
+
const latestNew = {
|
|
65
|
+
...latestOld.newState,
|
|
66
|
+
...newerState
|
|
67
|
+
};
|
|
68
|
+
states[uid] = {
|
|
69
|
+
newState: latestNew,
|
|
70
|
+
oldState: latestOld.oldState
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
return wrapped;
|
|
74
|
+
},
|
|
75
|
+
wrapGetter(fn) {
|
|
76
|
+
const wrapped = (uid, ...args) => {
|
|
77
|
+
const {
|
|
78
|
+
newState
|
|
79
|
+
} = states[uid];
|
|
80
|
+
return fn(newState, ...args);
|
|
81
|
+
};
|
|
82
|
+
return wrapped;
|
|
83
|
+
},
|
|
84
|
+
wrapLoadContent(fn) {
|
|
85
|
+
const wrapped = async (uid, ...args) => {
|
|
86
|
+
const {
|
|
87
|
+
newState,
|
|
88
|
+
oldState
|
|
89
|
+
} = states[uid];
|
|
90
|
+
const result = await fn(newState, ...args);
|
|
91
|
+
const {
|
|
92
|
+
error,
|
|
93
|
+
state
|
|
94
|
+
} = result;
|
|
95
|
+
if (oldState === state || newState === state) {
|
|
96
|
+
return {
|
|
97
|
+
error
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const latestOld = states[uid];
|
|
101
|
+
const latestNew = {
|
|
102
|
+
...latestOld.newState,
|
|
103
|
+
...state
|
|
104
|
+
};
|
|
105
|
+
states[uid] = {
|
|
106
|
+
newState: latestNew,
|
|
107
|
+
oldState: latestOld.oldState
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
error
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
return wrapped;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
20
116
|
};
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
return parent;
|
|
24
|
-
}
|
|
25
|
-
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
26
|
-
const childNewLineIndex = getNewLineIndex$1(child);
|
|
27
|
-
if (childNewLineIndex === -1) {
|
|
28
|
-
return parent;
|
|
29
|
-
}
|
|
30
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
31
|
-
const childRest = child.slice(childNewLineIndex);
|
|
32
|
-
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
33
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
34
|
-
return parentFirstLine + childRest;
|
|
35
|
-
}
|
|
36
|
-
return child;
|
|
117
|
+
const terminate = () => {
|
|
118
|
+
globalThis.close();
|
|
37
119
|
};
|
|
38
|
-
class VError extends Error {
|
|
39
|
-
constructor(error, message) {
|
|
40
|
-
const combinedMessage = getCombinedMessage(error, message);
|
|
41
|
-
super(combinedMessage);
|
|
42
|
-
this.name = 'VError';
|
|
43
|
-
if (error instanceof Error) {
|
|
44
|
-
this.stack = mergeStacks(this.stack, error.stack);
|
|
45
|
-
}
|
|
46
|
-
if (error.codeFrame) {
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
this.codeFrame = error.codeFrame;
|
|
49
|
-
}
|
|
50
|
-
if (error.code) {
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
this.code = error.code;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
120
|
|
|
57
121
|
class AssertionError extends Error {
|
|
58
122
|
constructor(message) {
|
|
@@ -121,6 +185,62 @@ const boolean = value => {
|
|
|
121
185
|
}
|
|
122
186
|
};
|
|
123
187
|
|
|
188
|
+
const normalizeLine = line => {
|
|
189
|
+
if (line.startsWith('Error: ')) {
|
|
190
|
+
return line.slice('Error: '.length);
|
|
191
|
+
}
|
|
192
|
+
if (line.startsWith('VError: ')) {
|
|
193
|
+
return line.slice('VError: '.length);
|
|
194
|
+
}
|
|
195
|
+
return line;
|
|
196
|
+
};
|
|
197
|
+
const getCombinedMessage = (error, message) => {
|
|
198
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
199
|
+
if (message) {
|
|
200
|
+
return `${message}: ${stringifiedError}`;
|
|
201
|
+
}
|
|
202
|
+
return stringifiedError;
|
|
203
|
+
};
|
|
204
|
+
const NewLine$3 = '\n';
|
|
205
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
206
|
+
return string.indexOf(NewLine$3, startIndex);
|
|
207
|
+
};
|
|
208
|
+
const mergeStacks = (parent, child) => {
|
|
209
|
+
if (!child) {
|
|
210
|
+
return parent;
|
|
211
|
+
}
|
|
212
|
+
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
213
|
+
const childNewLineIndex = getNewLineIndex$1(child);
|
|
214
|
+
if (childNewLineIndex === -1) {
|
|
215
|
+
return parent;
|
|
216
|
+
}
|
|
217
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
218
|
+
const childRest = child.slice(childNewLineIndex);
|
|
219
|
+
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
220
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
221
|
+
return parentFirstLine + childRest;
|
|
222
|
+
}
|
|
223
|
+
return child;
|
|
224
|
+
};
|
|
225
|
+
class VError extends Error {
|
|
226
|
+
constructor(error, message) {
|
|
227
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
228
|
+
super(combinedMessage);
|
|
229
|
+
this.name = 'VError';
|
|
230
|
+
if (error instanceof Error) {
|
|
231
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
232
|
+
}
|
|
233
|
+
if (error.codeFrame) {
|
|
234
|
+
// @ts-ignore
|
|
235
|
+
this.codeFrame = error.codeFrame;
|
|
236
|
+
}
|
|
237
|
+
if (error.code) {
|
|
238
|
+
// @ts-ignore
|
|
239
|
+
this.code = error.code;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
124
244
|
const isMessagePort = value => {
|
|
125
245
|
return value && value instanceof MessagePort;
|
|
126
246
|
};
|
|
@@ -765,7 +885,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
765
885
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
766
886
|
return create$1$1(id, errorProperty);
|
|
767
887
|
};
|
|
768
|
-
const create$
|
|
888
|
+
const create$i = (message, result) => {
|
|
769
889
|
return {
|
|
770
890
|
id: message.id,
|
|
771
891
|
jsonrpc: Two$1,
|
|
@@ -774,7 +894,7 @@ const create$j = (message, result) => {
|
|
|
774
894
|
};
|
|
775
895
|
const getSuccessResponse = (message, result) => {
|
|
776
896
|
const resultProperty = result ?? null;
|
|
777
|
-
return create$
|
|
897
|
+
return create$i(message, resultProperty);
|
|
778
898
|
};
|
|
779
899
|
const getErrorResponseSimple = (id, error) => {
|
|
780
900
|
return {
|
|
@@ -868,7 +988,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
868
988
|
|
|
869
989
|
const Two = '2.0';
|
|
870
990
|
|
|
871
|
-
const create$
|
|
991
|
+
const create$h = (method, params) => {
|
|
872
992
|
return {
|
|
873
993
|
jsonrpc: Two,
|
|
874
994
|
method,
|
|
@@ -876,7 +996,7 @@ const create$i = (method, params) => {
|
|
|
876
996
|
};
|
|
877
997
|
};
|
|
878
998
|
|
|
879
|
-
const create$
|
|
999
|
+
const create$g = (id, method, params) => {
|
|
880
1000
|
const message = {
|
|
881
1001
|
id,
|
|
882
1002
|
jsonrpc: Two,
|
|
@@ -887,12 +1007,12 @@ const create$h = (id, method, params) => {
|
|
|
887
1007
|
};
|
|
888
1008
|
|
|
889
1009
|
let id = 0;
|
|
890
|
-
const create$
|
|
1010
|
+
const create$f = () => {
|
|
891
1011
|
return ++id;
|
|
892
1012
|
};
|
|
893
1013
|
|
|
894
1014
|
const registerPromise = map => {
|
|
895
|
-
const id = create$
|
|
1015
|
+
const id = create$f();
|
|
896
1016
|
const {
|
|
897
1017
|
promise,
|
|
898
1018
|
resolve
|
|
@@ -909,7 +1029,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
909
1029
|
id,
|
|
910
1030
|
promise
|
|
911
1031
|
} = registerPromise(callbacks);
|
|
912
|
-
const message = create$
|
|
1032
|
+
const message = create$g(id, method, params);
|
|
913
1033
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
914
1034
|
ipc.sendAndTransfer(message);
|
|
915
1035
|
} else {
|
|
@@ -945,7 +1065,7 @@ const createRpc = ipc => {
|
|
|
945
1065
|
* @deprecated
|
|
946
1066
|
*/
|
|
947
1067
|
send(method, ...params) {
|
|
948
|
-
const message = create$
|
|
1068
|
+
const message = create$h(method, params);
|
|
949
1069
|
ipc.send(message);
|
|
950
1070
|
}
|
|
951
1071
|
};
|
|
@@ -985,7 +1105,7 @@ const listen$1 = async (module, options) => {
|
|
|
985
1105
|
return ipc;
|
|
986
1106
|
};
|
|
987
1107
|
|
|
988
|
-
const create$
|
|
1108
|
+
const create$e = async ({
|
|
989
1109
|
commandMap,
|
|
990
1110
|
isMessagePortOpen = true,
|
|
991
1111
|
messagePort
|
|
@@ -1003,7 +1123,7 @@ const create$f = async ({
|
|
|
1003
1123
|
return rpc;
|
|
1004
1124
|
};
|
|
1005
1125
|
|
|
1006
|
-
const create$
|
|
1126
|
+
const create$d = async ({
|
|
1007
1127
|
commandMap,
|
|
1008
1128
|
isMessagePortOpen,
|
|
1009
1129
|
send
|
|
@@ -1013,7 +1133,7 @@ const create$e = async ({
|
|
|
1013
1133
|
port2
|
|
1014
1134
|
} = new MessageChannel();
|
|
1015
1135
|
await send(port1);
|
|
1016
|
-
return create$
|
|
1136
|
+
return create$e({
|
|
1017
1137
|
commandMap,
|
|
1018
1138
|
isMessagePortOpen,
|
|
1019
1139
|
messagePort: port2
|
|
@@ -1048,13 +1168,13 @@ const createSharedLazyRpc = factory => {
|
|
|
1048
1168
|
};
|
|
1049
1169
|
};
|
|
1050
1170
|
|
|
1051
|
-
const create$
|
|
1171
|
+
const create$c = async ({
|
|
1052
1172
|
commandMap,
|
|
1053
1173
|
isMessagePortOpen,
|
|
1054
1174
|
send
|
|
1055
1175
|
}) => {
|
|
1056
1176
|
return createSharedLazyRpc(() => {
|
|
1057
|
-
return create$
|
|
1177
|
+
return create$d({
|
|
1058
1178
|
commandMap,
|
|
1059
1179
|
isMessagePortOpen,
|
|
1060
1180
|
send
|
|
@@ -1062,17 +1182,17 @@ const create$d = async ({
|
|
|
1062
1182
|
});
|
|
1063
1183
|
};
|
|
1064
1184
|
|
|
1065
|
-
const create$
|
|
1185
|
+
const create$b = async ({
|
|
1066
1186
|
commandMap,
|
|
1067
1187
|
messagePort
|
|
1068
1188
|
}) => {
|
|
1069
|
-
return create$
|
|
1189
|
+
return create$e({
|
|
1070
1190
|
commandMap,
|
|
1071
1191
|
messagePort
|
|
1072
1192
|
});
|
|
1073
1193
|
};
|
|
1074
1194
|
|
|
1075
|
-
const create$
|
|
1195
|
+
const create$a = async ({
|
|
1076
1196
|
commandMap
|
|
1077
1197
|
}) => {
|
|
1078
1198
|
// TODO create a commandMap per rpc instance
|
|
@@ -1115,7 +1235,7 @@ const remove$8 = id => {
|
|
|
1115
1235
|
};
|
|
1116
1236
|
|
|
1117
1237
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1118
|
-
const create$
|
|
1238
|
+
const create$9 = rpcId => {
|
|
1119
1239
|
return {
|
|
1120
1240
|
async dispose() {
|
|
1121
1241
|
const rpc = get$7(rpcId);
|
|
@@ -1233,7 +1353,7 @@ const FocusEditorText$1 = 12;
|
|
|
1233
1353
|
const {
|
|
1234
1354
|
invoke: invoke$f,
|
|
1235
1355
|
set: set$d
|
|
1236
|
-
} = create$
|
|
1356
|
+
} = create$9(ExtensionHostWorker);
|
|
1237
1357
|
|
|
1238
1358
|
const ExtensionHost = {
|
|
1239
1359
|
__proto__: null,
|
|
@@ -1244,7 +1364,7 @@ const ExtensionHost = {
|
|
|
1244
1364
|
const {
|
|
1245
1365
|
invoke: invoke$e,
|
|
1246
1366
|
set: set$c
|
|
1247
|
-
} = create$
|
|
1367
|
+
} = create$9(ExtensionManagementWorker);
|
|
1248
1368
|
const getLanguages$1 = (platform, assetDir) => {
|
|
1249
1369
|
return invoke$e('Extensions.getLanguages', platform, assetDir);
|
|
1250
1370
|
};
|
|
@@ -1252,45 +1372,50 @@ const getLanguages$1 = (platform, assetDir) => {
|
|
|
1252
1372
|
const {
|
|
1253
1373
|
invoke: invoke$d,
|
|
1254
1374
|
set: set$b
|
|
1255
|
-
} = create$
|
|
1375
|
+
} = create$9(OpenerWorker);
|
|
1256
1376
|
const openUrl = async (url, platform) => {
|
|
1257
1377
|
return invoke$d('Open.openUrl', url, platform);
|
|
1258
1378
|
};
|
|
1259
1379
|
|
|
1260
1380
|
const {
|
|
1261
1381
|
invoke: invoke$c,
|
|
1262
|
-
invokeAndTransfer,
|
|
1263
1382
|
set: set$a
|
|
1264
|
-
} = create$
|
|
1383
|
+
} = create$9(IconThemeWorker);
|
|
1384
|
+
|
|
1385
|
+
const {
|
|
1386
|
+
invoke: invoke$b,
|
|
1387
|
+
invokeAndTransfer,
|
|
1388
|
+
set: set$9
|
|
1389
|
+
} = create$9(RendererWorker$1);
|
|
1265
1390
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1266
1391
|
number(uid);
|
|
1267
1392
|
number(menuId);
|
|
1268
1393
|
number(x);
|
|
1269
1394
|
number(y);
|
|
1270
|
-
await invoke$
|
|
1395
|
+
await invoke$b('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1271
1396
|
};
|
|
1272
1397
|
const sendMessagePortToOpenerWorker = async (port, rpcId) => {
|
|
1273
1398
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1274
1399
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
|
|
1275
1400
|
};
|
|
1276
1401
|
const readFile = async uri => {
|
|
1277
|
-
return invoke$
|
|
1402
|
+
return invoke$b('FileSystem.readFile', uri);
|
|
1278
1403
|
};
|
|
1279
1404
|
const handleWorkspaceRefresh = async () => {
|
|
1280
|
-
return invoke$
|
|
1405
|
+
return invoke$b('Layout.handleWorkspaceRefresh');
|
|
1281
1406
|
};
|
|
1282
1407
|
const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
|
|
1283
1408
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1284
1409
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1285
1410
|
};
|
|
1286
1411
|
const writeClipBoardText = async text => {
|
|
1287
|
-
await invoke$
|
|
1412
|
+
await invoke$b('ClipBoard.writeText', /* text */text);
|
|
1288
1413
|
};
|
|
1289
1414
|
const readClipBoardText = async () => {
|
|
1290
|
-
return invoke$
|
|
1415
|
+
return invoke$b('ClipBoard.readText');
|
|
1291
1416
|
};
|
|
1292
1417
|
const activateByEvent$1 = (event, assetDir, platform) => {
|
|
1293
|
-
return invoke$
|
|
1418
|
+
return invoke$b('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
|
|
1294
1419
|
};
|
|
1295
1420
|
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
1296
1421
|
const command = 'TextMeasurement.handleMessagePort';
|
|
@@ -1301,10 +1426,10 @@ const sendMessagePortToExtensionManagementWorker$1 = async (port, rpcId) => {
|
|
|
1301
1426
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1302
1427
|
};
|
|
1303
1428
|
const getPreference = async key => {
|
|
1304
|
-
return await invoke$
|
|
1429
|
+
return await invoke$b('Preferences.get', key);
|
|
1305
1430
|
};
|
|
1306
1431
|
const openUri = async (uri, focus, options) => {
|
|
1307
|
-
await invoke$
|
|
1432
|
+
await invoke$b('Main.openUri', uri, focus, options);
|
|
1308
1433
|
};
|
|
1309
1434
|
const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
|
|
1310
1435
|
await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
|
|
@@ -1315,7 +1440,7 @@ const RendererWorker = {
|
|
|
1315
1440
|
activateByEvent: activateByEvent$1,
|
|
1316
1441
|
getPreference,
|
|
1317
1442
|
handleWorkspaceRefresh,
|
|
1318
|
-
invoke: invoke$
|
|
1443
|
+
invoke: invoke$b,
|
|
1319
1444
|
invokeAndTransfer,
|
|
1320
1445
|
openUri,
|
|
1321
1446
|
readClipBoardText,
|
|
@@ -1325,20 +1450,15 @@ const RendererWorker = {
|
|
|
1325
1450
|
sendMessagePortToOpenerWorker,
|
|
1326
1451
|
sendMessagePortToSyntaxHighlightingWorker: sendMessagePortToSyntaxHighlightingWorker$1,
|
|
1327
1452
|
sendMessagePortToTextMeasurementWorker,
|
|
1328
|
-
set: set$
|
|
1453
|
+
set: set$9,
|
|
1329
1454
|
showContextMenu2,
|
|
1330
1455
|
writeClipBoardText
|
|
1331
1456
|
};
|
|
1332
1457
|
|
|
1333
|
-
const {
|
|
1334
|
-
invoke: invoke$b,
|
|
1335
|
-
set: set$9
|
|
1336
|
-
} = create$a(IconThemeWorker);
|
|
1337
|
-
|
|
1338
1458
|
const {
|
|
1339
1459
|
invoke: invoke$a,
|
|
1340
1460
|
set: set$8
|
|
1341
|
-
} = create$
|
|
1461
|
+
} = create$9(MarkdownWorker);
|
|
1342
1462
|
|
|
1343
1463
|
const SyntaxHighlightingWorker = {
|
|
1344
1464
|
__proto__: null,
|
|
@@ -1376,126 +1496,6 @@ const createLazyRpc = rpcId => {
|
|
|
1376
1496
|
};
|
|
1377
1497
|
};
|
|
1378
1498
|
|
|
1379
|
-
const toCommandId = key => {
|
|
1380
|
-
const dotIndex = key.indexOf('.');
|
|
1381
|
-
return key.slice(dotIndex + 1);
|
|
1382
|
-
};
|
|
1383
|
-
const create$9 = () => {
|
|
1384
|
-
const states = Object.create(null);
|
|
1385
|
-
const commandMapRef = {};
|
|
1386
|
-
return {
|
|
1387
|
-
clear() {
|
|
1388
|
-
for (const key of Object.keys(states)) {
|
|
1389
|
-
delete states[key];
|
|
1390
|
-
}
|
|
1391
|
-
},
|
|
1392
|
-
diff(uid, modules, numbers) {
|
|
1393
|
-
const {
|
|
1394
|
-
newState,
|
|
1395
|
-
oldState
|
|
1396
|
-
} = states[uid];
|
|
1397
|
-
const diffResult = [];
|
|
1398
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1399
|
-
const fn = modules[i];
|
|
1400
|
-
if (!fn(oldState, newState)) {
|
|
1401
|
-
diffResult.push(numbers[i]);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
return diffResult;
|
|
1405
|
-
},
|
|
1406
|
-
dispose(uid) {
|
|
1407
|
-
delete states[uid];
|
|
1408
|
-
},
|
|
1409
|
-
get(uid) {
|
|
1410
|
-
return states[uid];
|
|
1411
|
-
},
|
|
1412
|
-
getCommandIds() {
|
|
1413
|
-
const keys = Object.keys(commandMapRef);
|
|
1414
|
-
const ids = keys.map(toCommandId);
|
|
1415
|
-
return ids;
|
|
1416
|
-
},
|
|
1417
|
-
getKeys() {
|
|
1418
|
-
return Object.keys(states).map(key => {
|
|
1419
|
-
return Number.parseFloat(key);
|
|
1420
|
-
});
|
|
1421
|
-
},
|
|
1422
|
-
registerCommands(commandMap) {
|
|
1423
|
-
Object.assign(commandMapRef, commandMap);
|
|
1424
|
-
},
|
|
1425
|
-
set(uid, oldState, newState) {
|
|
1426
|
-
states[uid] = {
|
|
1427
|
-
newState,
|
|
1428
|
-
oldState
|
|
1429
|
-
};
|
|
1430
|
-
},
|
|
1431
|
-
wrapCommand(fn) {
|
|
1432
|
-
const wrapped = async (uid, ...args) => {
|
|
1433
|
-
const {
|
|
1434
|
-
newState,
|
|
1435
|
-
oldState
|
|
1436
|
-
} = states[uid];
|
|
1437
|
-
const newerState = await fn(newState, ...args);
|
|
1438
|
-
if (oldState === newerState || newState === newerState) {
|
|
1439
|
-
return;
|
|
1440
|
-
}
|
|
1441
|
-
const latestOld = states[uid];
|
|
1442
|
-
const latestNew = {
|
|
1443
|
-
...latestOld.newState,
|
|
1444
|
-
...newerState
|
|
1445
|
-
};
|
|
1446
|
-
states[uid] = {
|
|
1447
|
-
newState: latestNew,
|
|
1448
|
-
oldState: latestOld.oldState
|
|
1449
|
-
};
|
|
1450
|
-
};
|
|
1451
|
-
return wrapped;
|
|
1452
|
-
},
|
|
1453
|
-
wrapGetter(fn) {
|
|
1454
|
-
const wrapped = (uid, ...args) => {
|
|
1455
|
-
const {
|
|
1456
|
-
newState
|
|
1457
|
-
} = states[uid];
|
|
1458
|
-
return fn(newState, ...args);
|
|
1459
|
-
};
|
|
1460
|
-
return wrapped;
|
|
1461
|
-
},
|
|
1462
|
-
wrapLoadContent(fn) {
|
|
1463
|
-
const wrapped = async (uid, ...args) => {
|
|
1464
|
-
const {
|
|
1465
|
-
newState,
|
|
1466
|
-
oldState
|
|
1467
|
-
} = states[uid];
|
|
1468
|
-
const result = await fn(newState, ...args);
|
|
1469
|
-
const {
|
|
1470
|
-
error,
|
|
1471
|
-
state
|
|
1472
|
-
} = result;
|
|
1473
|
-
if (oldState === state || newState === state) {
|
|
1474
|
-
return {
|
|
1475
|
-
error
|
|
1476
|
-
};
|
|
1477
|
-
}
|
|
1478
|
-
const latestOld = states[uid];
|
|
1479
|
-
const latestNew = {
|
|
1480
|
-
...latestOld.newState,
|
|
1481
|
-
...state
|
|
1482
|
-
};
|
|
1483
|
-
states[uid] = {
|
|
1484
|
-
newState: latestNew,
|
|
1485
|
-
oldState: latestOld.oldState
|
|
1486
|
-
};
|
|
1487
|
-
return {
|
|
1488
|
-
error
|
|
1489
|
-
};
|
|
1490
|
-
};
|
|
1491
|
-
return wrapped;
|
|
1492
|
-
}
|
|
1493
|
-
};
|
|
1494
|
-
};
|
|
1495
|
-
const terminate = () => {
|
|
1496
|
-
globalThis.close();
|
|
1497
|
-
};
|
|
1498
|
-
|
|
1499
1499
|
// TODO add tests for this
|
|
1500
1500
|
const activateByEvent = async (event, assetDir, platform) => {
|
|
1501
1501
|
string(event);
|
|
@@ -1512,7 +1512,7 @@ const codeGeneratorAccept = state => {
|
|
|
1512
1512
|
const ModuleWorkerAndWorkaroundForChromeDevtoolsBug = 6;
|
|
1513
1513
|
|
|
1514
1514
|
const launchWorker = async (name, url, intializeCommand) => {
|
|
1515
|
-
const rpc = await create$
|
|
1515
|
+
const rpc = await create$d({
|
|
1516
1516
|
commandMap: {},
|
|
1517
1517
|
isMessagePortOpen: true,
|
|
1518
1518
|
async send(port) {
|
|
@@ -1567,7 +1567,7 @@ const loadContent$3 = async (state, parentUid) => {
|
|
|
1567
1567
|
};
|
|
1568
1568
|
};
|
|
1569
1569
|
|
|
1570
|
-
const editorStates = create$
|
|
1570
|
+
const editorStates = create$j();
|
|
1571
1571
|
const {
|
|
1572
1572
|
getCommandIds,
|
|
1573
1573
|
registerCommands,
|
|
@@ -1623,6 +1623,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1623
1623
|
fontFamily: '',
|
|
1624
1624
|
fontSize: 0,
|
|
1625
1625
|
fontWeight: 0,
|
|
1626
|
+
handleOffset: 0,
|
|
1626
1627
|
handleOffsetX: 0,
|
|
1627
1628
|
height,
|
|
1628
1629
|
highlightedLine: -1,
|
|
@@ -1938,7 +1939,7 @@ const state$7 = {
|
|
|
1938
1939
|
tokenizers: Object.create(null)
|
|
1939
1940
|
};
|
|
1940
1941
|
const has = languageId => {
|
|
1941
|
-
return
|
|
1942
|
+
return Object.hasOwn(state$7.tokenizers, languageId);
|
|
1942
1943
|
};
|
|
1943
1944
|
const set$4 = (languageId, tokenizer) => {
|
|
1944
1945
|
state$7.tokenizers[languageId] = tokenizer;
|
|
@@ -1947,7 +1948,7 @@ const get$4 = languageId => {
|
|
|
1947
1948
|
return state$7.tokenizers[languageId];
|
|
1948
1949
|
};
|
|
1949
1950
|
const isPending = languageId => {
|
|
1950
|
-
return
|
|
1951
|
+
return Object.hasOwn(state$7.pending, languageId);
|
|
1951
1952
|
};
|
|
1952
1953
|
|
|
1953
1954
|
const tokenMaps = Object.create(null);
|
|
@@ -2168,7 +2169,7 @@ const Tab = '\t';
|
|
|
2168
2169
|
|
|
2169
2170
|
const normalizeText = (text, normalize, tabSize) => {
|
|
2170
2171
|
if (normalize) {
|
|
2171
|
-
return text.replaceAll(Tab, Space.repeat(tabSize));
|
|
2172
|
+
return text.replaceAll(Tab, () => Space.repeat(tabSize));
|
|
2172
2173
|
}
|
|
2173
2174
|
return text;
|
|
2174
2175
|
};
|
|
@@ -2231,11 +2232,9 @@ const applyEdits = (textDocument, changes) => {
|
|
|
2231
2232
|
const startColumnIndex = change.start.columnIndex;
|
|
2232
2233
|
const endColumnIndex = change.end.columnIndex;
|
|
2233
2234
|
const {
|
|
2235
|
+
deleted,
|
|
2234
2236
|
inserted
|
|
2235
2237
|
} = change;
|
|
2236
|
-
const {
|
|
2237
|
-
deleted
|
|
2238
|
-
} = change;
|
|
2239
2238
|
number(startRowIndex);
|
|
2240
2239
|
number(endRowIndex);
|
|
2241
2240
|
number(startColumnIndex);
|
|
@@ -2411,11 +2410,29 @@ const getStartDefaults = (tokens, minOffset) => {
|
|
|
2411
2410
|
break;
|
|
2412
2411
|
}
|
|
2413
2412
|
}
|
|
2414
|
-
return {
|
|
2415
|
-
end,
|
|
2416
|
-
start,
|
|
2417
|
-
startIndex
|
|
2418
|
-
};
|
|
2413
|
+
return {
|
|
2414
|
+
end,
|
|
2415
|
+
start,
|
|
2416
|
+
startIndex
|
|
2417
|
+
};
|
|
2418
|
+
};
|
|
2419
|
+
const hasDecorationOverlap = (decorationMap, tokenStart, tokenEnd) => {
|
|
2420
|
+
for (const [decorationStart, {
|
|
2421
|
+
end: decorationEnd
|
|
2422
|
+
}] of decorationMap) {
|
|
2423
|
+
if (decorationStart < tokenEnd && decorationEnd > tokenStart) {
|
|
2424
|
+
return true;
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
return false;
|
|
2428
|
+
};
|
|
2429
|
+
const getActiveDecoration = (decorationMap, currentPos) => {
|
|
2430
|
+
for (const [decorationStart, decoration] of decorationMap) {
|
|
2431
|
+
if (decorationStart <= currentPos && decoration.end > currentPos) {
|
|
2432
|
+
return decoration;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
return undefined;
|
|
2419
2436
|
};
|
|
2420
2437
|
const getLineInfoEmbeddedFull = (embeddedResults, tokenResults, line, decorations, lineOffset, normalize, tabSize, width, deltaX, averageCharWidth, minOffset, maxOffset) => {
|
|
2421
2438
|
const lineInfo = [];
|
|
@@ -2454,29 +2471,13 @@ const getLineInfoEmbeddedFull = (embeddedResults, tokenResults, line, decoration
|
|
|
2454
2471
|
const tokenType = embeddedTokens[i];
|
|
2455
2472
|
const tokenLength = embeddedTokens[i + 1];
|
|
2456
2473
|
const tokenEnd = start + tokenLength;
|
|
2457
|
-
|
|
2458
|
-
// Check if any decorations overlap with this token
|
|
2459
|
-
let hasOverlap = false;
|
|
2460
|
-
for (const [decorationStart, {
|
|
2461
|
-
end: decorationEnd
|
|
2462
|
-
}] of decorationMap) {
|
|
2463
|
-
if (decorationStart < tokenEnd && decorationEnd > start) {
|
|
2464
|
-
hasOverlap = true;
|
|
2465
|
-
break;
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2474
|
+
const hasOverlap = hasDecorationOverlap(decorationMap, start, tokenEnd);
|
|
2468
2475
|
if (hasOverlap) {
|
|
2469
2476
|
// Token has decoration overlap - split into parts
|
|
2470
2477
|
let currentPos = start;
|
|
2471
2478
|
while (currentPos < tokenEnd) {
|
|
2472
2479
|
// Find if current position is inside a decoration
|
|
2473
|
-
|
|
2474
|
-
for (const [decorationStart, decoration] of decorationMap) {
|
|
2475
|
-
if (decorationStart <= currentPos && decoration.end > currentPos) {
|
|
2476
|
-
activeDecoration = decoration;
|
|
2477
|
-
break;
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
+
const activeDecoration = getActiveDecoration(decorationMap, currentPos);
|
|
2480
2481
|
if (activeDecoration) {
|
|
2481
2482
|
// Render decorated part
|
|
2482
2483
|
const partEnd = Math.min(tokenEnd, activeDecoration.end);
|
|
@@ -2524,7 +2525,7 @@ const getLineInfoEmbeddedFull = (embeddedResults, tokenResults, line, decoration
|
|
|
2524
2525
|
};
|
|
2525
2526
|
const getOffsets = (deltaX, width, averageCharWidth) => {
|
|
2526
2527
|
// TODO accurately measure char widths using offscreen canvas
|
|
2527
|
-
// and use fast measurements for monospace
|
|
2528
|
+
// and use fast measurements for monospace ASCII text
|
|
2528
2529
|
if (deltaX === 0) {
|
|
2529
2530
|
return {
|
|
2530
2531
|
maxOffset: Math.ceil(width / averageCharWidth),
|
|
@@ -2580,29 +2581,13 @@ const getLineInfoDefault = (line, tokenResults, embeddedResults, decorations, To
|
|
|
2580
2581
|
const tokenType = tokens[i];
|
|
2581
2582
|
const tokenLength = tokens[i + 1];
|
|
2582
2583
|
const tokenEnd = start + tokenLength;
|
|
2583
|
-
|
|
2584
|
-
// Check if any decorations overlap with this token
|
|
2585
|
-
let hasOverlap = false;
|
|
2586
|
-
for (const [decorationStart, {
|
|
2587
|
-
end: decorationEnd
|
|
2588
|
-
}] of decorationMap) {
|
|
2589
|
-
if (decorationStart < tokenEnd && decorationEnd > start) {
|
|
2590
|
-
hasOverlap = true;
|
|
2591
|
-
break;
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2584
|
+
const hasOverlap = hasDecorationOverlap(decorationMap, start, tokenEnd);
|
|
2594
2585
|
if (hasOverlap) {
|
|
2595
2586
|
// Token has decoration overlap - split into parts
|
|
2596
2587
|
let currentPos = start;
|
|
2597
2588
|
while (currentPos < tokenEnd) {
|
|
2598
2589
|
// Find if current position is inside a decoration
|
|
2599
|
-
|
|
2600
|
-
for (const [decorationStart, decoration] of decorationMap) {
|
|
2601
|
-
if (decorationStart <= currentPos && decoration.end > currentPos) {
|
|
2602
|
-
activeDecoration = decoration;
|
|
2603
|
-
break;
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2590
|
+
const activeDecoration = getActiveDecoration(decorationMap, currentPos);
|
|
2606
2591
|
if (activeDecoration) {
|
|
2607
2592
|
// Render decorated part
|
|
2608
2593
|
const partEnd = Math.min(tokenEnd, activeDecoration.end);
|
|
@@ -2743,6 +2728,9 @@ const getVisible$1 = async (editor, syncIncremental) => {
|
|
|
2743
2728
|
|
|
2744
2729
|
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
2745
2730
|
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
2731
|
+
if (!Number.isFinite(scrollBarOffset)) {
|
|
2732
|
+
return 0;
|
|
2733
|
+
}
|
|
2746
2734
|
return scrollBarOffset;
|
|
2747
2735
|
};
|
|
2748
2736
|
const getScrollBarY = getScrollBarOffset;
|
|
@@ -2871,7 +2859,7 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
2871
2859
|
* @returns Array of regex matches
|
|
2872
2860
|
*/
|
|
2873
2861
|
const getRegexMatches = (text, regex) => {
|
|
2874
|
-
return
|
|
2862
|
+
return text.matchAll(regex).toArray();
|
|
2875
2863
|
};
|
|
2876
2864
|
|
|
2877
2865
|
// URL matching regex pattern - matches common URL schemes
|
|
@@ -2979,7 +2967,7 @@ const state$6 = Object.create(null);
|
|
|
2979
2967
|
const registerListener$1 = (listenerType, rpcId) => {
|
|
2980
2968
|
number(listenerType);
|
|
2981
2969
|
number(rpcId);
|
|
2982
|
-
if (!state$6
|
|
2970
|
+
if (!Object.hasOwn(state$6, listenerType)) {
|
|
2983
2971
|
state$6[listenerType] = [];
|
|
2984
2972
|
}
|
|
2985
2973
|
|
|
@@ -2997,7 +2985,7 @@ const registerListener$1 = (listenerType, rpcId) => {
|
|
|
2997
2985
|
const unregisterListener$1 = (listenerType, rpcId) => {
|
|
2998
2986
|
number(listenerType);
|
|
2999
2987
|
number(rpcId);
|
|
3000
|
-
if (state$6
|
|
2988
|
+
if (Object.hasOwn(state$6, listenerType)) {
|
|
3001
2989
|
const index = state$6[listenerType].indexOf(rpcId);
|
|
3002
2990
|
if (index !== -1) {
|
|
3003
2991
|
state$6[listenerType].splice(index, 1);
|
|
@@ -3122,13 +3110,13 @@ const measureTextWidthFast = async (text, charWidth) => {
|
|
|
3122
3110
|
};
|
|
3123
3111
|
|
|
3124
3112
|
const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
|
|
3125
|
-
const width = await invoke$
|
|
3113
|
+
const width = await invoke$c('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
|
|
3126
3114
|
return width;
|
|
3127
3115
|
};
|
|
3128
3116
|
|
|
3129
3117
|
const measureTextWidth = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
|
|
3130
3118
|
// TODO maybe have a property for the whole text document
|
|
3131
|
-
// whether the document is
|
|
3119
|
+
// whether the document is ASCII or not
|
|
3132
3120
|
// so that it doesn't need to be checked on every cursor change
|
|
3133
3121
|
// or scroll position change
|
|
3134
3122
|
if (isMonoSpaceFont && isAscii(text)) {
|
|
@@ -3482,7 +3470,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
|
|
|
3482
3470
|
// invalidStartIndex, lineCache, etc. just for testing editorType
|
|
3483
3471
|
const invalidStartIndex = Math.min(editor.invalidStartIndex, changes[0].start.rowIndex);
|
|
3484
3472
|
|
|
3485
|
-
// TODO maybe put undostack into indexeddb so that there is no memory leak in
|
|
3473
|
+
// TODO maybe put undostack into indexeddb so that there is no memory leak in app
|
|
3486
3474
|
// then clear old undostack from indexeddb after 3 days
|
|
3487
3475
|
// TODO should push to undostack after rendering
|
|
3488
3476
|
const autoClosingRanges = applyAutoClosingRangesEdit(editor, changes);
|
|
@@ -3509,10 +3497,12 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
|
|
|
3509
3497
|
}
|
|
3510
3498
|
|
|
3511
3499
|
// Notify registered listeners about editor changes
|
|
3512
|
-
|
|
3500
|
+
try {
|
|
3501
|
+
await notifyListeners(EditorChange, 'handleEditorChanged', editor.uid, editor.uri, changes);
|
|
3502
|
+
} catch (error) {
|
|
3513
3503
|
// Silently ignore notification errors to not interrupt the edit flow
|
|
3514
3504
|
console.warn('Failed to notify editor change listeners:', error);
|
|
3515
|
-
}
|
|
3505
|
+
}
|
|
3516
3506
|
const incrementalEdits = await getIncrementalEdits(editor, newEditorWithDecorations);
|
|
3517
3507
|
const editorWithNewWidgets = await applyWidgetChanges(newEditorWithDecorations, changes);
|
|
3518
3508
|
const newEditor2 = {
|
|
@@ -3932,7 +3922,7 @@ const updateDiagnostics = async newState => {
|
|
|
3932
3922
|
};
|
|
3933
3923
|
set$7(newState.id, latest.oldState, newEditor);
|
|
3934
3924
|
// @ts-ignore
|
|
3935
|
-
await invoke$
|
|
3925
|
+
await invoke$b('Editor.rerender', newState.id);
|
|
3936
3926
|
return newEditor;
|
|
3937
3927
|
} catch (error) {
|
|
3938
3928
|
// @ts-ignore
|
|
@@ -4006,6 +3996,7 @@ const createEditor = async ({
|
|
|
4006
3996
|
fontFamily,
|
|
4007
3997
|
fontSize,
|
|
4008
3998
|
fontWeight,
|
|
3999
|
+
handleOffset: 0,
|
|
4009
4000
|
handleOffsetX: 0,
|
|
4010
4001
|
height,
|
|
4011
4002
|
id,
|
|
@@ -4101,7 +4092,7 @@ const createEditor = async ({
|
|
|
4101
4092
|
};
|
|
4102
4093
|
|
|
4103
4094
|
const isEqual$2 = (oldState, newState) => {
|
|
4104
|
-
return oldState.
|
|
4095
|
+
return oldState.rowHeight === newState.rowHeight && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.scrollBarHeight === newState.scrollBarHeight;
|
|
4105
4096
|
};
|
|
4106
4097
|
|
|
4107
4098
|
const isEqual$1 = (oldState, newState) => {
|
|
@@ -4280,7 +4271,7 @@ const applyWorkspaceEdit = async (editor, changes) => {
|
|
|
4280
4271
|
return editor;
|
|
4281
4272
|
}
|
|
4282
4273
|
// TODO
|
|
4283
|
-
// for now only apply edits to single file, if it matches the
|
|
4274
|
+
// for now only apply edits to single file, if it matches the URI
|
|
4284
4275
|
//
|
|
4285
4276
|
// in the future:
|
|
4286
4277
|
// 1. if a change targets the current editor, apply an edit to this editor
|
|
@@ -4355,9 +4346,7 @@ const create$8 = () => {
|
|
|
4355
4346
|
const segments = segmenter.segment(line);
|
|
4356
4347
|
return segments.containing(index);
|
|
4357
4348
|
},
|
|
4358
|
-
getSegments(line)
|
|
4359
|
-
return segmenter.segment(line);
|
|
4360
|
-
},
|
|
4349
|
+
getSegments: line => segmenter.segment(line),
|
|
4361
4350
|
modelIndex(line, visualIndex) {
|
|
4362
4351
|
const segments = segmenter.segment(line);
|
|
4363
4352
|
let currentVisualIndex = 0;
|
|
@@ -4457,13 +4446,13 @@ const at = async (editor, eventX, eventY) => {
|
|
|
4457
4446
|
y
|
|
4458
4447
|
} = editor;
|
|
4459
4448
|
const rowIndex = Math.floor((eventY - y + deltaY) / rowHeight);
|
|
4460
|
-
const relativeX = eventX - x + deltaX;
|
|
4461
4449
|
if (rowIndex < 0) {
|
|
4462
4450
|
return {
|
|
4463
4451
|
columnIndex: 0,
|
|
4464
4452
|
rowIndex: 0
|
|
4465
4453
|
};
|
|
4466
4454
|
}
|
|
4455
|
+
const relativeX = eventX - x + deltaX;
|
|
4467
4456
|
const clampedRowIndex = clamp(rowIndex, 0, lines.length - 1);
|
|
4468
4457
|
const line = lines[clampedRowIndex];
|
|
4469
4458
|
const columnIndex = await getAccurateColumnIndex(line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, relativeX);
|
|
@@ -4474,7 +4463,7 @@ const at = async (editor, eventX, eventY) => {
|
|
|
4474
4463
|
};
|
|
4475
4464
|
|
|
4476
4465
|
/**
|
|
4477
|
-
* @deprecated this doesn't work for variable width characters (
|
|
4466
|
+
* @deprecated this doesn't work for variable width characters (Unicode/emoji).
|
|
4478
4467
|
* Use position computation in renderer process instead
|
|
4479
4468
|
*
|
|
4480
4469
|
* @param {object} editor
|
|
@@ -4522,7 +4511,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
|
|
|
4522
4511
|
const y$1 = y(editor, rowIndex);
|
|
4523
4512
|
const displayErrorMessage = message;
|
|
4524
4513
|
// @ts-ignore
|
|
4525
|
-
await invoke$
|
|
4514
|
+
await invoke$b('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
|
|
4526
4515
|
if (!isError) {
|
|
4527
4516
|
const handleTimeout = () => {
|
|
4528
4517
|
editorHideMessage(editor);
|
|
@@ -4557,9 +4546,7 @@ const editorHideMessage = async editor => {
|
|
|
4557
4546
|
};
|
|
4558
4547
|
|
|
4559
4548
|
// @ts-ignore
|
|
4560
|
-
const getErrorMessage$4 =
|
|
4561
|
-
return `${error}`;
|
|
4562
|
-
};
|
|
4549
|
+
const getErrorMessage$4 = String;
|
|
4563
4550
|
|
|
4564
4551
|
// @ts-ignore
|
|
4565
4552
|
const getMatchingClosingBrace$1 = brace => {
|
|
@@ -4579,7 +4566,7 @@ const braceCompletion = async (editor, text) => {
|
|
|
4579
4566
|
// @ts-ignore
|
|
4580
4567
|
const offset = offsetAt(editor, editor.cursor);
|
|
4581
4568
|
// @ts-ignore
|
|
4582
|
-
const result = await invoke$
|
|
4569
|
+
const result = await invoke$b('ExtensionHostBraceCompletion.executeBraceCompletionProvider', editor, offset, text);
|
|
4583
4570
|
if (result) {
|
|
4584
4571
|
const closingBrace = getMatchingClosingBrace$1(text);
|
|
4585
4572
|
const insertText = text + closingBrace;
|
|
@@ -5080,7 +5067,7 @@ const tryRegexArray = (partialLine, regexArray) => {
|
|
|
5080
5067
|
return 1;
|
|
5081
5068
|
};
|
|
5082
5069
|
const RE_WORD_LEFT_1 = /(?<![A-Z])[A-Z]+\s*$/;
|
|
5083
|
-
const RE_WORD_LEFT_2 = /[\
|
|
5070
|
+
const RE_WORD_LEFT_2 = /[\u{C0}-\u{17F}\w\-]+>?\s*$/u;
|
|
5084
5071
|
const RE_WORD_LEFT_3 = /[a-zA-Z]+[^a-zA-Z\d]+\s*$/;
|
|
5085
5072
|
const RE_WORD_LEFT_4 = /\s+$/;
|
|
5086
5073
|
const RE_WORD_LEFT_5 = /[^a-zA-Z\d]+\s*$/;
|
|
@@ -5091,7 +5078,7 @@ const wordLeft = (line, columnIndex) => {
|
|
|
5091
5078
|
const partialLine = line.slice(0, columnIndex);
|
|
5092
5079
|
return tryRegexArray(partialLine, RE_WORD_LEFT);
|
|
5093
5080
|
};
|
|
5094
|
-
const RE_WORD_RIGHT_1 = /^\s*[\
|
|
5081
|
+
const RE_WORD_RIGHT_1 = /^\s*[\u{C0}-\u{17F}\w]+/iu;
|
|
5095
5082
|
const RE_WORD_RIGHT_2 = /^[^a-zA-Z\d]+\w*/;
|
|
5096
5083
|
const RE_WORD_RIGHT = [RE_WORD_RIGHT_1, RE_WORD_RIGHT_2];
|
|
5097
5084
|
const wordRight = (line, columnIndex) => {
|
|
@@ -5512,7 +5499,7 @@ const deleteWordRight = editor => {
|
|
|
5512
5499
|
|
|
5513
5500
|
const findAllReferences$1 = async editor => {
|
|
5514
5501
|
// @ts-ignore
|
|
5515
|
-
await invoke$
|
|
5502
|
+
await invoke$b('SideBar.show', 'References', /* focus */true);
|
|
5516
5503
|
return editor;
|
|
5517
5504
|
};
|
|
5518
5505
|
|
|
@@ -5549,7 +5536,7 @@ const format = async editor => {
|
|
|
5549
5536
|
console.error(error);
|
|
5550
5537
|
|
|
5551
5538
|
// TODO configure editor message as widget
|
|
5552
|
-
const displayErrorMessage =
|
|
5539
|
+
const displayErrorMessage = String(error);
|
|
5553
5540
|
await editorShowMessage(editor, 0, 0, displayErrorMessage, true);
|
|
5554
5541
|
return editor;
|
|
5555
5542
|
}
|
|
@@ -5600,7 +5587,7 @@ const getWordBefore = (editor, rowIndex, columnIndex) => {
|
|
|
5600
5587
|
// @ts-ignore
|
|
5601
5588
|
const getDefinition = async (editor, offset) => {
|
|
5602
5589
|
// @ts-ignore
|
|
5603
|
-
const definition = await invoke$
|
|
5590
|
+
const definition = await invoke$b('ExtensionHostDefinition.executeDefinitionProvider', editor, offset);
|
|
5604
5591
|
return definition;
|
|
5605
5592
|
};
|
|
5606
5593
|
|
|
@@ -5833,7 +5820,7 @@ const goTo = async ({
|
|
|
5833
5820
|
// TODO possible to do this with events/state machine instead of promises -> enables canceling operations / concurrent calls
|
|
5834
5821
|
|
|
5835
5822
|
// TODO there are still race conditions in this function:
|
|
5836
|
-
// - when open is called twice, previous
|
|
5823
|
+
// - when open is called twice, previous DOM nodes can either be reused or the previous DOM nodes must be disposed
|
|
5837
5824
|
|
|
5838
5825
|
// @ts-ignore
|
|
5839
5826
|
const getLocation$1 = async (editor, rowIndex, columnIndex) => {
|
|
@@ -5849,18 +5836,7 @@ const getNoLocationFoundMessage$1 = info => {
|
|
|
5849
5836
|
}
|
|
5850
5837
|
return noDefinitionFound();
|
|
5851
5838
|
};
|
|
5852
|
-
|
|
5853
|
-
// @ts-ignore
|
|
5854
|
-
const getErrorMessage$3 = error => {
|
|
5855
|
-
// if (
|
|
5856
|
-
// error &&
|
|
5857
|
-
// error.message &&
|
|
5858
|
-
// error.message.startsWith('Failed to execute definition provider: ')
|
|
5859
|
-
// ) {
|
|
5860
|
-
// return error.message.replace('Failed to execute definition provider: ', '')
|
|
5861
|
-
// }
|
|
5862
|
-
return `${error}`;
|
|
5863
|
-
};
|
|
5839
|
+
const getErrorMessage$3 = String;
|
|
5864
5840
|
|
|
5865
5841
|
// @ts-ignore
|
|
5866
5842
|
const isNoProviderFoundError$1 = error => {
|
|
@@ -5885,7 +5861,7 @@ const getNoLocationFoundMessage = info => {
|
|
|
5885
5861
|
|
|
5886
5862
|
const getTypeDefinition = async (editor, offset) => {
|
|
5887
5863
|
// @ts-ignore
|
|
5888
|
-
const definition = await invoke$
|
|
5864
|
+
const definition = await invoke$b('ExtensionHostTypeDefinition.executeTypeDefinitionProvider', editor, offset);
|
|
5889
5865
|
return definition;
|
|
5890
5866
|
};
|
|
5891
5867
|
|
|
@@ -5894,21 +5870,7 @@ const getLocation = async (editor, rowIndex, columnIndex) => {
|
|
|
5894
5870
|
const definition = await getTypeDefinition(editor, offset);
|
|
5895
5871
|
return definition;
|
|
5896
5872
|
};
|
|
5897
|
-
|
|
5898
|
-
// @ts-ignore
|
|
5899
|
-
const getErrorMessage$2 = error => {
|
|
5900
|
-
// if (
|
|
5901
|
-
// error &&
|
|
5902
|
-
// error.message &&
|
|
5903
|
-
// error.message.startsWith('Failed to execute type definition provider: ')
|
|
5904
|
-
// ) {
|
|
5905
|
-
// return error.message.replace(
|
|
5906
|
-
// 'Failed to execute type definition provider: ',
|
|
5907
|
-
// ''
|
|
5908
|
-
// )
|
|
5909
|
-
// }
|
|
5910
|
-
return `${error}`;
|
|
5911
|
-
};
|
|
5873
|
+
const getErrorMessage$2 = String;
|
|
5912
5874
|
const isNoProviderFoundError = error => {
|
|
5913
5875
|
return error?.message?.startsWith('Failed to execute type definition provider: No type definition provider found');
|
|
5914
5876
|
};
|
|
@@ -6068,8 +6030,8 @@ const handleContextMenu = async (editor, button, x, y) => {
|
|
|
6068
6030
|
// @ts-ignore
|
|
6069
6031
|
|
|
6070
6032
|
// match all words, including umlauts, see https://stackoverflow.com/questions/5436824/matching-accented-characters-with-javascript-regexes/#answer-11550799
|
|
6071
|
-
const RE_WORD_START = /^[a-
|
|
6072
|
-
const RE_WORD_END = /[a-
|
|
6033
|
+
const RE_WORD_START = /^[a-zA-Z\u{C0}-\u{17F}\d]+/u;
|
|
6034
|
+
const RE_WORD_END = /[a-zA-Z\u{C0}-\u{17F}\d]+$/u;
|
|
6073
6035
|
|
|
6074
6036
|
// @ts-ignore
|
|
6075
6037
|
const getNewSelections$7 = (line, rowIndex, columnIndex) => {
|
|
@@ -6331,6 +6293,7 @@ const state$1 = {
|
|
|
6331
6293
|
*/
|
|
6332
6294
|
currentEditor: undefined,
|
|
6333
6295
|
hasListener: false,
|
|
6296
|
+
isSelecting: false,
|
|
6334
6297
|
position: {
|
|
6335
6298
|
columnIndex: 0,
|
|
6336
6299
|
rowIndex: 0
|
|
@@ -6345,6 +6308,13 @@ const setEditor = editor => {
|
|
|
6345
6308
|
const clearEditor = () => {
|
|
6346
6309
|
state$1.currentEditor = undefined;
|
|
6347
6310
|
state$1.hasListener = false;
|
|
6311
|
+
state$1.isSelecting = false;
|
|
6312
|
+
};
|
|
6313
|
+
const startSelecting = () => {
|
|
6314
|
+
state$1.isSelecting = true;
|
|
6315
|
+
};
|
|
6316
|
+
const isSelecting = () => {
|
|
6317
|
+
return state$1.isSelecting;
|
|
6348
6318
|
};
|
|
6349
6319
|
|
|
6350
6320
|
// @ts-ignore
|
|
@@ -6368,6 +6338,7 @@ const handlePointerCaptureLost = editor => {
|
|
|
6368
6338
|
};
|
|
6369
6339
|
|
|
6370
6340
|
const handlePointerDown$1 = (state, button, altKey, ctrlKey, x, y, detail) => {
|
|
6341
|
+
startSelecting();
|
|
6371
6342
|
return handleMouseDown(state, button, altKey, ctrlKey, x, y, detail);
|
|
6372
6343
|
};
|
|
6373
6344
|
|
|
@@ -6549,6 +6520,9 @@ const moveSelectionPx = async (editor, x, y) => {
|
|
|
6549
6520
|
};
|
|
6550
6521
|
|
|
6551
6522
|
const handlePointerMove = async (editor, x, y, altKey) => {
|
|
6523
|
+
if (!isSelecting()) {
|
|
6524
|
+
return editor;
|
|
6525
|
+
}
|
|
6552
6526
|
if (altKey) {
|
|
6553
6527
|
return moveRectangleSelectionPx(editor, x, y);
|
|
6554
6528
|
}
|
|
@@ -6587,8 +6561,6 @@ const handleScrollBarHorizontalMove = (state, eventX) => {
|
|
|
6587
6561
|
width,
|
|
6588
6562
|
x
|
|
6589
6563
|
} = state;
|
|
6590
|
-
const spaceRight = 20; // TODO make this configurable
|
|
6591
|
-
const normalizedEventX = clamp(eventX, x, x + width);
|
|
6592
6564
|
if (width > longestLineWidth) {
|
|
6593
6565
|
return {
|
|
6594
6566
|
...state,
|
|
@@ -6596,6 +6568,8 @@ const handleScrollBarHorizontalMove = (state, eventX) => {
|
|
|
6596
6568
|
scrollBarWidth: 0
|
|
6597
6569
|
};
|
|
6598
6570
|
}
|
|
6571
|
+
const spaceRight = 20; // TODO make this configurable
|
|
6572
|
+
const normalizedEventX = clamp(eventX, x, x + width);
|
|
6599
6573
|
const relativeX = normalizedEventX - x - handleOffsetX;
|
|
6600
6574
|
const scrollBarWidth = getScrollBarWidth(width, longestLineWidth);
|
|
6601
6575
|
const finalDeltaX = longestLineWidth - width + spaceRight;
|
|
@@ -6663,18 +6637,17 @@ const getNewPercent = (state, relativeY) => {
|
|
|
6663
6637
|
// clicked at bottom
|
|
6664
6638
|
return 1;
|
|
6665
6639
|
};
|
|
6666
|
-
|
|
6667
|
-
// @ts-ignore
|
|
6668
|
-
const handleScrollBarMove = (state, eventY) => {
|
|
6640
|
+
const handleScrollBarMove = async (state, eventY) => {
|
|
6669
6641
|
const {
|
|
6670
6642
|
finalDeltaY,
|
|
6671
|
-
handleOffset,
|
|
6643
|
+
handleOffset = 0,
|
|
6672
6644
|
y
|
|
6673
6645
|
} = state;
|
|
6674
6646
|
const relativeY = eventY - y - handleOffset;
|
|
6675
6647
|
const newPercent = getNewPercent(state, relativeY);
|
|
6676
6648
|
const newDeltaY = newPercent * finalDeltaY;
|
|
6677
|
-
|
|
6649
|
+
const newState = await setDeltaYFixedValue$1(state, newDeltaY);
|
|
6650
|
+
return newState;
|
|
6678
6651
|
};
|
|
6679
6652
|
const handleScrollBarVerticalPointerMove = handleScrollBarMove;
|
|
6680
6653
|
|
|
@@ -6684,7 +6657,7 @@ const handleScrollBarVerticalPointerMove = handleScrollBarMove;
|
|
|
6684
6657
|
// when clicked at y > editor.height - editor.scrollBarHeight/2, position scrollbar at (y - scrollbarHeight/2)
|
|
6685
6658
|
// additionally, when clicked on scrollbar, scrollbar position shouldn't move
|
|
6686
6659
|
|
|
6687
|
-
const handleScrollBarPointerDown = (state, eventY) => {
|
|
6660
|
+
const handleScrollBarPointerDown = async (state, eventY) => {
|
|
6688
6661
|
const {
|
|
6689
6662
|
deltaY,
|
|
6690
6663
|
finalDeltaY,
|
|
@@ -6706,8 +6679,9 @@ const handleScrollBarPointerDown = (state, eventY) => {
|
|
|
6706
6679
|
percent
|
|
6707
6680
|
} = getNewDeltaPercent(height, scrollBarHeight, relativeY);
|
|
6708
6681
|
const newDeltaY = percent * finalDeltaY;
|
|
6682
|
+
const newState = await setDeltaYFixedValue$1(state, newDeltaY);
|
|
6709
6683
|
return {
|
|
6710
|
-
...
|
|
6684
|
+
...newState,
|
|
6711
6685
|
handleOffset
|
|
6712
6686
|
};
|
|
6713
6687
|
};
|
|
@@ -6774,7 +6748,7 @@ const setDelta = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
|
|
|
6774
6748
|
if (eventDeltaX === 0) {
|
|
6775
6749
|
return setDeltaY(editor, eventDeltaY);
|
|
6776
6750
|
}
|
|
6777
|
-
const newDeltaX = clamp(deltaX + eventDeltaX, 0,
|
|
6751
|
+
const newDeltaX = clamp(deltaX + eventDeltaX, 0, Infinity);
|
|
6778
6752
|
return {
|
|
6779
6753
|
...setDeltaY(editor, eventDeltaY),
|
|
6780
6754
|
deltaX: newDeltaX
|
|
@@ -6845,22 +6819,19 @@ const getChanges$1 = selections => {
|
|
|
6845
6819
|
rowsToIndent.push(i);
|
|
6846
6820
|
}
|
|
6847
6821
|
}
|
|
6848
|
-
const changes =
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
}
|
|
6862
|
-
});
|
|
6863
|
-
}
|
|
6822
|
+
const changes = Array.from(rowsToIndent, rowToIndent => ({
|
|
6823
|
+
deleted: [''],
|
|
6824
|
+
end: {
|
|
6825
|
+
columnIndex: 0,
|
|
6826
|
+
rowIndex: rowToIndent
|
|
6827
|
+
},
|
|
6828
|
+
inserted: [' '],
|
|
6829
|
+
origin: IndentMore,
|
|
6830
|
+
start: {
|
|
6831
|
+
columnIndex: 0,
|
|
6832
|
+
rowIndex: rowToIndent
|
|
6833
|
+
}
|
|
6834
|
+
}));
|
|
6864
6835
|
return changes;
|
|
6865
6836
|
};
|
|
6866
6837
|
const indentMore = editor => {
|
|
@@ -6873,7 +6844,7 @@ const indentMore = editor => {
|
|
|
6873
6844
|
|
|
6874
6845
|
const getLanguageConfiguration = async editor => {
|
|
6875
6846
|
// @ts-ignore
|
|
6876
|
-
return invoke$
|
|
6847
|
+
return invoke$b('Languages.getLanguageConfiguration', {
|
|
6877
6848
|
languageId: editor.languageId,
|
|
6878
6849
|
uri: editor.uri
|
|
6879
6850
|
});
|
|
@@ -7380,12 +7351,12 @@ const print = error => {
|
|
|
7380
7351
|
return `${error.type}: ${error.message}\n${error.stack}`;
|
|
7381
7352
|
}
|
|
7382
7353
|
if (error && error.stack) {
|
|
7383
|
-
return
|
|
7354
|
+
return error.stack;
|
|
7384
7355
|
}
|
|
7385
7356
|
if (error === null) {
|
|
7386
7357
|
return null;
|
|
7387
7358
|
}
|
|
7388
|
-
return
|
|
7359
|
+
return String(error);
|
|
7389
7360
|
};
|
|
7390
7361
|
|
|
7391
7362
|
// @ts-nocheck
|
|
@@ -7415,7 +7386,7 @@ const isUntitledFile = uri => {
|
|
|
7415
7386
|
};
|
|
7416
7387
|
|
|
7417
7388
|
const saveNormalFile = async (uri, content) => {
|
|
7418
|
-
await invoke$
|
|
7389
|
+
await invoke$b('FileSystem.writeFile', uri, content);
|
|
7419
7390
|
};
|
|
7420
7391
|
|
|
7421
7392
|
const showFilePicker = async platform => {
|
|
@@ -7435,9 +7406,9 @@ const saveUntitledFile = async (uri, content, platform) => {
|
|
|
7435
7406
|
if (!filePath) {
|
|
7436
7407
|
return;
|
|
7437
7408
|
}
|
|
7438
|
-
await invoke$
|
|
7409
|
+
await invoke$b('FileSystem.writeFile', filePath, content);
|
|
7439
7410
|
await handleWorkspaceRefresh();
|
|
7440
|
-
await invoke$
|
|
7411
|
+
await invoke$b('Main.handleUriChange', uri, filePath);
|
|
7441
7412
|
return filePath;
|
|
7442
7413
|
};
|
|
7443
7414
|
|
|
@@ -7459,9 +7430,8 @@ const save = async editor => {
|
|
|
7459
7430
|
};
|
|
7460
7431
|
}
|
|
7461
7432
|
return newEditor;
|
|
7462
|
-
} else {
|
|
7463
|
-
await saveNormalFile(uri, content);
|
|
7464
7433
|
}
|
|
7434
|
+
await saveNormalFile(uri, content);
|
|
7465
7435
|
return {
|
|
7466
7436
|
...newEditor,
|
|
7467
7437
|
modified: false
|
|
@@ -7769,7 +7739,7 @@ const selectInsideString = editor => {
|
|
|
7769
7739
|
|
|
7770
7740
|
const getNewSelections = async (editor, selections) => {
|
|
7771
7741
|
// @ts-ignore
|
|
7772
|
-
const newSelections = await invoke$
|
|
7742
|
+
const newSelections = await invoke$b('ExtensionHostSelection.executeGrowSelection', editor, selections);
|
|
7773
7743
|
if (newSelections.length === 0) {
|
|
7774
7744
|
return selections;
|
|
7775
7745
|
}
|
|
@@ -7797,7 +7767,7 @@ const selectionGrow = async editor => {
|
|
|
7797
7767
|
// ccc
|
|
7798
7768
|
|
|
7799
7769
|
// when clicking first at position 4 and then position 2,
|
|
7800
|
-
// -
|
|
7770
|
+
// - VS Code selects next position 3 and refuses to select position 1
|
|
7801
7771
|
// - atom also selects next position 3 and refuses to select position 1
|
|
7802
7772
|
// - WebStorm also selects next position 3 and refuses to select position 1
|
|
7803
7773
|
// - brackets (codemirror) selects position 3 and then selects position 1
|
|
@@ -7858,25 +7828,25 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
|
|
|
7858
7828
|
startRowIndex = selections[selectionIndex];
|
|
7859
7829
|
const startColumnIndex = selections[selectionIndex + 1];
|
|
7860
7830
|
const endColumnIndex = selections[selectionIndex + 3];
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7831
|
+
const isSelected = startRowIndex === i && startColumnIndex <= columnIndex && columnIndex <= endColumnIndex;
|
|
7832
|
+
if (!isSelected) {
|
|
7833
|
+
if (startRowIndex > i) {
|
|
7834
|
+
selectionIndex -= 4;
|
|
7835
|
+
}
|
|
7836
|
+
const columnEndIndex = columnIndex + word.length;
|
|
7837
|
+
selectionIndex += 4;
|
|
7838
|
+
const newSelections = new Uint32Array(selections.length + 4);
|
|
7839
|
+
newSelections.set(selections.subarray(0, selectionIndex), 0);
|
|
7840
|
+
newSelections[selectionIndex] = i;
|
|
7841
|
+
newSelections[selectionIndex + 1] = columnIndex;
|
|
7842
|
+
newSelections[selectionIndex + 2] = i;
|
|
7843
|
+
newSelections[selectionIndex + 3] = columnEndIndex;
|
|
7844
|
+
newSelections.set(selections.subarray(selectionIndex), selectionIndex + 4);
|
|
7845
|
+
return {
|
|
7846
|
+
revealRange: newSelections.length - 4,
|
|
7847
|
+
selectionEdits: newSelections
|
|
7848
|
+
};
|
|
7866
7849
|
}
|
|
7867
|
-
const columnEndIndex = columnIndex + word.length;
|
|
7868
|
-
selectionIndex += 4;
|
|
7869
|
-
const newSelections = new Uint32Array(selections.length + 4);
|
|
7870
|
-
newSelections.set(selections.subarray(0, selectionIndex), 0);
|
|
7871
|
-
newSelections[selectionIndex] = i;
|
|
7872
|
-
newSelections[selectionIndex + 1] = columnIndex;
|
|
7873
|
-
newSelections[selectionIndex + 2] = i;
|
|
7874
|
-
newSelections[selectionIndex + 3] = columnEndIndex;
|
|
7875
|
-
newSelections.set(selections.subarray(selectionIndex), selectionIndex + 4);
|
|
7876
|
-
return {
|
|
7877
|
-
revealRange: newSelections.length - 4,
|
|
7878
|
-
selectionEdits: newSelections
|
|
7879
|
-
};
|
|
7880
7850
|
}
|
|
7881
7851
|
}
|
|
7882
7852
|
return undefined;
|
|
@@ -7931,13 +7901,13 @@ const getSelectNextOccurrenceResult = editor => {
|
|
|
7931
7901
|
// ccc
|
|
7932
7902
|
|
|
7933
7903
|
// when clicking first at position 4 and then position 2,
|
|
7934
|
-
// -
|
|
7904
|
+
// - VS Code selects next position 3 and refuses to select position 1
|
|
7935
7905
|
// - atom also selects next position 3 and refuses to select position 1
|
|
7936
7906
|
// - WebStorm also selects next position 3 and refuses to select position 1
|
|
7937
7907
|
// - brackets (codemirror) selects position 3 and then selects position 1
|
|
7938
7908
|
// - sublime selects next position 1, then next position 3
|
|
7939
7909
|
|
|
7940
|
-
const
|
|
7910
|
+
const isRangeInViewport = (minLineY, maxLineY, startRowIndex, endRowIndex) => {
|
|
7941
7911
|
return startRowIndex >= minLineY && endRowIndex <= maxLineY;
|
|
7942
7912
|
};
|
|
7943
7913
|
|
|
@@ -7948,14 +7918,12 @@ const selectNextOccurrence = editor => {
|
|
|
7948
7918
|
return editor;
|
|
7949
7919
|
}
|
|
7950
7920
|
const {
|
|
7951
|
-
revealRange
|
|
7952
|
-
} = result;
|
|
7953
|
-
const {
|
|
7921
|
+
revealRange,
|
|
7954
7922
|
selectionEdits
|
|
7955
7923
|
} = result;
|
|
7956
7924
|
const revealRangeStartRowIndex = selectionEdits[revealRange];
|
|
7957
7925
|
const revealRangeEndRowIndex = selectionEdits[revealRange + 2];
|
|
7958
|
-
if (
|
|
7926
|
+
if (isRangeInViewport(editor.minLineY, editor.maxLineY, revealRangeStartRowIndex, revealRangeEndRowIndex)) {
|
|
7959
7927
|
return scheduleSelections(editor, selectionEdits);
|
|
7960
7928
|
}
|
|
7961
7929
|
// TODO what is this magic number 5?
|
|
@@ -8202,7 +8170,7 @@ const showHover3 = async editor => {
|
|
|
8202
8170
|
|
|
8203
8171
|
const EditorHover = 'EditorHover';
|
|
8204
8172
|
const showHover = async state => {
|
|
8205
|
-
await invoke$
|
|
8173
|
+
await invoke$b('Viewlet.openWidget', EditorHover);
|
|
8206
8174
|
return state;
|
|
8207
8175
|
};
|
|
8208
8176
|
|
|
@@ -8465,9 +8433,7 @@ const editorSnippet = (editor, snippet) => {
|
|
|
8465
8433
|
return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
8466
8434
|
};
|
|
8467
8435
|
|
|
8468
|
-
const getErrorMessage =
|
|
8469
|
-
return `${error}`;
|
|
8470
|
-
};
|
|
8436
|
+
const getErrorMessage = String;
|
|
8471
8437
|
const tabCompletion = async editor => {
|
|
8472
8438
|
try {
|
|
8473
8439
|
// TODO race condition
|
|
@@ -8493,7 +8459,7 @@ const getBlockComment = async (editor, offset) => {
|
|
|
8493
8459
|
} = editor;
|
|
8494
8460
|
// TODO ask extension host worker,
|
|
8495
8461
|
// execute block comment provider with
|
|
8496
|
-
//
|
|
8462
|
+
// URI, language id, offset
|
|
8497
8463
|
// and the extension returns a matching block comment or undefined
|
|
8498
8464
|
try {
|
|
8499
8465
|
await activateByEvent(`onLanguage:${editor.languageId}`, assetDir, platform);
|
|
@@ -8755,7 +8721,7 @@ const toggleComment = async editor => {
|
|
|
8755
8721
|
} catch (error$1) {
|
|
8756
8722
|
error(error$1);
|
|
8757
8723
|
// TODO use correct position
|
|
8758
|
-
await editorShowMessage(/* editor */editor, /* rowIndex */0, /* columnIndex */0, /* message
|
|
8724
|
+
await editorShowMessage(/* editor */editor, /* rowIndex */0, /* columnIndex */0, /* message */String(error$1), /* isError */true);
|
|
8759
8725
|
return editor;
|
|
8760
8726
|
}
|
|
8761
8727
|
};
|
|
@@ -8848,7 +8814,7 @@ const typeWithAutoClosingQuote = (editor, text) => {
|
|
|
8848
8814
|
const typeWithAutoClosingTag = async (editor, text) => {
|
|
8849
8815
|
const offset = offsetAt(editor, editor.selections[0], editor.selections[1]);
|
|
8850
8816
|
// @ts-ignore
|
|
8851
|
-
const result = await invoke$
|
|
8817
|
+
const result = await invoke$b('ExtensionHostClosingTagCompletion.executeClosingTagProvider', editor, offset, text);
|
|
8852
8818
|
if (!result) {
|
|
8853
8819
|
const changes = editorReplaceSelections(editor, [text], EditorType);
|
|
8854
8820
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
@@ -9100,7 +9066,7 @@ const addWidget$1 = (widget, id, render) => {
|
|
|
9100
9066
|
// 1. renderDom
|
|
9101
9067
|
// 2. renderAriaAnnouncement
|
|
9102
9068
|
// 3. renderFocus
|
|
9103
|
-
// to ensure that focus is always after the element is added to the
|
|
9069
|
+
// to ensure that focus is always after the element is added to the DOM
|
|
9104
9070
|
if (focusCommandIndex !== -1) {
|
|
9105
9071
|
const command = allCommands[focusCommandIndex];
|
|
9106
9072
|
allCommands.splice(focusCommandIndex, 1);
|
|
@@ -9207,6 +9173,7 @@ const renderFull$4 = (oldState, newState) => {
|
|
|
9207
9173
|
return commands;
|
|
9208
9174
|
};
|
|
9209
9175
|
|
|
9176
|
+
const commandsToForward$5 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
|
|
9210
9177
|
const render$b = widget => {
|
|
9211
9178
|
const commands = renderFull$4(widget.oldState, widget.newState);
|
|
9212
9179
|
const wrappedCommands = [];
|
|
@@ -9214,7 +9181,7 @@ const render$b = widget => {
|
|
|
9214
9181
|
uid
|
|
9215
9182
|
} = widget.newState;
|
|
9216
9183
|
for (const command of commands) {
|
|
9217
|
-
if (command[0]
|
|
9184
|
+
if (commandsToForward$5.includes(command[0])) {
|
|
9218
9185
|
wrappedCommands.push(command);
|
|
9219
9186
|
} else {
|
|
9220
9187
|
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
@@ -9279,6 +9246,7 @@ const renderFull$3 = (oldState, newState) => {
|
|
|
9279
9246
|
return commands;
|
|
9280
9247
|
};
|
|
9281
9248
|
|
|
9249
|
+
const commandsToForward$4 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
|
|
9282
9250
|
const render$a = widget => {
|
|
9283
9251
|
const commands = renderFull$3(widget.oldState, widget.newState);
|
|
9284
9252
|
const wrappedCommands = [];
|
|
@@ -9286,7 +9254,7 @@ const render$a = widget => {
|
|
|
9286
9254
|
uid
|
|
9287
9255
|
} = widget.newState;
|
|
9288
9256
|
for (const command of commands) {
|
|
9289
|
-
if (command[0]
|
|
9257
|
+
if (commandsToForward$4.includes(command[0])) {
|
|
9290
9258
|
wrappedCommands.push(command);
|
|
9291
9259
|
} else {
|
|
9292
9260
|
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
@@ -9710,9 +9678,7 @@ const renderHoverDom = {
|
|
|
9710
9678
|
const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
|
|
9711
9679
|
return [/* method */SetDom2, dom];
|
|
9712
9680
|
},
|
|
9713
|
-
isEqual(oldState, newState)
|
|
9714
|
-
return oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics;
|
|
9715
|
-
}
|
|
9681
|
+
isEqual: (oldState, newState) => oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics
|
|
9716
9682
|
};
|
|
9717
9683
|
const renderBounds$2 = {
|
|
9718
9684
|
apply(oldState, newState) {
|
|
@@ -9724,9 +9690,7 @@ const renderBounds$2 = {
|
|
|
9724
9690
|
} = newState;
|
|
9725
9691
|
return [SetBounds, x, y, width, height];
|
|
9726
9692
|
},
|
|
9727
|
-
isEqual(oldState, newState)
|
|
9728
|
-
return oldState.x === newState.x && oldState.y === newState.y;
|
|
9729
|
-
}
|
|
9693
|
+
isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y
|
|
9730
9694
|
};
|
|
9731
9695
|
const render$9 = [renderHoverDom, renderBounds$2];
|
|
9732
9696
|
const renderHover = (oldState, newState) => {
|
|
@@ -9739,6 +9703,7 @@ const renderHover = (oldState, newState) => {
|
|
|
9739
9703
|
return commands;
|
|
9740
9704
|
};
|
|
9741
9705
|
|
|
9706
|
+
const commandsToForward$3 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
|
|
9742
9707
|
const render$8 = widget => {
|
|
9743
9708
|
const commands = renderFull$4(widget.oldState, widget.newState);
|
|
9744
9709
|
const wrappedCommands = [];
|
|
@@ -9746,7 +9711,7 @@ const render$8 = widget => {
|
|
|
9746
9711
|
uid
|
|
9747
9712
|
} = widget.newState;
|
|
9748
9713
|
for (const command of commands) {
|
|
9749
|
-
if (command[0]
|
|
9714
|
+
if (commandsToForward$3.includes(command[0])) {
|
|
9750
9715
|
wrappedCommands.push(command);
|
|
9751
9716
|
} else {
|
|
9752
9717
|
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
@@ -9799,6 +9764,7 @@ const removeWidget$1 = widget => {
|
|
|
9799
9764
|
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
9800
9765
|
};
|
|
9801
9766
|
|
|
9767
|
+
const commandsToForward$2 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
|
|
9802
9768
|
const render$7 = widget => {
|
|
9803
9769
|
const commands = renderFull$4(widget.oldState, widget.newState);
|
|
9804
9770
|
const wrappedCommands = [];
|
|
@@ -9806,7 +9772,7 @@ const render$7 = widget => {
|
|
|
9806
9772
|
uid
|
|
9807
9773
|
} = widget.newState;
|
|
9808
9774
|
for (const command of commands) {
|
|
9809
|
-
if (command[0]
|
|
9775
|
+
if (commandsToForward$2.includes(command[0])) {
|
|
9810
9776
|
wrappedCommands.push(command);
|
|
9811
9777
|
} else {
|
|
9812
9778
|
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
@@ -9903,7 +9869,7 @@ const getEditorSourceActions = async editorId => {
|
|
|
9903
9869
|
languageId
|
|
9904
9870
|
} = newState;
|
|
9905
9871
|
// @ts-ignore
|
|
9906
|
-
const allActions = await invoke$
|
|
9872
|
+
const allActions = await invoke$b('GetEditorSourceActions.getEditorSourceActions');
|
|
9907
9873
|
const filtered = filterActions(allActions, languageId);
|
|
9908
9874
|
return filtered;
|
|
9909
9875
|
};
|
|
@@ -9926,14 +9892,14 @@ const getWordAtOffset = editor => {
|
|
|
9926
9892
|
};
|
|
9927
9893
|
|
|
9928
9894
|
const setFocus = async focusKey => {
|
|
9929
|
-
await invoke$
|
|
9895
|
+
await invoke$b('Focus.setFocus', focusKey);
|
|
9930
9896
|
};
|
|
9931
9897
|
const unsetAdditionalFocus = async focusKey => {
|
|
9932
9898
|
if (!focusKey) {
|
|
9933
9899
|
return;
|
|
9934
9900
|
}
|
|
9935
9901
|
// @ts-ignore
|
|
9936
|
-
await invoke$
|
|
9902
|
+
await invoke$b('Focus.removeAdditionalFocus', focusKey);
|
|
9937
9903
|
};
|
|
9938
9904
|
|
|
9939
9905
|
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
@@ -10089,7 +10055,7 @@ const getDiagnostics$1 = async editorUid => {
|
|
|
10089
10055
|
};
|
|
10090
10056
|
|
|
10091
10057
|
const ensure = async (fontName, fontUrl) => {
|
|
10092
|
-
await invoke$
|
|
10058
|
+
await invoke$c('TextMeasurement.ensureFont', fontName, fontUrl);
|
|
10093
10059
|
};
|
|
10094
10060
|
|
|
10095
10061
|
const getKeyBindings = () => {
|
|
@@ -10647,7 +10613,7 @@ const handleBeforeInput = (editor, inputType, data) => {
|
|
|
10647
10613
|
};
|
|
10648
10614
|
|
|
10649
10615
|
const handleMessagePort = async (port, rpcId) => {
|
|
10650
|
-
const rpc = await create$
|
|
10616
|
+
const rpc = await create$b({
|
|
10651
10617
|
commandMap: {},
|
|
10652
10618
|
messagePort: port
|
|
10653
10619
|
});
|
|
@@ -10756,73 +10722,10 @@ const hotReload = async () => {
|
|
|
10756
10722
|
|
|
10757
10723
|
// TODO ask renderer worker to rerender all editors
|
|
10758
10724
|
// @ts-ignore
|
|
10759
|
-
await invoke$
|
|
10725
|
+
await invoke$b(`Editor.rerender`);
|
|
10760
10726
|
isReloading = false;
|
|
10761
10727
|
};
|
|
10762
10728
|
|
|
10763
|
-
const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
|
|
10764
|
-
await sendMessagePortToExtensionHostWorker(port, rpcId);
|
|
10765
|
-
};
|
|
10766
|
-
|
|
10767
|
-
const createExtensionHostRpc = async () => {
|
|
10768
|
-
try {
|
|
10769
|
-
const initialCommand = 'HandleMessagePort.handleMessagePort2';
|
|
10770
|
-
const rpc = await create$e({
|
|
10771
|
-
commandMap: {},
|
|
10772
|
-
async send(port) {
|
|
10773
|
-
await sendMessagePortToExtensionHostWorker2(port, initialCommand, EditorWorker);
|
|
10774
|
-
}
|
|
10775
|
-
});
|
|
10776
|
-
return rpc;
|
|
10777
|
-
} catch (error) {
|
|
10778
|
-
throw new VError(error, `Failed to create extension host rpc`);
|
|
10779
|
-
}
|
|
10780
|
-
};
|
|
10781
|
-
|
|
10782
|
-
const initializeExtensionHost = async () => {
|
|
10783
|
-
const extensionHostRpc = await createExtensionHostRpc();
|
|
10784
|
-
set$1(extensionHostRpc);
|
|
10785
|
-
};
|
|
10786
|
-
|
|
10787
|
-
const createExtensionManagementWorkerRpc = async () => {
|
|
10788
|
-
try {
|
|
10789
|
-
const rpc = await create$e({
|
|
10790
|
-
commandMap: {},
|
|
10791
|
-
async send(port) {
|
|
10792
|
-
await sendMessagePortToExtensionManagementWorker$1(port, EditorWorker);
|
|
10793
|
-
}
|
|
10794
|
-
});
|
|
10795
|
-
return rpc;
|
|
10796
|
-
} catch (error) {
|
|
10797
|
-
throw new VError(error, `Failed to create extension management worker rpc`);
|
|
10798
|
-
}
|
|
10799
|
-
};
|
|
10800
|
-
|
|
10801
|
-
const initializeExtensionManagementWorker = async () => {
|
|
10802
|
-
try {
|
|
10803
|
-
const rpc = await createExtensionManagementWorkerRpc();
|
|
10804
|
-
set$c(rpc);
|
|
10805
|
-
} catch {
|
|
10806
|
-
// ignore
|
|
10807
|
-
}
|
|
10808
|
-
};
|
|
10809
|
-
|
|
10810
|
-
const send$1 = port => {
|
|
10811
|
-
// @ts-ignore
|
|
10812
|
-
return sendMessagePortToOpenerWorker(port);
|
|
10813
|
-
};
|
|
10814
|
-
const initializeOpenerWorker = async () => {
|
|
10815
|
-
try {
|
|
10816
|
-
const rpc = await create$d({
|
|
10817
|
-
commandMap: {},
|
|
10818
|
-
send: send$1
|
|
10819
|
-
});
|
|
10820
|
-
set$b(rpc);
|
|
10821
|
-
} catch {
|
|
10822
|
-
// ignore
|
|
10823
|
-
}
|
|
10824
|
-
};
|
|
10825
|
-
|
|
10826
10729
|
const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
10827
10730
|
try {
|
|
10828
10731
|
await sendMessagePortToSyntaxHighlightingWorker$1(port);
|
|
@@ -10836,7 +10739,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
|
10836
10739
|
|
|
10837
10740
|
const createSyntaxHighlightingWorkerRpc = async () => {
|
|
10838
10741
|
try {
|
|
10839
|
-
const rpc = await create$
|
|
10742
|
+
const rpc = await create$d({
|
|
10840
10743
|
commandMap: {},
|
|
10841
10744
|
send: sendMessagePortToSyntaxHighlightingWorker
|
|
10842
10745
|
});
|
|
@@ -10857,17 +10760,6 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
|
|
|
10857
10760
|
}
|
|
10858
10761
|
};
|
|
10859
10762
|
|
|
10860
|
-
const send = port => {
|
|
10861
|
-
return sendMessagePortToTextMeasurementWorker(port);
|
|
10862
|
-
};
|
|
10863
|
-
const initializeTextMeasurementWorker = async () => {
|
|
10864
|
-
const rpc = await create$d({
|
|
10865
|
-
commandMap: {},
|
|
10866
|
-
send
|
|
10867
|
-
});
|
|
10868
|
-
set$9(rpc);
|
|
10869
|
-
};
|
|
10870
|
-
|
|
10871
10763
|
const launchCompletionWorker = async () => {
|
|
10872
10764
|
const name = 'Completion Worker';
|
|
10873
10765
|
const url = 'completionWorkerMain.js';
|
|
@@ -10878,7 +10770,7 @@ const launchCompletionWorker = async () => {
|
|
|
10878
10770
|
|
|
10879
10771
|
const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
10880
10772
|
setFactory(launchCompletionWorker);
|
|
10881
|
-
await
|
|
10773
|
+
await initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental);
|
|
10882
10774
|
};
|
|
10883
10775
|
|
|
10884
10776
|
const kLineHeight = 'editor.lineHeight';
|
|
@@ -11062,8 +10954,8 @@ const loadContent = async (state, savedState) => {
|
|
|
11062
10954
|
};
|
|
11063
10955
|
|
|
11064
10956
|
// TODO move cursor
|
|
11065
|
-
// TODO multiple cursors ->
|
|
11066
|
-
// TODO with selection ->
|
|
10957
|
+
// TODO multiple cursors -> VS Code removes multiple cursors
|
|
10958
|
+
// TODO with selection -> VS Code moves whole selection
|
|
11067
10959
|
const moveLineDown = editor => {
|
|
11068
10960
|
// const rowIndex = editor.cursor.rowIndex
|
|
11069
10961
|
// if (rowIndex === editor.lines.length - 1) {
|
|
@@ -11127,19 +11019,34 @@ const registerListener = (listenerType, rpcId) => {
|
|
|
11127
11019
|
registerListener$1(listenerType, rpcId);
|
|
11128
11020
|
};
|
|
11129
11021
|
|
|
11130
|
-
const getCss =
|
|
11131
|
-
return
|
|
11132
|
-
--
|
|
11022
|
+
const getCss = (rowHeight, scrollBarHeight, scrollBarTop) => {
|
|
11023
|
+
return `.Editor {
|
|
11024
|
+
--EditorRowHeight: ${rowHeight}px;
|
|
11025
|
+
--ScrollBarHeight: ${scrollBarHeight}px;
|
|
11026
|
+
--ScrollBarTop: ${scrollBarTop}px;
|
|
11027
|
+
}
|
|
11028
|
+
.Editor .EditorRow {
|
|
11029
|
+
height: var(--EditorRowHeight);
|
|
11030
|
+
line-height: var(--EditorRowHeight);
|
|
11031
|
+
}
|
|
11032
|
+
.Editor .ScrollBarThumbVertical {
|
|
11033
|
+
height: var(--ScrollBarHeight);
|
|
11034
|
+
translate: 0px var(--ScrollBarTop);
|
|
11133
11035
|
}
|
|
11134
11036
|
`;
|
|
11135
11037
|
};
|
|
11136
11038
|
|
|
11137
11039
|
const renderCss = (oldState, newState) => {
|
|
11138
11040
|
const {
|
|
11139
|
-
|
|
11041
|
+
deltaY,
|
|
11042
|
+
finalDeltaY,
|
|
11043
|
+
height,
|
|
11044
|
+
rowHeight,
|
|
11045
|
+
scrollBarHeight,
|
|
11140
11046
|
uid
|
|
11141
11047
|
} = newState;
|
|
11142
|
-
const
|
|
11048
|
+
const scrollBarTop = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
|
|
11049
|
+
const css = getCss(rowHeight, scrollBarHeight, scrollBarTop);
|
|
11143
11050
|
return [SetCss$1, uid, css];
|
|
11144
11051
|
};
|
|
11145
11052
|
|
|
@@ -11223,12 +11130,12 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
11223
11130
|
};
|
|
11224
11131
|
|
|
11225
11132
|
const compareNodes = (oldNode, newNode) => {
|
|
11226
|
-
const patches = [];
|
|
11227
11133
|
// Check if node type changed - return null to signal incompatible nodes
|
|
11228
11134
|
// (caller should handle this with a Replace operation)
|
|
11229
11135
|
if (oldNode.type !== newNode.type) {
|
|
11230
11136
|
return null;
|
|
11231
11137
|
}
|
|
11138
|
+
const patches = [];
|
|
11232
11139
|
// Handle reference nodes - special handling for uid changes
|
|
11233
11140
|
if (oldNode.type === Reference) {
|
|
11234
11141
|
if (oldNode.uid !== newNode.uid) {
|
|
@@ -11264,7 +11171,7 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
11264
11171
|
}
|
|
11265
11172
|
// Check for removed attributes
|
|
11266
11173
|
for (const key of oldKeys) {
|
|
11267
|
-
if (!(key
|
|
11174
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
11268
11175
|
patches.push({
|
|
11269
11176
|
type: RemoveAttribute,
|
|
11270
11177
|
key
|
|
@@ -11440,15 +11347,12 @@ const getEditorInputVirtualDom = () => {
|
|
|
11440
11347
|
};
|
|
11441
11348
|
|
|
11442
11349
|
const getCursorsVirtualDom = cursors => {
|
|
11443
|
-
const dom =
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
type: Div
|
|
11450
|
-
});
|
|
11451
|
-
}
|
|
11350
|
+
const dom = Array.from(cursors, translate => ({
|
|
11351
|
+
childCount: 0,
|
|
11352
|
+
className: EditorCursor,
|
|
11353
|
+
translate,
|
|
11354
|
+
type: Div
|
|
11355
|
+
}));
|
|
11452
11356
|
return dom;
|
|
11453
11357
|
};
|
|
11454
11358
|
|
|
@@ -11802,9 +11706,7 @@ const renderLines = {
|
|
|
11802
11706
|
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine);
|
|
11803
11707
|
return [/* method */'setText', dom];
|
|
11804
11708
|
},
|
|
11805
|
-
isEqual(oldState, newState)
|
|
11806
|
-
return oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled;
|
|
11807
|
-
}
|
|
11709
|
+
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
|
|
11808
11710
|
};
|
|
11809
11711
|
const renderSelections = {
|
|
11810
11712
|
apply: (oldState, newState) => {
|
|
@@ -11816,9 +11718,7 @@ const renderSelections = {
|
|
|
11816
11718
|
const selectionsDom = getSelectionsVirtualDom(selectionInfos);
|
|
11817
11719
|
return [/* method */'setSelections', cursorsDom, selectionsDom];
|
|
11818
11720
|
},
|
|
11819
|
-
isEqual(oldState, newState)
|
|
11820
|
-
return oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos;
|
|
11821
|
-
}
|
|
11721
|
+
isEqual: (oldState, newState) => oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos
|
|
11822
11722
|
};
|
|
11823
11723
|
const renderScrollBarY = {
|
|
11824
11724
|
apply(oldState, newState) {
|
|
@@ -11827,9 +11727,7 @@ const renderScrollBarY = {
|
|
|
11827
11727
|
const heightPx = `${newState.scrollBarHeight}px`;
|
|
11828
11728
|
return [/* method */'setScrollBar', translate, heightPx];
|
|
11829
11729
|
},
|
|
11830
|
-
isEqual(oldState, newState)
|
|
11831
|
-
return oldState.deltaY === newState.deltaY && oldState.scrollBarHeight === newState.scrollBarHeight;
|
|
11832
|
-
}
|
|
11730
|
+
isEqual: (oldState, newState) => oldState.deltaY === newState.deltaY && oldState.scrollBarHeight === newState.scrollBarHeight
|
|
11833
11731
|
};
|
|
11834
11732
|
const renderScrollBarX = {
|
|
11835
11733
|
apply(oldState, newState) {
|
|
@@ -11837,25 +11735,15 @@ const renderScrollBarX = {
|
|
|
11837
11735
|
const scrollBarX = newState.deltaX / newState.longestLineWidth * newState.width;
|
|
11838
11736
|
return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
|
|
11839
11737
|
},
|
|
11840
|
-
isEqual(oldState, newState)
|
|
11841
|
-
return oldState.longestLineWidth === newState.longestLineWidth && oldState.deltaX === newState.deltaX;
|
|
11842
|
-
}
|
|
11738
|
+
isEqual: (oldState, newState) => oldState.longestLineWidth === newState.longestLineWidth && oldState.deltaX === newState.deltaX
|
|
11843
11739
|
};
|
|
11844
11740
|
const renderFocus$1 = {
|
|
11845
|
-
apply(oldState, newState)
|
|
11846
|
-
|
|
11847
|
-
},
|
|
11848
|
-
isEqual(oldState, newState) {
|
|
11849
|
-
return oldState.focused === newState.focused;
|
|
11850
|
-
}
|
|
11741
|
+
apply: (oldState, newState) => [/* method */'setFocused', newState.focused],
|
|
11742
|
+
isEqual: (oldState, newState) => oldState.focused === newState.focused
|
|
11851
11743
|
};
|
|
11852
11744
|
const renderFocusContext = {
|
|
11853
|
-
apply(oldState, newState)
|
|
11854
|
-
|
|
11855
|
-
},
|
|
11856
|
-
isEqual(oldState, newState) {
|
|
11857
|
-
return oldState.focus === newState.focus;
|
|
11858
|
-
}
|
|
11745
|
+
apply: (oldState, newState) => [SetFocusContext$1, newState.uid, newState.focus, 0, newState.uid, 'Editor'],
|
|
11746
|
+
isEqual: (oldState, newState) => oldState.focus === newState.focus
|
|
11859
11747
|
};
|
|
11860
11748
|
const renderAdditionalFocusContext = {
|
|
11861
11749
|
apply(oldState, newState) {
|
|
@@ -11864,18 +11752,14 @@ const renderAdditionalFocusContext = {
|
|
|
11864
11752
|
}
|
|
11865
11753
|
return ['viewlet.unsetAdditionalFocus', newState.uid, newState.additionalFocus];
|
|
11866
11754
|
},
|
|
11867
|
-
isEqual(oldState, newState)
|
|
11868
|
-
return oldState.additionalFocus === newState.additionalFocus;
|
|
11869
|
-
}
|
|
11755
|
+
isEqual: (oldState, newState) => oldState.additionalFocus === newState.additionalFocus
|
|
11870
11756
|
};
|
|
11871
11757
|
const renderDecorations = {
|
|
11872
11758
|
apply(oldState, newState) {
|
|
11873
11759
|
const dom = getDiagnosticsVirtualDom(newState.visualDecorations || []);
|
|
11874
11760
|
return ['setDecorationsDom', dom];
|
|
11875
11761
|
},
|
|
11876
|
-
isEqual(oldState, newState)
|
|
11877
|
-
return oldState.visualDecorations === newState.visualDecorations;
|
|
11878
|
-
}
|
|
11762
|
+
isEqual: (oldState, newState) => oldState.visualDecorations === newState.visualDecorations
|
|
11879
11763
|
};
|
|
11880
11764
|
const renderGutterInfo = {
|
|
11881
11765
|
apply(oldState, newState) {
|
|
@@ -11893,9 +11777,7 @@ const renderGutterInfo = {
|
|
|
11893
11777
|
const dom = getEditorGutterVirtualDom$1(gutterInfos);
|
|
11894
11778
|
return ['renderGutter', dom];
|
|
11895
11779
|
},
|
|
11896
|
-
isEqual(oldState, newState)
|
|
11897
|
-
return oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY;
|
|
11898
|
-
}
|
|
11780
|
+
isEqual: (oldState, newState) => oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY
|
|
11899
11781
|
};
|
|
11900
11782
|
const renderWidgets = {
|
|
11901
11783
|
apply(oldState, newState) {
|
|
@@ -11913,14 +11795,14 @@ const renderWidgets = {
|
|
|
11913
11795
|
newWidgetMap[newWidget.id] = newWidget;
|
|
11914
11796
|
}
|
|
11915
11797
|
for (const oldWidget of oldWidgets) {
|
|
11916
|
-
if (oldWidget.id
|
|
11798
|
+
if (Object.hasOwn(newWidgetMap, oldWidget.id)) {
|
|
11917
11799
|
changedWidgets.push(newWidgetMap[oldWidget.id]);
|
|
11918
11800
|
} else {
|
|
11919
11801
|
removedWidgets.push(oldWidget);
|
|
11920
11802
|
}
|
|
11921
11803
|
}
|
|
11922
11804
|
for (const newWidget of newWidgets) {
|
|
11923
|
-
if (newWidget.id
|
|
11805
|
+
if (Object.hasOwn(oldWidgetMap, newWidget.id)) ; else {
|
|
11924
11806
|
addedWidgets.push(newWidget);
|
|
11925
11807
|
}
|
|
11926
11808
|
}
|
|
@@ -11949,9 +11831,7 @@ const renderWidgets = {
|
|
|
11949
11831
|
const filteredCommands = allCommands.filter(item => item[0] !== 'Viewlet.setFocusContext');
|
|
11950
11832
|
return filteredCommands;
|
|
11951
11833
|
},
|
|
11952
|
-
isEqual(oldState, newState)
|
|
11953
|
-
return oldState.widgets === newState.widgets;
|
|
11954
|
-
},
|
|
11834
|
+
isEqual: (oldState, newState) => oldState.widgets === newState.widgets,
|
|
11955
11835
|
multiple: true
|
|
11956
11836
|
};
|
|
11957
11837
|
const render$6 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
|
|
@@ -12035,6 +11915,7 @@ const renderEventListeners = () => {
|
|
|
12035
11915
|
}, {
|
|
12036
11916
|
name: HandleScrollBarVerticalPointerDown,
|
|
12037
11917
|
params: ['handleScrollBarVerticalPointerDown', ClientY],
|
|
11918
|
+
preventDefault: true,
|
|
12038
11919
|
trackPointerEvents: [HandleScrollBarVerticalPointerMove, HandleScrollBarVerticalPointerUp]
|
|
12039
11920
|
}, {
|
|
12040
11921
|
name: HandleScrollBarVerticalPointerMove,
|
|
@@ -12064,6 +11945,10 @@ const saveState = (state, savedState) => {
|
|
|
12064
11945
|
};
|
|
12065
11946
|
};
|
|
12066
11947
|
|
|
11948
|
+
const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
|
|
11949
|
+
await sendMessagePortToExtensionHostWorker(port, rpcId);
|
|
11950
|
+
};
|
|
11951
|
+
|
|
12067
11952
|
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
12068
11953
|
await sendMessagePortToExtensionManagementWorker$1(port, rpcId);
|
|
12069
11954
|
};
|
|
@@ -12114,7 +11999,7 @@ const updateDebugInfo = async debugId => {
|
|
|
12114
11999
|
};
|
|
12115
12000
|
set$7(key, oldState, newEditor);
|
|
12116
12001
|
// @ts-ignore
|
|
12117
|
-
await invoke$
|
|
12002
|
+
await invoke$b('Editor.rerender', key);
|
|
12118
12003
|
};
|
|
12119
12004
|
|
|
12120
12005
|
// TODO wrap commands globally, not per editor
|
|
@@ -12401,14 +12286,76 @@ for (const [key, value] of Object.entries(commandMap)) {
|
|
|
12401
12286
|
}
|
|
12402
12287
|
}
|
|
12403
12288
|
|
|
12404
|
-
const
|
|
12405
|
-
|
|
12406
|
-
const rpc = await create$
|
|
12289
|
+
const createExtensionHostRpc = async () => {
|
|
12290
|
+
const initialCommand = 'HandleMessagePort.handleMessagePort2';
|
|
12291
|
+
const rpc = await create$c({
|
|
12292
|
+
commandMap: {},
|
|
12293
|
+
async send(port) {
|
|
12294
|
+
await sendMessagePortToExtensionHostWorker2(port, initialCommand, EditorWorker);
|
|
12295
|
+
}
|
|
12296
|
+
});
|
|
12297
|
+
return rpc;
|
|
12298
|
+
};
|
|
12299
|
+
|
|
12300
|
+
const initializeExtensionHost = async () => {
|
|
12301
|
+
const extensionHostRpc = await createExtensionHostRpc();
|
|
12302
|
+
set$1(extensionHostRpc);
|
|
12303
|
+
};
|
|
12304
|
+
|
|
12305
|
+
const createExtensionManagementWorkerRpc = async () => {
|
|
12306
|
+
const rpc = await create$c({
|
|
12307
|
+
commandMap: {},
|
|
12308
|
+
async send(port) {
|
|
12309
|
+
await sendMessagePortToExtensionManagementWorker$1(port, EditorWorker);
|
|
12310
|
+
}
|
|
12311
|
+
});
|
|
12312
|
+
return rpc;
|
|
12313
|
+
};
|
|
12314
|
+
|
|
12315
|
+
const initializeExtensionManagementWorker = async () => {
|
|
12316
|
+
try {
|
|
12317
|
+
const rpc = await createExtensionManagementWorkerRpc();
|
|
12318
|
+
set$c(rpc);
|
|
12319
|
+
} catch {
|
|
12320
|
+
// ignore
|
|
12321
|
+
}
|
|
12322
|
+
};
|
|
12323
|
+
|
|
12324
|
+
const send$1 = port => {
|
|
12325
|
+
// @ts-ignore
|
|
12326
|
+
return sendMessagePortToOpenerWorker(port);
|
|
12327
|
+
};
|
|
12328
|
+
const initializeOpenerWorker = async () => {
|
|
12329
|
+
const rpc = await create$c({
|
|
12330
|
+
commandMap: {},
|
|
12331
|
+
send: send$1
|
|
12332
|
+
});
|
|
12333
|
+
set$b(rpc);
|
|
12334
|
+
};
|
|
12335
|
+
|
|
12336
|
+
const initializeRendererWorker = async () => {
|
|
12337
|
+
const rpc = await create$a({
|
|
12407
12338
|
commandMap: commandMap
|
|
12408
12339
|
});
|
|
12340
|
+
set$9(rpc);
|
|
12341
|
+
};
|
|
12342
|
+
|
|
12343
|
+
const send = port => {
|
|
12344
|
+
return sendMessagePortToTextMeasurementWorker(port);
|
|
12345
|
+
};
|
|
12346
|
+
const initializeTextMeasurementWorker = async () => {
|
|
12347
|
+
const rpc = await create$c({
|
|
12348
|
+
commandMap: {},
|
|
12349
|
+
send
|
|
12350
|
+
});
|
|
12409
12351
|
set$a(rpc);
|
|
12410
12352
|
};
|
|
12411
12353
|
|
|
12354
|
+
const listen = async () => {
|
|
12355
|
+
registerCommands(commandMap);
|
|
12356
|
+
await Promise.all([initializeRendererWorker(), initializeExtensionHost(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
|
|
12357
|
+
};
|
|
12358
|
+
|
|
12412
12359
|
const CodeGeneratorInput = 'CodeGeneratorInput';
|
|
12413
12360
|
|
|
12414
12361
|
const getCodeGeneratorVirtualDom = state => {
|
|
@@ -12436,9 +12383,7 @@ const renderContent$1 = {
|
|
|
12436
12383
|
const dom = getCodeGeneratorVirtualDom();
|
|
12437
12384
|
return [SetDom2, newState.uid, dom];
|
|
12438
12385
|
},
|
|
12439
|
-
isEqual(oldState, newState)
|
|
12440
|
-
return oldState.questions === newState.questions;
|
|
12441
|
-
}
|
|
12386
|
+
isEqual: (oldState, newState) => oldState.questions === newState.questions
|
|
12442
12387
|
};
|
|
12443
12388
|
const renderBounds$1 = {
|
|
12444
12389
|
apply(oldState, newState) {
|
|
@@ -12450,17 +12395,11 @@ const renderBounds$1 = {
|
|
|
12450
12395
|
} = newState;
|
|
12451
12396
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
12452
12397
|
},
|
|
12453
|
-
isEqual(oldState, newState)
|
|
12454
|
-
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
12455
|
-
}
|
|
12398
|
+
isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height
|
|
12456
12399
|
};
|
|
12457
12400
|
const renderFocus = {
|
|
12458
|
-
apply(oldState, newState)
|
|
12459
|
-
|
|
12460
|
-
},
|
|
12461
|
-
isEqual(oldState, newState) {
|
|
12462
|
-
return oldState.focused === newState.focused && oldState.focusSource === newState.focusSource;
|
|
12463
|
-
}
|
|
12401
|
+
apply: (oldState, newState) => [Focus, '.CodeGeneratorInput', newState.focusSource],
|
|
12402
|
+
isEqual: (oldState, newState) => oldState.focused === newState.focused && oldState.focusSource === newState.focusSource
|
|
12464
12403
|
};
|
|
12465
12404
|
const render$5 = [renderContent$1, renderBounds$1, renderFocus];
|
|
12466
12405
|
const renderFull$2 = (oldState, newState) => {
|
|
@@ -12508,6 +12447,7 @@ const renderFull$1 = (oldState, newState) => {
|
|
|
12508
12447
|
return commands;
|
|
12509
12448
|
};
|
|
12510
12449
|
|
|
12450
|
+
const commandsToForward$1 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetUid];
|
|
12511
12451
|
const render$3 = widget => {
|
|
12512
12452
|
const commands = renderFull$1(widget.oldState, widget.newState);
|
|
12513
12453
|
const wrappedCommands = [];
|
|
@@ -12515,7 +12455,7 @@ const render$3 = widget => {
|
|
|
12515
12455
|
uid
|
|
12516
12456
|
} = widget.newState;
|
|
12517
12457
|
for (const command of commands) {
|
|
12518
|
-
if (command[0]
|
|
12458
|
+
if (commandsToForward$1.includes(command[0])) {
|
|
12519
12459
|
wrappedCommands.push(command);
|
|
12520
12460
|
} else {
|
|
12521
12461
|
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
@@ -12574,9 +12514,7 @@ const renderContent = {
|
|
|
12574
12514
|
const dom = getCompletionDetailVirtualDom(newState.content);
|
|
12575
12515
|
return [SetDom2, newState.uid, dom];
|
|
12576
12516
|
},
|
|
12577
|
-
isEqual(oldState, newState)
|
|
12578
|
-
return oldState.content === newState.content;
|
|
12579
|
-
}
|
|
12517
|
+
isEqual: (oldState, newState) => oldState.content === newState.content
|
|
12580
12518
|
};
|
|
12581
12519
|
const renderBounds = {
|
|
12582
12520
|
apply(oldState, newState) {
|
|
@@ -12588,9 +12526,7 @@ const renderBounds = {
|
|
|
12588
12526
|
} = newState;
|
|
12589
12527
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
12590
12528
|
},
|
|
12591
|
-
isEqual(oldState, newState)
|
|
12592
|
-
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
12593
|
-
}
|
|
12529
|
+
isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height
|
|
12594
12530
|
};
|
|
12595
12531
|
const render$2 = [renderContent, renderBounds];
|
|
12596
12532
|
const renderFull = (oldState, newState) => {
|
|
@@ -12662,6 +12598,7 @@ const EditorCompletionDetailWidget = {
|
|
|
12662
12598
|
render: render$1
|
|
12663
12599
|
};
|
|
12664
12600
|
|
|
12601
|
+
const commandsToForward = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
|
|
12665
12602
|
const render = widget => {
|
|
12666
12603
|
const commands = renderFull$4(widget.oldState, widget.newState);
|
|
12667
12604
|
const wrappedCommands = [];
|
|
@@ -12669,7 +12606,7 @@ const render = widget => {
|
|
|
12669
12606
|
uid
|
|
12670
12607
|
} = widget.newState;
|
|
12671
12608
|
for (const command of commands) {
|
|
12672
|
-
if (command[0]
|
|
12609
|
+
if (commandsToForward.includes(command[0])) {
|
|
12673
12610
|
wrappedCommands.push(command);
|
|
12674
12611
|
} else {
|
|
12675
12612
|
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|