@lvce-editor/editor-worker 18.2.0 → 18.4.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 +984 -152
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -474,7 +474,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
474
474
|
return promise;
|
|
475
475
|
};
|
|
476
476
|
const Message$1 = 3;
|
|
477
|
-
const create$5$
|
|
477
|
+
const create$5$1 = async ({
|
|
478
478
|
isMessagePortOpen,
|
|
479
479
|
messagePort
|
|
480
480
|
}) => {
|
|
@@ -525,14 +525,35 @@ const wrap$5 = messagePort => {
|
|
|
525
525
|
};
|
|
526
526
|
const IpcParentWithMessagePort$1 = {
|
|
527
527
|
__proto__: null,
|
|
528
|
-
create: create$5$
|
|
528
|
+
create: create$5$1,
|
|
529
529
|
signal: signal$1,
|
|
530
530
|
wrap: wrap$5
|
|
531
531
|
};
|
|
532
532
|
|
|
533
|
+
class CommandNotFoundError extends Error {
|
|
534
|
+
constructor(command) {
|
|
535
|
+
super(`Command not found ${command}`);
|
|
536
|
+
this.name = 'CommandNotFoundError';
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
const commands = Object.create(null);
|
|
540
|
+
const register = commandMap => {
|
|
541
|
+
Object.assign(commands, commandMap);
|
|
542
|
+
};
|
|
543
|
+
const getCommand = key => {
|
|
544
|
+
return commands[key];
|
|
545
|
+
};
|
|
546
|
+
const execute$1 = (command, ...args) => {
|
|
547
|
+
const fn = getCommand(command);
|
|
548
|
+
if (!fn) {
|
|
549
|
+
throw new CommandNotFoundError(command);
|
|
550
|
+
}
|
|
551
|
+
return fn(...args);
|
|
552
|
+
};
|
|
553
|
+
|
|
533
554
|
const Two$1 = '2.0';
|
|
534
555
|
const callbacks = Object.create(null);
|
|
535
|
-
const get$
|
|
556
|
+
const get$9 = id => {
|
|
536
557
|
return callbacks[id];
|
|
537
558
|
};
|
|
538
559
|
const remove$9 = id => {
|
|
@@ -681,7 +702,7 @@ const warn$1 = (...args) => {
|
|
|
681
702
|
console.warn(...args);
|
|
682
703
|
};
|
|
683
704
|
const resolve = (id, response) => {
|
|
684
|
-
const fn = get$
|
|
705
|
+
const fn = get$9(id);
|
|
685
706
|
if (!fn) {
|
|
686
707
|
console.log(response);
|
|
687
708
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -744,7 +765,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
744
765
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
745
766
|
return create$1$1(id, errorProperty);
|
|
746
767
|
};
|
|
747
|
-
const create$
|
|
768
|
+
const create$j = (message, result) => {
|
|
748
769
|
return {
|
|
749
770
|
jsonrpc: Two$1,
|
|
750
771
|
id: message.id,
|
|
@@ -753,7 +774,7 @@ const create$a = (message, result) => {
|
|
|
753
774
|
};
|
|
754
775
|
const getSuccessResponse = (message, result) => {
|
|
755
776
|
const resultProperty = result ?? null;
|
|
756
|
-
return create$
|
|
777
|
+
return create$j(message, resultProperty);
|
|
757
778
|
};
|
|
758
779
|
const getErrorResponseSimple = (id, error) => {
|
|
759
780
|
return {
|
|
@@ -845,36 +866,17 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
845
866
|
throw new JsonRpcError('unexpected message');
|
|
846
867
|
};
|
|
847
868
|
|
|
848
|
-
class CommandNotFoundError extends Error {
|
|
849
|
-
constructor(command) {
|
|
850
|
-
super(`Command not found ${command}`);
|
|
851
|
-
this.name = 'CommandNotFoundError';
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
const commands = Object.create(null);
|
|
855
|
-
const register = commandMap => {
|
|
856
|
-
Object.assign(commands, commandMap);
|
|
857
|
-
};
|
|
858
|
-
const getCommand = key => {
|
|
859
|
-
return commands[key];
|
|
860
|
-
};
|
|
861
|
-
const execute$1 = (command, ...args) => {
|
|
862
|
-
const fn = getCommand(command);
|
|
863
|
-
if (!fn) {
|
|
864
|
-
throw new CommandNotFoundError(command);
|
|
865
|
-
}
|
|
866
|
-
return fn(...args);
|
|
867
|
-
};
|
|
868
|
-
|
|
869
869
|
const Two = '2.0';
|
|
870
|
-
|
|
870
|
+
|
|
871
|
+
const create$i = (method, params) => {
|
|
871
872
|
return {
|
|
872
873
|
jsonrpc: Two,
|
|
873
874
|
method,
|
|
874
875
|
params
|
|
875
876
|
};
|
|
876
877
|
};
|
|
877
|
-
|
|
878
|
+
|
|
879
|
+
const create$h = (id, method, params) => {
|
|
878
880
|
const message = {
|
|
879
881
|
id,
|
|
880
882
|
jsonrpc: Two,
|
|
@@ -883,15 +885,14 @@ const create$s = (id, method, params) => {
|
|
|
883
885
|
};
|
|
884
886
|
return message;
|
|
885
887
|
};
|
|
888
|
+
|
|
886
889
|
let id = 0;
|
|
887
|
-
const create$
|
|
890
|
+
const create$g = () => {
|
|
888
891
|
return ++id;
|
|
889
892
|
};
|
|
890
893
|
|
|
891
|
-
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
892
|
-
|
|
893
894
|
const registerPromise = map => {
|
|
894
|
-
const id = create$
|
|
895
|
+
const id = create$g();
|
|
895
896
|
const {
|
|
896
897
|
promise,
|
|
897
898
|
resolve
|
|
@@ -909,7 +910,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
909
910
|
id,
|
|
910
911
|
promise
|
|
911
912
|
} = registerPromise(callbacks);
|
|
912
|
-
const message = create$
|
|
913
|
+
const message = create$h(id, method, params);
|
|
913
914
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
914
915
|
ipc.sendAndTransfer(message);
|
|
915
916
|
} else {
|
|
@@ -945,12 +946,13 @@ const createRpc = ipc => {
|
|
|
945
946
|
* @deprecated
|
|
946
947
|
*/
|
|
947
948
|
send(method, ...params) {
|
|
948
|
-
const message = create$
|
|
949
|
+
const message = create$i(method, params);
|
|
949
950
|
ipc.send(message);
|
|
950
951
|
}
|
|
951
952
|
};
|
|
952
953
|
return rpc;
|
|
953
954
|
};
|
|
955
|
+
|
|
954
956
|
const requiresSocket = () => {
|
|
955
957
|
return false;
|
|
956
958
|
};
|
|
@@ -965,6 +967,7 @@ const handleMessage = event => {
|
|
|
965
967
|
const actualExecute = event?.target?.execute || execute$1;
|
|
966
968
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError$1, actualRequiresSocket);
|
|
967
969
|
};
|
|
970
|
+
|
|
968
971
|
const handleIpc = ipc => {
|
|
969
972
|
if ('addEventListener' in ipc) {
|
|
970
973
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -973,6 +976,7 @@ const handleIpc = ipc => {
|
|
|
973
976
|
ipc.on('message', handleMessage);
|
|
974
977
|
}
|
|
975
978
|
};
|
|
979
|
+
|
|
976
980
|
const listen$1 = async (module, options) => {
|
|
977
981
|
const rawIpc = await module.listen(options);
|
|
978
982
|
if (module.signal) {
|
|
@@ -982,8 +986,6 @@ const listen$1 = async (module, options) => {
|
|
|
982
986
|
return ipc;
|
|
983
987
|
};
|
|
984
988
|
|
|
985
|
-
/* eslint-disable @typescript-eslint/no-misused-promises */
|
|
986
|
-
|
|
987
989
|
const createSharedLazyRpc = factory => {
|
|
988
990
|
let rpcPromise;
|
|
989
991
|
const getOrCreate = () => {
|
|
@@ -1011,24 +1013,22 @@ const createSharedLazyRpc = factory => {
|
|
|
1011
1013
|
}
|
|
1012
1014
|
};
|
|
1013
1015
|
};
|
|
1014
|
-
|
|
1016
|
+
|
|
1017
|
+
const create$f = async ({
|
|
1015
1018
|
commandMap,
|
|
1016
1019
|
isMessagePortOpen,
|
|
1017
1020
|
send
|
|
1018
1021
|
}) => {
|
|
1019
1022
|
return createSharedLazyRpc(() => {
|
|
1020
|
-
return create$
|
|
1023
|
+
return create$c({
|
|
1021
1024
|
commandMap,
|
|
1022
1025
|
isMessagePortOpen,
|
|
1023
1026
|
send
|
|
1024
1027
|
});
|
|
1025
1028
|
});
|
|
1026
1029
|
};
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
create: create$j
|
|
1030
|
-
};
|
|
1031
|
-
const create$5$1 = async ({
|
|
1030
|
+
|
|
1031
|
+
const create$e = async ({
|
|
1032
1032
|
commandMap,
|
|
1033
1033
|
isMessagePortOpen = true,
|
|
1034
1034
|
messagePort
|
|
@@ -1045,20 +1045,18 @@ const create$5$1 = async ({
|
|
|
1045
1045
|
messagePort.start();
|
|
1046
1046
|
return rpc;
|
|
1047
1047
|
};
|
|
1048
|
-
|
|
1048
|
+
|
|
1049
|
+
const create$d = async ({
|
|
1049
1050
|
commandMap,
|
|
1050
1051
|
messagePort
|
|
1051
1052
|
}) => {
|
|
1052
|
-
return create$
|
|
1053
|
+
return create$e({
|
|
1053
1054
|
commandMap,
|
|
1054
1055
|
messagePort
|
|
1055
1056
|
});
|
|
1056
1057
|
};
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
create: create$4$1
|
|
1060
|
-
};
|
|
1061
|
-
const create$3$1 = async ({
|
|
1058
|
+
|
|
1059
|
+
const create$c = async ({
|
|
1062
1060
|
commandMap,
|
|
1063
1061
|
isMessagePortOpen,
|
|
1064
1062
|
send
|
|
@@ -1068,17 +1066,14 @@ const create$3$1 = async ({
|
|
|
1068
1066
|
port2
|
|
1069
1067
|
} = new MessageChannel();
|
|
1070
1068
|
await send(port1);
|
|
1071
|
-
return create$
|
|
1069
|
+
return create$e({
|
|
1072
1070
|
commandMap,
|
|
1073
1071
|
isMessagePortOpen,
|
|
1074
1072
|
messagePort: port2
|
|
1075
1073
|
});
|
|
1076
1074
|
};
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
create: create$3$1
|
|
1080
|
-
};
|
|
1081
|
-
const create$2$1 = async ({
|
|
1075
|
+
|
|
1076
|
+
const create$b = async ({
|
|
1082
1077
|
commandMap
|
|
1083
1078
|
}) => {
|
|
1084
1079
|
// TODO create a commandMap per rpc instance
|
|
@@ -1088,29 +1083,9 @@ const create$2$1 = async ({
|
|
|
1088
1083
|
const rpc = createRpc(ipc);
|
|
1089
1084
|
return rpc;
|
|
1090
1085
|
};
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
};
|
|
1095
|
-
const createMockRpc = ({
|
|
1096
|
-
commandMap
|
|
1097
|
-
}) => {
|
|
1098
|
-
const invocations = [];
|
|
1099
|
-
const invoke = (method, ...params) => {
|
|
1100
|
-
invocations.push([method, ...params]);
|
|
1101
|
-
const command = commandMap[method];
|
|
1102
|
-
if (!command) {
|
|
1103
|
-
throw new Error(`command ${method} not found`);
|
|
1104
|
-
}
|
|
1105
|
-
return command(...params);
|
|
1106
|
-
};
|
|
1107
|
-
const mockRpc = {
|
|
1108
|
-
invocations,
|
|
1109
|
-
invoke,
|
|
1110
|
-
invokeAndTransfer: invoke
|
|
1111
|
-
};
|
|
1112
|
-
return mockRpc;
|
|
1113
|
-
};
|
|
1086
|
+
|
|
1087
|
+
const Text$1 = 12;
|
|
1088
|
+
const Reference = 100;
|
|
1114
1089
|
|
|
1115
1090
|
const Backspace = 1;
|
|
1116
1091
|
const Tab$1 = 2;
|
|
@@ -1177,15 +1152,39 @@ const OpenerWorker = 4561;
|
|
|
1177
1152
|
const RendererWorker$1 = 1;
|
|
1178
1153
|
const TextMeasurementWorker = 7011;
|
|
1179
1154
|
|
|
1155
|
+
const FocusSelector = 'Viewlet.focusSelector';
|
|
1156
|
+
const SetCss$1 = 'Viewlet.setCss';
|
|
1180
1157
|
const SetFocusContext$1 = 'Viewlet.setFocusContext';
|
|
1158
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
1181
1159
|
|
|
1182
1160
|
const FocusEditorText$1 = 12;
|
|
1161
|
+
const FocusExplorer = 13;
|
|
1162
|
+
|
|
1163
|
+
const createMockRpc = ({
|
|
1164
|
+
commandMap
|
|
1165
|
+
}) => {
|
|
1166
|
+
const invocations = [];
|
|
1167
|
+
const invoke = (method, ...params) => {
|
|
1168
|
+
invocations.push([method, ...params]);
|
|
1169
|
+
const command = commandMap[method];
|
|
1170
|
+
if (!command) {
|
|
1171
|
+
throw new Error(`command ${method} not found`);
|
|
1172
|
+
}
|
|
1173
|
+
return command(...params);
|
|
1174
|
+
};
|
|
1175
|
+
const mockRpc = {
|
|
1176
|
+
invocations,
|
|
1177
|
+
invoke,
|
|
1178
|
+
invokeAndTransfer: invoke
|
|
1179
|
+
};
|
|
1180
|
+
return mockRpc;
|
|
1181
|
+
};
|
|
1183
1182
|
|
|
1184
1183
|
const rpcs = Object.create(null);
|
|
1185
|
-
const set$
|
|
1184
|
+
const set$f = (id, rpc) => {
|
|
1186
1185
|
rpcs[id] = rpc;
|
|
1187
1186
|
};
|
|
1188
|
-
const get$
|
|
1187
|
+
const get$8 = id => {
|
|
1189
1188
|
return rpcs[id];
|
|
1190
1189
|
};
|
|
1191
1190
|
const remove$8 = id => {
|
|
@@ -1193,21 +1192,21 @@ const remove$8 = id => {
|
|
|
1193
1192
|
};
|
|
1194
1193
|
|
|
1195
1194
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1196
|
-
const create$
|
|
1195
|
+
const create$a = rpcId => {
|
|
1197
1196
|
return {
|
|
1198
1197
|
async dispose() {
|
|
1199
|
-
const rpc = get$
|
|
1198
|
+
const rpc = get$8(rpcId);
|
|
1200
1199
|
await rpc.dispose();
|
|
1201
1200
|
},
|
|
1202
1201
|
// @ts-ignore
|
|
1203
1202
|
invoke(method, ...params) {
|
|
1204
|
-
const rpc = get$
|
|
1203
|
+
const rpc = get$8(rpcId);
|
|
1205
1204
|
// @ts-ignore
|
|
1206
1205
|
return rpc.invoke(method, ...params);
|
|
1207
1206
|
},
|
|
1208
1207
|
// @ts-ignore
|
|
1209
1208
|
invokeAndTransfer(method, ...params) {
|
|
1210
|
-
const rpc = get$
|
|
1209
|
+
const rpc = get$8(rpcId);
|
|
1211
1210
|
// @ts-ignore
|
|
1212
1211
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1213
1212
|
},
|
|
@@ -1215,7 +1214,7 @@ const create$9 = rpcId => {
|
|
|
1215
1214
|
const mockRpc = createMockRpc({
|
|
1216
1215
|
commandMap
|
|
1217
1216
|
});
|
|
1218
|
-
set$
|
|
1217
|
+
set$f(rpcId, mockRpc);
|
|
1219
1218
|
// @ts-ignore
|
|
1220
1219
|
mockRpc[Symbol.dispose] = () => {
|
|
1221
1220
|
remove$8(rpcId);
|
|
@@ -1224,7 +1223,7 @@ const create$9 = rpcId => {
|
|
|
1224
1223
|
return mockRpc;
|
|
1225
1224
|
},
|
|
1226
1225
|
set(rpc) {
|
|
1227
|
-
set$
|
|
1226
|
+
set$f(rpcId, rpc);
|
|
1228
1227
|
}
|
|
1229
1228
|
};
|
|
1230
1229
|
};
|
|
@@ -1234,8 +1233,8 @@ const {
|
|
|
1234
1233
|
invoke: invoke$f,
|
|
1235
1234
|
invokeAndTransfer: invokeAndTransfer$2,
|
|
1236
1235
|
registerMockRpc: registerMockRpc$1,
|
|
1237
|
-
set: set$
|
|
1238
|
-
} = create$
|
|
1236
|
+
set: set$e
|
|
1237
|
+
} = create$a(ExtensionHostWorker);
|
|
1239
1238
|
const executeReferenceProvider = async (id, offset) => {
|
|
1240
1239
|
// @ts-ignore
|
|
1241
1240
|
return invoke$f('ExtensionHostReference.executeReferenceProvider', id, offset);
|
|
@@ -1263,21 +1262,21 @@ const ExtensionHost = {
|
|
|
1263
1262
|
invoke: invoke$f,
|
|
1264
1263
|
invokeAndTransfer: invokeAndTransfer$2,
|
|
1265
1264
|
registerMockRpc: registerMockRpc$1,
|
|
1266
|
-
set: set$
|
|
1265
|
+
set: set$e
|
|
1267
1266
|
};
|
|
1268
1267
|
|
|
1269
1268
|
const {
|
|
1270
1269
|
invoke: invoke$e,
|
|
1271
|
-
set: set$
|
|
1272
|
-
} = create$
|
|
1270
|
+
set: set$d
|
|
1271
|
+
} = create$a(ExtensionManagementWorker);
|
|
1273
1272
|
|
|
1274
1273
|
const {
|
|
1275
1274
|
dispose: dispose$2,
|
|
1276
1275
|
invoke: invoke$d,
|
|
1277
1276
|
invokeAndTransfer: invokeAndTransfer$1,
|
|
1278
1277
|
registerMockRpc,
|
|
1279
|
-
set: set$
|
|
1280
|
-
} = create$
|
|
1278
|
+
set: set$c
|
|
1279
|
+
} = create$a(RendererWorker$1);
|
|
1281
1280
|
const searchFileHtml = async uri => {
|
|
1282
1281
|
return invoke$d('ExtensionHost.searchFileWithHtml', uri);
|
|
1283
1282
|
};
|
|
@@ -1664,7 +1663,7 @@ const RendererWorker = {
|
|
|
1664
1663
|
sendMessagePortToSourceControlWorker,
|
|
1665
1664
|
sendMessagePortToSyntaxHighlightingWorker: sendMessagePortToSyntaxHighlightingWorker$1,
|
|
1666
1665
|
sendMessagePortToTextMeasurementWorker,
|
|
1667
|
-
set: set$
|
|
1666
|
+
set: set$c,
|
|
1668
1667
|
setAdditionalFocus,
|
|
1669
1668
|
setColorTheme,
|
|
1670
1669
|
setExtensionsSearchValue,
|
|
@@ -1685,26 +1684,26 @@ const RendererWorker = {
|
|
|
1685
1684
|
|
|
1686
1685
|
const {
|
|
1687
1686
|
invoke: invoke$c,
|
|
1688
|
-
set: set$
|
|
1689
|
-
} = create$
|
|
1687
|
+
set: set$b
|
|
1688
|
+
} = create$a(OpenerWorker);
|
|
1690
1689
|
|
|
1691
1690
|
const {
|
|
1692
|
-
set: set$
|
|
1693
|
-
} = create$
|
|
1691
|
+
set: set$a
|
|
1692
|
+
} = create$a(IconThemeWorker);
|
|
1694
1693
|
|
|
1695
1694
|
const {
|
|
1696
1695
|
dispose: dispose$1,
|
|
1697
1696
|
invoke: invoke$b,
|
|
1698
1697
|
invokeAndTransfer,
|
|
1699
|
-
set: set$
|
|
1700
|
-
} = create$
|
|
1698
|
+
set: set$9
|
|
1699
|
+
} = create$a(MarkdownWorker);
|
|
1701
1700
|
|
|
1702
1701
|
const SyntaxHighlightingWorker = {
|
|
1703
1702
|
__proto__: null,
|
|
1704
1703
|
dispose: dispose$1,
|
|
1705
1704
|
invoke: invoke$b,
|
|
1706
1705
|
invokeAndTransfer,
|
|
1707
|
-
set: set$
|
|
1706
|
+
set: set$9
|
|
1708
1707
|
};
|
|
1709
1708
|
|
|
1710
1709
|
const createLazyRpc = rpcId => {
|
|
@@ -1712,7 +1711,7 @@ const createLazyRpc = rpcId => {
|
|
|
1712
1711
|
let factory;
|
|
1713
1712
|
const createRpc = async () => {
|
|
1714
1713
|
const rpc = await factory();
|
|
1715
|
-
set$
|
|
1714
|
+
set$f(rpcId, rpc);
|
|
1716
1715
|
};
|
|
1717
1716
|
const ensureRpc = async () => {
|
|
1718
1717
|
if (!rpcPromise) {
|
|
@@ -1723,12 +1722,12 @@ const createLazyRpc = rpcId => {
|
|
|
1723
1722
|
return {
|
|
1724
1723
|
async invoke(method, ...params) {
|
|
1725
1724
|
await ensureRpc();
|
|
1726
|
-
const rpc = get$
|
|
1725
|
+
const rpc = get$8(rpcId);
|
|
1727
1726
|
return rpc.invoke(method, ...params);
|
|
1728
1727
|
},
|
|
1729
1728
|
async invokeAndTransfer(method, ...params) {
|
|
1730
1729
|
await ensureRpc();
|
|
1731
|
-
const rpc = get$
|
|
1730
|
+
const rpc = get$8(rpcId);
|
|
1732
1731
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1733
1732
|
},
|
|
1734
1733
|
setFactory(value) {
|
|
@@ -1737,6 +1736,95 @@ const createLazyRpc = rpcId => {
|
|
|
1737
1736
|
};
|
|
1738
1737
|
};
|
|
1739
1738
|
|
|
1739
|
+
const toCommandId = key => {
|
|
1740
|
+
const dotIndex = key.indexOf('.');
|
|
1741
|
+
return key.slice(dotIndex + 1);
|
|
1742
|
+
};
|
|
1743
|
+
const create$9 = () => {
|
|
1744
|
+
const states = Object.create(null);
|
|
1745
|
+
const commandMapRef = {};
|
|
1746
|
+
return {
|
|
1747
|
+
clear() {
|
|
1748
|
+
for (const key of Object.keys(states)) {
|
|
1749
|
+
delete states[key];
|
|
1750
|
+
}
|
|
1751
|
+
},
|
|
1752
|
+
diff(uid, modules, numbers) {
|
|
1753
|
+
const {
|
|
1754
|
+
newState,
|
|
1755
|
+
oldState
|
|
1756
|
+
} = states[uid];
|
|
1757
|
+
const diffResult = [];
|
|
1758
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1759
|
+
const fn = modules[i];
|
|
1760
|
+
if (!fn(oldState, newState)) {
|
|
1761
|
+
diffResult.push(numbers[i]);
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
return diffResult;
|
|
1765
|
+
},
|
|
1766
|
+
dispose(uid) {
|
|
1767
|
+
delete states[uid];
|
|
1768
|
+
},
|
|
1769
|
+
get(uid) {
|
|
1770
|
+
return states[uid];
|
|
1771
|
+
},
|
|
1772
|
+
getCommandIds() {
|
|
1773
|
+
const keys = Object.keys(commandMapRef);
|
|
1774
|
+
const ids = keys.map(toCommandId);
|
|
1775
|
+
return ids;
|
|
1776
|
+
},
|
|
1777
|
+
getKeys() {
|
|
1778
|
+
return Object.keys(states).map(key => {
|
|
1779
|
+
return Number.parseInt(key);
|
|
1780
|
+
});
|
|
1781
|
+
},
|
|
1782
|
+
registerCommands(commandMap) {
|
|
1783
|
+
Object.assign(commandMapRef, commandMap);
|
|
1784
|
+
},
|
|
1785
|
+
set(uid, oldState, newState) {
|
|
1786
|
+
states[uid] = {
|
|
1787
|
+
newState,
|
|
1788
|
+
oldState
|
|
1789
|
+
};
|
|
1790
|
+
},
|
|
1791
|
+
wrapCommand(fn) {
|
|
1792
|
+
const wrapped = async (uid, ...args) => {
|
|
1793
|
+
const {
|
|
1794
|
+
newState,
|
|
1795
|
+
oldState
|
|
1796
|
+
} = states[uid];
|
|
1797
|
+
const newerState = await fn(newState, ...args);
|
|
1798
|
+
if (oldState === newerState || newState === newerState) {
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
const latestOld = states[uid];
|
|
1802
|
+
const latestNew = {
|
|
1803
|
+
...latestOld.newState,
|
|
1804
|
+
...newerState
|
|
1805
|
+
};
|
|
1806
|
+
states[uid] = {
|
|
1807
|
+
newState: latestNew,
|
|
1808
|
+
oldState: latestOld.oldState
|
|
1809
|
+
};
|
|
1810
|
+
};
|
|
1811
|
+
return wrapped;
|
|
1812
|
+
},
|
|
1813
|
+
wrapGetter(fn) {
|
|
1814
|
+
const wrapped = (uid, ...args) => {
|
|
1815
|
+
const {
|
|
1816
|
+
newState
|
|
1817
|
+
} = states[uid];
|
|
1818
|
+
return fn(newState, ...args);
|
|
1819
|
+
};
|
|
1820
|
+
return wrapped;
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
};
|
|
1824
|
+
const terminate = () => {
|
|
1825
|
+
globalThis.close();
|
|
1826
|
+
};
|
|
1827
|
+
|
|
1740
1828
|
// TODO add tests for this
|
|
1741
1829
|
const activateByEvent = async (event, assetDir, platform) => {
|
|
1742
1830
|
string(event);
|
|
@@ -1753,7 +1841,7 @@ const codeGeneratorAccept = state => {
|
|
|
1753
1841
|
const ModuleWorkerAndWorkaroundForChromeDevtoolsBug = 6;
|
|
1754
1842
|
|
|
1755
1843
|
const launchWorker = async (name, url, intializeCommand) => {
|
|
1756
|
-
const rpc = await
|
|
1844
|
+
const rpc = await create$c({
|
|
1757
1845
|
commandMap: {},
|
|
1758
1846
|
isMessagePortOpen: true,
|
|
1759
1847
|
async send(port) {
|
|
@@ -1790,7 +1878,7 @@ const invoke$a = async (method, ...params) => {
|
|
|
1790
1878
|
return await worker.invoke(method, ...params);
|
|
1791
1879
|
};
|
|
1792
1880
|
|
|
1793
|
-
const loadContent$
|
|
1881
|
+
const loadContent$3 = async (state, parentUid) => {
|
|
1794
1882
|
const {
|
|
1795
1883
|
height,
|
|
1796
1884
|
uid,
|
|
@@ -1808,6 +1896,100 @@ const loadContent$2 = async (state, parentUid) => {
|
|
|
1808
1896
|
};
|
|
1809
1897
|
};
|
|
1810
1898
|
|
|
1899
|
+
const {
|
|
1900
|
+
get: get$7,
|
|
1901
|
+
getCommandIds,
|
|
1902
|
+
set: set$8,
|
|
1903
|
+
wrapCommand: wrapCommand$1,
|
|
1904
|
+
wrapGetter
|
|
1905
|
+
} = create$9();
|
|
1906
|
+
|
|
1907
|
+
const emptyIncrementalEdits = [];
|
|
1908
|
+
|
|
1909
|
+
const ColorPicker = 41;
|
|
1910
|
+
const EditorCompletion = 9;
|
|
1911
|
+
const Empty = 0;
|
|
1912
|
+
const FindWidget = 16;
|
|
1913
|
+
const FocusEditorHover = 51;
|
|
1914
|
+
const FocusEditorRename$1 = 11;
|
|
1915
|
+
const SourceActions = 38;
|
|
1916
|
+
const FocusCodeGenerator = 52;
|
|
1917
|
+
|
|
1918
|
+
const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
1919
|
+
number(id);
|
|
1920
|
+
const editor = {
|
|
1921
|
+
additionalFocus: 0,
|
|
1922
|
+
assetDir,
|
|
1923
|
+
charWidth: 0,
|
|
1924
|
+
columnWidth: 0,
|
|
1925
|
+
completionState: '',
|
|
1926
|
+
completionTriggerCharacters: [],
|
|
1927
|
+
completionUid: 0,
|
|
1928
|
+
cursorWidth: 2,
|
|
1929
|
+
debugEnabled: false,
|
|
1930
|
+
decorations: [],
|
|
1931
|
+
deltaX: 0,
|
|
1932
|
+
deltaY: 0,
|
|
1933
|
+
diagnostics: [],
|
|
1934
|
+
diagnosticsEnabled: false,
|
|
1935
|
+
differences: [],
|
|
1936
|
+
embeds: [],
|
|
1937
|
+
finalDeltaY: 0,
|
|
1938
|
+
finalY: 0,
|
|
1939
|
+
focus: 0,
|
|
1940
|
+
focused: false,
|
|
1941
|
+
focusKey: Empty,
|
|
1942
|
+
fontFamily: '',
|
|
1943
|
+
fontSize: 0,
|
|
1944
|
+
fontWeight: 0,
|
|
1945
|
+
handleOffsetX: 0,
|
|
1946
|
+
height,
|
|
1947
|
+
highlightedLine: -1,
|
|
1948
|
+
id,
|
|
1949
|
+
incrementalEdits: emptyIncrementalEdits,
|
|
1950
|
+
initial: true,
|
|
1951
|
+
invalidStartIndex: 0,
|
|
1952
|
+
isAutoClosingBracketsEnabled: false,
|
|
1953
|
+
isAutoClosingQuotesEnabled: false,
|
|
1954
|
+
isAutoClosingTagsEnabled: false,
|
|
1955
|
+
isMonospaceFont: false,
|
|
1956
|
+
isQuickSuggestionsEnabled: false,
|
|
1957
|
+
itemHeight: 20,
|
|
1958
|
+
languageId: '',
|
|
1959
|
+
letterSpacing: 0,
|
|
1960
|
+
lineCache: [],
|
|
1961
|
+
lineNumbers: false,
|
|
1962
|
+
lines: [],
|
|
1963
|
+
longestLineWidth: 0,
|
|
1964
|
+
maxLineY: 0,
|
|
1965
|
+
minimumSliderSize: 20,
|
|
1966
|
+
minLineY: 0,
|
|
1967
|
+
modified: false,
|
|
1968
|
+
numberOfLines: 0,
|
|
1969
|
+
numberOfVisibleLines: 0,
|
|
1970
|
+
platform,
|
|
1971
|
+
primarySelectionIndex: 0,
|
|
1972
|
+
rowHeight: 0,
|
|
1973
|
+
savedSelections: [],
|
|
1974
|
+
scrollBarHeight: 0,
|
|
1975
|
+
scrollBarWidth: 0,
|
|
1976
|
+
selections: new Uint32Array(),
|
|
1977
|
+
tabSize: 0,
|
|
1978
|
+
textInfos: [],
|
|
1979
|
+
tokenizerId: 0,
|
|
1980
|
+
uid: id,
|
|
1981
|
+
undoStack: [],
|
|
1982
|
+
uri,
|
|
1983
|
+
validLines: [],
|
|
1984
|
+
visualDecorations: [],
|
|
1985
|
+
widgets: [],
|
|
1986
|
+
width,
|
|
1987
|
+
x,
|
|
1988
|
+
y
|
|
1989
|
+
};
|
|
1990
|
+
set$8(id, editor, editor);
|
|
1991
|
+
};
|
|
1992
|
+
|
|
1811
1993
|
// TODO use numeric enum
|
|
1812
1994
|
const CompositionUpdate = 'compositionUpdate';
|
|
1813
1995
|
const ContentEditableInput = 'contentEditableInput';
|
|
@@ -1873,7 +2055,7 @@ const get$5 = id => {
|
|
|
1873
2055
|
number(id);
|
|
1874
2056
|
return editors[id];
|
|
1875
2057
|
};
|
|
1876
|
-
const getKeys$
|
|
2058
|
+
const getKeys$2 = () => {
|
|
1877
2059
|
return Object.keys(editors);
|
|
1878
2060
|
};
|
|
1879
2061
|
const set$6 = (id, oldEditor, newEditor) => {
|
|
@@ -2984,8 +3166,6 @@ const setDeltaY$2 = async (state, value) => {
|
|
|
2984
3166
|
return newEditor2;
|
|
2985
3167
|
};
|
|
2986
3168
|
|
|
2987
|
-
const emptyIncrementalEdits = [];
|
|
2988
|
-
|
|
2989
3169
|
const getIncrementalEdits = async (oldState, newState) => {
|
|
2990
3170
|
if (!newState.undoStack) {
|
|
2991
3171
|
return emptyIncrementalEdits;
|
|
@@ -3184,7 +3364,7 @@ const notifyListeners = async (listenerType, method, ...params) => {
|
|
|
3184
3364
|
// Notify all listeners in parallel
|
|
3185
3365
|
const notifications = rpcIds.map(async rpcId => {
|
|
3186
3366
|
try {
|
|
3187
|
-
const rpc = get$
|
|
3367
|
+
const rpc = get$8(rpcId);
|
|
3188
3368
|
if (rpc) {
|
|
3189
3369
|
await rpc.invoke(method, ...params);
|
|
3190
3370
|
}
|
|
@@ -3847,15 +4027,6 @@ const {
|
|
|
3847
4027
|
set: set$1
|
|
3848
4028
|
} = ExtensionHost;
|
|
3849
4029
|
|
|
3850
|
-
const ColorPicker = 41;
|
|
3851
|
-
const EditorCompletion = 9;
|
|
3852
|
-
const Empty = 0;
|
|
3853
|
-
const FindWidget = 16;
|
|
3854
|
-
const FocusEditorHover = 51;
|
|
3855
|
-
const FocusEditorRename$1 = 11;
|
|
3856
|
-
const SourceActions = 38;
|
|
3857
|
-
const FocusCodeGenerator = 52;
|
|
3858
|
-
|
|
3859
4030
|
const getFileExtensionIndex = file => {
|
|
3860
4031
|
string(file);
|
|
3861
4032
|
return file.lastIndexOf(Dot);
|
|
@@ -4230,6 +4401,46 @@ const createEditor = async ({
|
|
|
4230
4401
|
});
|
|
4231
4402
|
};
|
|
4232
4403
|
|
|
4404
|
+
const isEqual$2 = (oldState, newState) => {
|
|
4405
|
+
return oldState.itemHeight === newState.itemHeight;
|
|
4406
|
+
};
|
|
4407
|
+
|
|
4408
|
+
const isEqual$1 = (oldState, newState) => {
|
|
4409
|
+
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
4410
|
+
};
|
|
4411
|
+
|
|
4412
|
+
const isEqual = (oldState, newState) => {
|
|
4413
|
+
return oldState.lines === newState.lines && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial;
|
|
4414
|
+
};
|
|
4415
|
+
|
|
4416
|
+
const RenderFocus = 6;
|
|
4417
|
+
const RenderFocusContext = 7;
|
|
4418
|
+
const RenderCss = 11;
|
|
4419
|
+
const RenderIncremental = 12;
|
|
4420
|
+
|
|
4421
|
+
const modules = [isEqual, isEqual$1, isEqual$1, isEqual$2];
|
|
4422
|
+
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderCss];
|
|
4423
|
+
|
|
4424
|
+
const diff = (oldState, newState) => {
|
|
4425
|
+
const diffResult = [];
|
|
4426
|
+
for (let i = 0; i < modules.length; i++) {
|
|
4427
|
+
const fn = modules[i];
|
|
4428
|
+
if (!fn(oldState, newState)) {
|
|
4429
|
+
diffResult.push(numbers[i]);
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
return diffResult;
|
|
4433
|
+
};
|
|
4434
|
+
|
|
4435
|
+
const diff2 = uid => {
|
|
4436
|
+
const {
|
|
4437
|
+
newState,
|
|
4438
|
+
oldState
|
|
4439
|
+
} = get$7(uid);
|
|
4440
|
+
const result = diff(oldState, newState);
|
|
4441
|
+
return result;
|
|
4442
|
+
};
|
|
4443
|
+
|
|
4233
4444
|
// @ts-ignore
|
|
4234
4445
|
const getNewSelections$c = selections => {
|
|
4235
4446
|
const newSelections = [];
|
|
@@ -4875,7 +5086,7 @@ const create$6 = () => {
|
|
|
4875
5086
|
};
|
|
4876
5087
|
|
|
4877
5088
|
const newStateGenerator$6 = (state, parentUid) => {
|
|
4878
|
-
return loadContent$
|
|
5089
|
+
return loadContent$3(state, parentUid);
|
|
4879
5090
|
};
|
|
4880
5091
|
const openColorPicker = async editor => {
|
|
4881
5092
|
return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$6);
|
|
@@ -7164,18 +7375,18 @@ const launchFindWidgetWorker = async () => {
|
|
|
7164
7375
|
const rpcId = 9002;
|
|
7165
7376
|
const launch = async () => {
|
|
7166
7377
|
// TODO race condition
|
|
7167
|
-
if (get$
|
|
7378
|
+
if (get$8(rpcId)) {
|
|
7168
7379
|
return;
|
|
7169
7380
|
}
|
|
7170
7381
|
const rpc = await launchFindWidgetWorker();
|
|
7171
|
-
set$
|
|
7382
|
+
set$f(rpcId, rpc);
|
|
7172
7383
|
};
|
|
7173
7384
|
const invoke$3 = async (method, ...params) => {
|
|
7174
|
-
const rpc = get$
|
|
7385
|
+
const rpc = get$8(rpcId);
|
|
7175
7386
|
return await rpc.invoke(method, ...params);
|
|
7176
7387
|
};
|
|
7177
7388
|
const dispose = async () => {
|
|
7178
|
-
const rpc = get$
|
|
7389
|
+
const rpc = get$8(rpcId);
|
|
7179
7390
|
remove$8(rpcId);
|
|
7180
7391
|
if (rpc) {
|
|
7181
7392
|
await rpc.dispose();
|
|
@@ -7197,7 +7408,7 @@ const getEditor = editorUid => {
|
|
|
7197
7408
|
return newState;
|
|
7198
7409
|
};
|
|
7199
7410
|
|
|
7200
|
-
const loadContent$
|
|
7411
|
+
const loadContent$2 = async (state, parentUid) => {
|
|
7201
7412
|
const {
|
|
7202
7413
|
uid
|
|
7203
7414
|
} = state;
|
|
@@ -7220,7 +7431,7 @@ const loadContent$1 = async (state, parentUid) => {
|
|
|
7220
7431
|
};
|
|
7221
7432
|
|
|
7222
7433
|
const newStateGenerator$3 = (state, parentUid) => {
|
|
7223
|
-
return loadContent$
|
|
7434
|
+
return loadContent$2(state, parentUid);
|
|
7224
7435
|
};
|
|
7225
7436
|
const openFind2 = async editor => {
|
|
7226
7437
|
const fullFocus = true;
|
|
@@ -9609,7 +9820,7 @@ const getEditorHoverInfo = async (editorUid, position) => {
|
|
|
9609
9820
|
};
|
|
9610
9821
|
};
|
|
9611
9822
|
|
|
9612
|
-
const loadContent = async (editorUid, state, position) => {
|
|
9823
|
+
const loadContent$1 = async (editorUid, state, position) => {
|
|
9613
9824
|
const hoverInfo = await getEditorHoverInfo(editorUid, position);
|
|
9614
9825
|
if (!hoverInfo) {
|
|
9615
9826
|
return state;
|
|
@@ -10476,8 +10687,8 @@ const getKeyBindings = () => {
|
|
|
10476
10687
|
}];
|
|
10477
10688
|
};
|
|
10478
10689
|
|
|
10479
|
-
const getKeys = () => {
|
|
10480
|
-
return getKeys$
|
|
10690
|
+
const getKeys$1 = () => {
|
|
10691
|
+
return getKeys$2();
|
|
10481
10692
|
};
|
|
10482
10693
|
|
|
10483
10694
|
/**
|
|
@@ -10562,7 +10773,7 @@ const getDiagnostics = editor => {
|
|
|
10562
10773
|
const getProblems = async () => {
|
|
10563
10774
|
// TODO maybe combine querying diagnostics for problems view with diagnostics for editor
|
|
10564
10775
|
// or query the diagnostics for the problems view directtly from the extension host worker
|
|
10565
|
-
const keys = getKeys$
|
|
10776
|
+
const keys = getKeys$2();
|
|
10566
10777
|
const editors = keys.map(key => {
|
|
10567
10778
|
const numericKey = parseInt(key);
|
|
10568
10779
|
const editor = get$5(numericKey);
|
|
@@ -10675,12 +10886,12 @@ const handleBeforeInput = (editor, inputType, data) => {
|
|
|
10675
10886
|
};
|
|
10676
10887
|
|
|
10677
10888
|
const handleMessagePort = async (port, rpcId) => {
|
|
10678
|
-
const rpc = await
|
|
10889
|
+
const rpc = await create$d({
|
|
10679
10890
|
commandMap: {},
|
|
10680
10891
|
messagePort: port
|
|
10681
10892
|
});
|
|
10682
10893
|
if (rpcId) {
|
|
10683
|
-
set$
|
|
10894
|
+
set$f(rpcId, rpc);
|
|
10684
10895
|
}
|
|
10685
10896
|
};
|
|
10686
10897
|
|
|
@@ -10774,7 +10985,7 @@ const hotReload = async () => {
|
|
|
10774
10985
|
isReloading = true;
|
|
10775
10986
|
|
|
10776
10987
|
// TODO use getEditors
|
|
10777
|
-
const keys = getKeys$
|
|
10988
|
+
const keys = getKeys$2();
|
|
10778
10989
|
const savedStates = await saveWidgetState(keys);
|
|
10779
10990
|
await relaunchWorkers();
|
|
10780
10991
|
const newEditors = await restoreWidgetState(keys, savedStates);
|
|
@@ -10795,7 +11006,7 @@ const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId
|
|
|
10795
11006
|
const createExtensionHostRpc = async () => {
|
|
10796
11007
|
try {
|
|
10797
11008
|
const initialCommand = 'HandleMessagePort.handleMessagePort2';
|
|
10798
|
-
const rpc = await
|
|
11009
|
+
const rpc = await create$c({
|
|
10799
11010
|
commandMap: {},
|
|
10800
11011
|
async send(port) {
|
|
10801
11012
|
await sendMessagePortToExtensionHostWorker2(port, initialCommand, EditorWorker);
|
|
@@ -10814,7 +11025,7 @@ const initializeExtensionHost = async () => {
|
|
|
10814
11025
|
|
|
10815
11026
|
const createExtensionManagementWorkerRpc = async () => {
|
|
10816
11027
|
try {
|
|
10817
|
-
const rpc = await
|
|
11028
|
+
const rpc = await create$c({
|
|
10818
11029
|
commandMap: {},
|
|
10819
11030
|
async send(port) {
|
|
10820
11031
|
await sendMessagePortToExtensionManagementWorker(port, EditorWorker);
|
|
@@ -10829,7 +11040,7 @@ const createExtensionManagementWorkerRpc = async () => {
|
|
|
10829
11040
|
const initializeExtensionManagementWorker = async () => {
|
|
10830
11041
|
try {
|
|
10831
11042
|
const rpc = await createExtensionManagementWorkerRpc();
|
|
10832
|
-
set$
|
|
11043
|
+
set$d(rpc);
|
|
10833
11044
|
} catch {
|
|
10834
11045
|
// ignore
|
|
10835
11046
|
}
|
|
@@ -10841,11 +11052,11 @@ const send$2 = port => {
|
|
|
10841
11052
|
};
|
|
10842
11053
|
const initializeOpenerWorker = async () => {
|
|
10843
11054
|
try {
|
|
10844
|
-
const rpc = await
|
|
11055
|
+
const rpc = await create$f({
|
|
10845
11056
|
commandMap: {},
|
|
10846
11057
|
send: send$2
|
|
10847
11058
|
});
|
|
10848
|
-
set$
|
|
11059
|
+
set$b(rpc);
|
|
10849
11060
|
} catch {
|
|
10850
11061
|
// ignore
|
|
10851
11062
|
}
|
|
@@ -10865,7 +11076,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
|
10865
11076
|
|
|
10866
11077
|
const createSyntaxHighlightingWorkerRpc = async () => {
|
|
10867
11078
|
try {
|
|
10868
|
-
const rpc = await
|
|
11079
|
+
const rpc = await create$c({
|
|
10869
11080
|
commandMap: {},
|
|
10870
11081
|
send: sendMessagePortToSyntaxHighlightingWorker
|
|
10871
11082
|
});
|
|
@@ -10891,11 +11102,11 @@ const send$1 = port => {
|
|
|
10891
11102
|
};
|
|
10892
11103
|
const initializeTextMeasurementWorker = async () => {
|
|
10893
11104
|
try {
|
|
10894
|
-
const rpc = await
|
|
11105
|
+
const rpc = await create$f({
|
|
10895
11106
|
commandMap: {},
|
|
10896
11107
|
send: send$1
|
|
10897
11108
|
});
|
|
10898
|
-
set$
|
|
11109
|
+
set$a(rpc);
|
|
10899
11110
|
} catch {
|
|
10900
11111
|
// ignore
|
|
10901
11112
|
}
|
|
@@ -10914,6 +11125,170 @@ const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
|
10914
11125
|
await Promise.all([initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental), initializeExtensionHost(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
|
|
10915
11126
|
};
|
|
10916
11127
|
|
|
11128
|
+
const kLineHeight = 'editor.lineHeight';
|
|
11129
|
+
const kFontSize = 'editor.fontSize';
|
|
11130
|
+
const kFontFamily = 'editor.fontFamily';
|
|
11131
|
+
const kTabSize = 'editor.tabSize';
|
|
11132
|
+
const kLineNumbers = 'editor.lineNumbers';
|
|
11133
|
+
const kDiagnostics = 'editor.diagnostics';
|
|
11134
|
+
const kQuickSuggestions = 'editor.quickSuggestions';
|
|
11135
|
+
const kAutoClosingQuotes = 'editor.autoClosingQuotes';
|
|
11136
|
+
const kAutoClosingBrackets = 'editor.autoclosingBrackets';
|
|
11137
|
+
const kFontWeight = 'editor.fontWeight';
|
|
11138
|
+
const isAutoClosingBracketsEnabled = async () => {
|
|
11139
|
+
return Boolean(await get$1(kAutoClosingBrackets));
|
|
11140
|
+
};
|
|
11141
|
+
const isAutoClosingQuotesEnabled = async () => {
|
|
11142
|
+
return Boolean(await get$1(kAutoClosingQuotes));
|
|
11143
|
+
};
|
|
11144
|
+
const isQuickSuggestionsEnabled = async () => {
|
|
11145
|
+
return Boolean(await get$1(kQuickSuggestions));
|
|
11146
|
+
};
|
|
11147
|
+
const isAutoClosingTagsEnabled = async () => {
|
|
11148
|
+
return true;
|
|
11149
|
+
};
|
|
11150
|
+
const getRowHeight = async () => {
|
|
11151
|
+
return (await get$1(kLineHeight)) || 20;
|
|
11152
|
+
};
|
|
11153
|
+
const getFontSize = async () => {
|
|
11154
|
+
return (await get$1(kFontSize)) || 15; // TODO find out if it is possible to use all numeric values for settings for efficiency, maybe settings could be an array
|
|
11155
|
+
};
|
|
11156
|
+
const getFontFamily = async () => {
|
|
11157
|
+
return (await get$1(kFontFamily)) || 'Fira Code';
|
|
11158
|
+
};
|
|
11159
|
+
const getLetterSpacing = async () => {
|
|
11160
|
+
{
|
|
11161
|
+
return 0;
|
|
11162
|
+
}
|
|
11163
|
+
};
|
|
11164
|
+
const getTabSize = async () => {
|
|
11165
|
+
return (await get$1(kTabSize)) || 2;
|
|
11166
|
+
};
|
|
11167
|
+
const getLineNumbers = async () => {
|
|
11168
|
+
return (await get$1(kLineNumbers)) ?? false;
|
|
11169
|
+
};
|
|
11170
|
+
const getCompletionTriggerCharacters = async () => {
|
|
11171
|
+
return ['.', '/'];
|
|
11172
|
+
};
|
|
11173
|
+
const diagnosticsEnabled = async () => {
|
|
11174
|
+
return (await get$1(kDiagnostics)) ?? false;
|
|
11175
|
+
};
|
|
11176
|
+
const getFontWeight = async () => {
|
|
11177
|
+
return (await get$1(kFontWeight)) ?? 400;
|
|
11178
|
+
};
|
|
11179
|
+
|
|
11180
|
+
const getEditorPreferences = async () => {
|
|
11181
|
+
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters()]);
|
|
11182
|
+
return {
|
|
11183
|
+
completionTriggerCharacters,
|
|
11184
|
+
diagnosticsEnabled: diagnosticsEnabled$1,
|
|
11185
|
+
fontFamily,
|
|
11186
|
+
fontSize,
|
|
11187
|
+
fontWeight,
|
|
11188
|
+
isAutoClosingBracketsEnabled: isAutoClosingBracketsEnabled$1,
|
|
11189
|
+
isAutoClosingQuotesEnabled: isAutoClosingQuotesEnabled$1,
|
|
11190
|
+
isAutoClosingTagsEnabled: isAutoClosingTagsEnabled$1,
|
|
11191
|
+
isQuickSuggestionsEnabled: isQuickSuggestionsEnabled$1,
|
|
11192
|
+
letterSpacing,
|
|
11193
|
+
lineNumbers,
|
|
11194
|
+
rowHeight,
|
|
11195
|
+
tabSize
|
|
11196
|
+
};
|
|
11197
|
+
};
|
|
11198
|
+
|
|
11199
|
+
const loadContent = async (state, savedState) => {
|
|
11200
|
+
const {
|
|
11201
|
+
assetDir,
|
|
11202
|
+
height,
|
|
11203
|
+
id,
|
|
11204
|
+
platform,
|
|
11205
|
+
uri,
|
|
11206
|
+
width,
|
|
11207
|
+
x,
|
|
11208
|
+
y
|
|
11209
|
+
} = state;
|
|
11210
|
+
const {
|
|
11211
|
+
completionTriggerCharacters,
|
|
11212
|
+
diagnosticsEnabled,
|
|
11213
|
+
fontFamily,
|
|
11214
|
+
fontSize,
|
|
11215
|
+
fontWeight,
|
|
11216
|
+
isAutoClosingBracketsEnabled,
|
|
11217
|
+
isAutoClosingQuotesEnabled,
|
|
11218
|
+
isAutoClosingTagsEnabled,
|
|
11219
|
+
isQuickSuggestionsEnabled,
|
|
11220
|
+
letterSpacing,
|
|
11221
|
+
lineNumbers,
|
|
11222
|
+
rowHeight,
|
|
11223
|
+
tabSize
|
|
11224
|
+
} = await getEditorPreferences();
|
|
11225
|
+
// TODO support overwriting language id by setting it explicitly or via settings
|
|
11226
|
+
const charWidth = await measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing);
|
|
11227
|
+
const languages = await getLanguages(platform, assetDir);
|
|
11228
|
+
const computedlanguageId = getLanguageId$1(uri, languages);
|
|
11229
|
+
const newEditor0 = {
|
|
11230
|
+
...state,
|
|
11231
|
+
charWidth,
|
|
11232
|
+
completionTriggerCharacters,
|
|
11233
|
+
diagnosticsEnabled,
|
|
11234
|
+
fontFamily,
|
|
11235
|
+
fontSize,
|
|
11236
|
+
fontWeight,
|
|
11237
|
+
isAutoClosingBracketsEnabled,
|
|
11238
|
+
isAutoClosingQuotesEnabled,
|
|
11239
|
+
isAutoClosingTagsEnabled,
|
|
11240
|
+
isQuickSuggestionsEnabled,
|
|
11241
|
+
languageId: computedlanguageId,
|
|
11242
|
+
letterSpacing,
|
|
11243
|
+
lineNumbers,
|
|
11244
|
+
rowHeight,
|
|
11245
|
+
tabSize
|
|
11246
|
+
};
|
|
11247
|
+
const content = await readFile(uri);
|
|
11248
|
+
|
|
11249
|
+
// TODO avoid creating intermediate editors here
|
|
11250
|
+
const newEditor1 = setBounds(newEditor0, x, y, width, height, 9);
|
|
11251
|
+
const newEditor2 = setText$1(newEditor1, content);
|
|
11252
|
+
let newEditor3 = newEditor2;
|
|
11253
|
+
|
|
11254
|
+
// Detect links and initialize decorations
|
|
11255
|
+
const linkDecorations = detectAllLinksAsDecorations(newEditor3);
|
|
11256
|
+
const newEditor3WithLinks = {
|
|
11257
|
+
...newEditor3,
|
|
11258
|
+
decorations: linkDecorations
|
|
11259
|
+
};
|
|
11260
|
+
const syncIncremental = getEnabled();
|
|
11261
|
+
const {
|
|
11262
|
+
differences,
|
|
11263
|
+
textInfos
|
|
11264
|
+
} = await getVisible$1(newEditor3WithLinks, syncIncremental);
|
|
11265
|
+
const newEditor4 = {
|
|
11266
|
+
...newEditor3WithLinks,
|
|
11267
|
+
differences,
|
|
11268
|
+
focus: FocusEditorText$1,
|
|
11269
|
+
focused: true,
|
|
11270
|
+
textInfos
|
|
11271
|
+
};
|
|
11272
|
+
|
|
11273
|
+
// TODO only sync when needed
|
|
11274
|
+
// e.g. it might not always be necessary to send text to extension host worker
|
|
11275
|
+
// @ts-ignore
|
|
11276
|
+
await invoke$6(TextDocumentSyncFull, uri, id, computedlanguageId, content);
|
|
11277
|
+
|
|
11278
|
+
// TODO await promise
|
|
11279
|
+
if (diagnosticsEnabled) {
|
|
11280
|
+
await updateDiagnostics(newEditor4);
|
|
11281
|
+
}
|
|
11282
|
+
const completionsOnTypeRaw = await get$1('editor.completionsOnType');
|
|
11283
|
+
const completionsOnType = Boolean(completionsOnTypeRaw);
|
|
11284
|
+
const newEditor5 = {
|
|
11285
|
+
...newEditor4,
|
|
11286
|
+
completionsOnType,
|
|
11287
|
+
initial: false
|
|
11288
|
+
};
|
|
11289
|
+
return newEditor5;
|
|
11290
|
+
};
|
|
11291
|
+
|
|
10917
11292
|
// TODO move cursor
|
|
10918
11293
|
// TODO multiple cursors -> vscode removes multiple cursors
|
|
10919
11294
|
// TODO with selection -> vscode moves whole selection
|
|
@@ -10980,6 +11355,319 @@ const registerListener = (listenerType, rpcId) => {
|
|
|
10980
11355
|
registerListener$1(listenerType, rpcId);
|
|
10981
11356
|
};
|
|
10982
11357
|
|
|
11358
|
+
const getCss = itemHeight => {
|
|
11359
|
+
return `:root {
|
|
11360
|
+
--ActivityBarItemHeight: var(--${itemHeight}px);
|
|
11361
|
+
}
|
|
11362
|
+
`;
|
|
11363
|
+
};
|
|
11364
|
+
|
|
11365
|
+
const renderCss = (oldState, newState) => {
|
|
11366
|
+
const {
|
|
11367
|
+
itemHeight,
|
|
11368
|
+
uid
|
|
11369
|
+
} = newState;
|
|
11370
|
+
const css = getCss(itemHeight);
|
|
11371
|
+
return [SetCss$1, uid, css];
|
|
11372
|
+
};
|
|
11373
|
+
|
|
11374
|
+
const renderFocus$2 = (oldState, newState) => {
|
|
11375
|
+
const selector = '.EditorInput';
|
|
11376
|
+
return [FocusSelector, newState.uid, selector];
|
|
11377
|
+
};
|
|
11378
|
+
|
|
11379
|
+
const renderFocusContext$1 = (oldState, newState) => {
|
|
11380
|
+
return [SetFocusContext$1, newState.uid, FocusExplorer];
|
|
11381
|
+
};
|
|
11382
|
+
|
|
11383
|
+
const SetText = 1;
|
|
11384
|
+
const Replace = 2;
|
|
11385
|
+
const SetAttribute = 3;
|
|
11386
|
+
const RemoveAttribute = 4;
|
|
11387
|
+
const Add = 6;
|
|
11388
|
+
const NavigateChild = 7;
|
|
11389
|
+
const NavigateParent = 8;
|
|
11390
|
+
const RemoveChild = 9;
|
|
11391
|
+
const NavigateSibling = 10;
|
|
11392
|
+
const SetReferenceNodeUid = 11;
|
|
11393
|
+
|
|
11394
|
+
const isKey = key => {
|
|
11395
|
+
return key !== 'type' && key !== 'childCount';
|
|
11396
|
+
};
|
|
11397
|
+
|
|
11398
|
+
const getKeys = node => {
|
|
11399
|
+
const keys = Object.keys(node).filter(isKey);
|
|
11400
|
+
return keys;
|
|
11401
|
+
};
|
|
11402
|
+
|
|
11403
|
+
const arrayToTree = nodes => {
|
|
11404
|
+
const result = [];
|
|
11405
|
+
let i = 0;
|
|
11406
|
+
while (i < nodes.length) {
|
|
11407
|
+
const node = nodes[i];
|
|
11408
|
+
const {
|
|
11409
|
+
children,
|
|
11410
|
+
nodesConsumed
|
|
11411
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
11412
|
+
result.push({
|
|
11413
|
+
node,
|
|
11414
|
+
children
|
|
11415
|
+
});
|
|
11416
|
+
i += 1 + nodesConsumed;
|
|
11417
|
+
}
|
|
11418
|
+
return result;
|
|
11419
|
+
};
|
|
11420
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
11421
|
+
if (childCount === 0) {
|
|
11422
|
+
return {
|
|
11423
|
+
children: [],
|
|
11424
|
+
nodesConsumed: 0
|
|
11425
|
+
};
|
|
11426
|
+
}
|
|
11427
|
+
const children = [];
|
|
11428
|
+
let i = startIndex;
|
|
11429
|
+
let remaining = childCount;
|
|
11430
|
+
let totalConsumed = 0;
|
|
11431
|
+
while (remaining > 0 && i < nodes.length) {
|
|
11432
|
+
const node = nodes[i];
|
|
11433
|
+
const nodeChildCount = node.childCount || 0;
|
|
11434
|
+
const {
|
|
11435
|
+
children: nodeChildren,
|
|
11436
|
+
nodesConsumed
|
|
11437
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
11438
|
+
children.push({
|
|
11439
|
+
node,
|
|
11440
|
+
children: nodeChildren
|
|
11441
|
+
});
|
|
11442
|
+
const nodeSize = 1 + nodesConsumed;
|
|
11443
|
+
i += nodeSize;
|
|
11444
|
+
totalConsumed += nodeSize;
|
|
11445
|
+
remaining--;
|
|
11446
|
+
}
|
|
11447
|
+
return {
|
|
11448
|
+
children,
|
|
11449
|
+
nodesConsumed: totalConsumed
|
|
11450
|
+
};
|
|
11451
|
+
};
|
|
11452
|
+
|
|
11453
|
+
const compareNodes = (oldNode, newNode) => {
|
|
11454
|
+
const patches = [];
|
|
11455
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
11456
|
+
// (caller should handle this with a Replace operation)
|
|
11457
|
+
if (oldNode.type !== newNode.type) {
|
|
11458
|
+
return null;
|
|
11459
|
+
}
|
|
11460
|
+
// Handle reference nodes - special handling for uid changes
|
|
11461
|
+
if (oldNode.type === Reference) {
|
|
11462
|
+
if (oldNode.uid !== newNode.uid) {
|
|
11463
|
+
patches.push({
|
|
11464
|
+
type: SetReferenceNodeUid,
|
|
11465
|
+
uid: newNode.uid
|
|
11466
|
+
});
|
|
11467
|
+
}
|
|
11468
|
+
return patches;
|
|
11469
|
+
}
|
|
11470
|
+
// Handle text nodes
|
|
11471
|
+
if (oldNode.type === Text$1 && newNode.type === Text$1) {
|
|
11472
|
+
if (oldNode.text !== newNode.text) {
|
|
11473
|
+
patches.push({
|
|
11474
|
+
type: SetText,
|
|
11475
|
+
value: newNode.text
|
|
11476
|
+
});
|
|
11477
|
+
}
|
|
11478
|
+
return patches;
|
|
11479
|
+
}
|
|
11480
|
+
// Compare attributes
|
|
11481
|
+
const oldKeys = getKeys(oldNode);
|
|
11482
|
+
const newKeys = getKeys(newNode);
|
|
11483
|
+
// Check for attribute changes
|
|
11484
|
+
for (const key of newKeys) {
|
|
11485
|
+
if (oldNode[key] !== newNode[key]) {
|
|
11486
|
+
patches.push({
|
|
11487
|
+
type: SetAttribute,
|
|
11488
|
+
key,
|
|
11489
|
+
value: newNode[key]
|
|
11490
|
+
});
|
|
11491
|
+
}
|
|
11492
|
+
}
|
|
11493
|
+
// Check for removed attributes
|
|
11494
|
+
for (const key of oldKeys) {
|
|
11495
|
+
if (!(key in newNode)) {
|
|
11496
|
+
patches.push({
|
|
11497
|
+
type: RemoveAttribute,
|
|
11498
|
+
key
|
|
11499
|
+
});
|
|
11500
|
+
}
|
|
11501
|
+
}
|
|
11502
|
+
return patches;
|
|
11503
|
+
};
|
|
11504
|
+
|
|
11505
|
+
const treeToArray = node => {
|
|
11506
|
+
const result = [node.node];
|
|
11507
|
+
for (const child of node.children) {
|
|
11508
|
+
result.push(...treeToArray(child));
|
|
11509
|
+
}
|
|
11510
|
+
return result;
|
|
11511
|
+
};
|
|
11512
|
+
|
|
11513
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
11514
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
11515
|
+
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
11516
|
+
let currentChildIndex = -1;
|
|
11517
|
+
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
11518
|
+
const indicesToRemove = [];
|
|
11519
|
+
for (let i = 0; i < maxLength; i++) {
|
|
11520
|
+
const oldNode = oldChildren[i];
|
|
11521
|
+
const newNode = newChildren[i];
|
|
11522
|
+
if (!oldNode && !newNode) {
|
|
11523
|
+
continue;
|
|
11524
|
+
}
|
|
11525
|
+
if (!oldNode) {
|
|
11526
|
+
// Add new node - we should be at the parent
|
|
11527
|
+
if (currentChildIndex >= 0) {
|
|
11528
|
+
// Navigate back to parent
|
|
11529
|
+
patches.push({
|
|
11530
|
+
type: NavigateParent
|
|
11531
|
+
});
|
|
11532
|
+
currentChildIndex = -1;
|
|
11533
|
+
}
|
|
11534
|
+
// Flatten the entire subtree so renderInternal can handle it
|
|
11535
|
+
const flatNodes = treeToArray(newNode);
|
|
11536
|
+
patches.push({
|
|
11537
|
+
type: Add,
|
|
11538
|
+
nodes: flatNodes
|
|
11539
|
+
});
|
|
11540
|
+
} else if (newNode) {
|
|
11541
|
+
// Compare nodes to see if we need any patches
|
|
11542
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
11543
|
+
// If nodePatches is null, the node types are incompatible - need to replace
|
|
11544
|
+
if (nodePatches === null) {
|
|
11545
|
+
// Navigate to this child
|
|
11546
|
+
if (currentChildIndex === -1) {
|
|
11547
|
+
patches.push({
|
|
11548
|
+
type: NavigateChild,
|
|
11549
|
+
index: i
|
|
11550
|
+
});
|
|
11551
|
+
currentChildIndex = i;
|
|
11552
|
+
} else if (currentChildIndex !== i) {
|
|
11553
|
+
patches.push({
|
|
11554
|
+
type: NavigateSibling,
|
|
11555
|
+
index: i
|
|
11556
|
+
});
|
|
11557
|
+
currentChildIndex = i;
|
|
11558
|
+
}
|
|
11559
|
+
// Replace the entire subtree
|
|
11560
|
+
const flatNodes = treeToArray(newNode);
|
|
11561
|
+
patches.push({
|
|
11562
|
+
type: Replace,
|
|
11563
|
+
nodes: flatNodes
|
|
11564
|
+
});
|
|
11565
|
+
// After replace, we're at the new element (same position)
|
|
11566
|
+
continue;
|
|
11567
|
+
}
|
|
11568
|
+
// Check if we need to recurse into children
|
|
11569
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
11570
|
+
// Only navigate to this element if we need to do something
|
|
11571
|
+
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
11572
|
+
// Navigate to this child if not already there
|
|
11573
|
+
if (currentChildIndex === -1) {
|
|
11574
|
+
patches.push({
|
|
11575
|
+
type: NavigateChild,
|
|
11576
|
+
index: i
|
|
11577
|
+
});
|
|
11578
|
+
currentChildIndex = i;
|
|
11579
|
+
} else if (currentChildIndex !== i) {
|
|
11580
|
+
patches.push({
|
|
11581
|
+
type: NavigateSibling,
|
|
11582
|
+
index: i
|
|
11583
|
+
});
|
|
11584
|
+
currentChildIndex = i;
|
|
11585
|
+
}
|
|
11586
|
+
// Apply node patches (these apply to the current element, not children)
|
|
11587
|
+
if (nodePatches.length > 0) {
|
|
11588
|
+
patches.push(...nodePatches);
|
|
11589
|
+
}
|
|
11590
|
+
// Compare children recursively
|
|
11591
|
+
if (hasChildrenToCompare) {
|
|
11592
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
11593
|
+
}
|
|
11594
|
+
}
|
|
11595
|
+
} else {
|
|
11596
|
+
// Remove old node - collect the index for later removal
|
|
11597
|
+
indicesToRemove.push(i);
|
|
11598
|
+
}
|
|
11599
|
+
}
|
|
11600
|
+
// Navigate back to parent if we ended at a child
|
|
11601
|
+
if (currentChildIndex >= 0) {
|
|
11602
|
+
patches.push({
|
|
11603
|
+
type: NavigateParent
|
|
11604
|
+
});
|
|
11605
|
+
currentChildIndex = -1;
|
|
11606
|
+
}
|
|
11607
|
+
// Add remove patches in reverse order (highest index first)
|
|
11608
|
+
// This ensures indices remain valid as we remove
|
|
11609
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
11610
|
+
patches.push({
|
|
11611
|
+
type: RemoveChild,
|
|
11612
|
+
index: indicesToRemove[j]
|
|
11613
|
+
});
|
|
11614
|
+
}
|
|
11615
|
+
};
|
|
11616
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
11617
|
+
// At the root level (path.length === 0), we're already AT the element
|
|
11618
|
+
// So we compare the root node directly, then compare its children
|
|
11619
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
11620
|
+
const oldNode = oldTree[0];
|
|
11621
|
+
const newNode = newTree[0];
|
|
11622
|
+
// Compare root nodes
|
|
11623
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
11624
|
+
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
11625
|
+
if (nodePatches === null) {
|
|
11626
|
+
const flatNodes = treeToArray(newNode);
|
|
11627
|
+
patches.push({
|
|
11628
|
+
type: Replace,
|
|
11629
|
+
nodes: flatNodes
|
|
11630
|
+
});
|
|
11631
|
+
return;
|
|
11632
|
+
}
|
|
11633
|
+
if (nodePatches.length > 0) {
|
|
11634
|
+
patches.push(...nodePatches);
|
|
11635
|
+
}
|
|
11636
|
+
// Compare children
|
|
11637
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
11638
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
11639
|
+
}
|
|
11640
|
+
} else {
|
|
11641
|
+
// Non-root level or multiple root elements - use the regular comparison
|
|
11642
|
+
diffChildren(oldTree, newTree, patches);
|
|
11643
|
+
}
|
|
11644
|
+
};
|
|
11645
|
+
|
|
11646
|
+
const removeTrailingNavigationPatches = patches => {
|
|
11647
|
+
// Find the last non-navigation patch
|
|
11648
|
+
let lastNonNavigationIndex = -1;
|
|
11649
|
+
for (let i = patches.length - 1; i >= 0; i--) {
|
|
11650
|
+
const patch = patches[i];
|
|
11651
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
11652
|
+
lastNonNavigationIndex = i;
|
|
11653
|
+
break;
|
|
11654
|
+
}
|
|
11655
|
+
}
|
|
11656
|
+
// Return patches up to and including the last non-navigation patch
|
|
11657
|
+
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
11658
|
+
};
|
|
11659
|
+
|
|
11660
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
11661
|
+
// Step 1: Convert flat arrays to tree structures
|
|
11662
|
+
const oldTree = arrayToTree(oldNodes);
|
|
11663
|
+
const newTree = arrayToTree(newNodes);
|
|
11664
|
+
// Step 3: Compare the trees
|
|
11665
|
+
const patches = [];
|
|
11666
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
11667
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
11668
|
+
return removeTrailingNavigationPatches(patches);
|
|
11669
|
+
};
|
|
11670
|
+
|
|
10983
11671
|
const getCursorsVirtualDom = cursors => {
|
|
10984
11672
|
const dom = [];
|
|
10985
11673
|
for (const translate of cursors) {
|
|
@@ -11095,6 +11783,133 @@ const getSelectionsVirtualDom = selections => {
|
|
|
11095
11783
|
return dom;
|
|
11096
11784
|
};
|
|
11097
11785
|
|
|
11786
|
+
const getEditorVirtualDom = ({
|
|
11787
|
+
cursorInfos = [],
|
|
11788
|
+
diagnostics = [],
|
|
11789
|
+
differences,
|
|
11790
|
+
gutterInfos = [],
|
|
11791
|
+
highlightedLine = -1,
|
|
11792
|
+
lineNumbers = true,
|
|
11793
|
+
scrollBarDiagnostics = [],
|
|
11794
|
+
selectionInfos = [],
|
|
11795
|
+
textInfos
|
|
11796
|
+
}) => {
|
|
11797
|
+
const cursorInfosArray = [...cursorInfos];
|
|
11798
|
+
const diagnosticsArray = [...diagnostics];
|
|
11799
|
+
const gutterInfosArray = [...gutterInfos];
|
|
11800
|
+
const scrollBarDiagnosticsArray = [...scrollBarDiagnostics];
|
|
11801
|
+
const rowsDom = getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine);
|
|
11802
|
+
const cursorsDom = getCursorsVirtualDom(cursorInfosArray);
|
|
11803
|
+
const selectionsDom = getSelectionsVirtualDom(selectionInfos);
|
|
11804
|
+
const diagnosticsDom = getDiagnosticsVirtualDom(diagnosticsArray);
|
|
11805
|
+
const gutterDom = getEditorGutterVirtualDom(gutterInfosArray);
|
|
11806
|
+
const scrollBarDiagnosticsDom = getDiagnosticsVirtualDom(scrollBarDiagnosticsArray);
|
|
11807
|
+
return [{
|
|
11808
|
+
childCount: 2,
|
|
11809
|
+
className: 'Viewlet Editor',
|
|
11810
|
+
role: 'code',
|
|
11811
|
+
type: Div
|
|
11812
|
+
}, {
|
|
11813
|
+
childCount: gutterInfosArray.length,
|
|
11814
|
+
className: 'Gutter',
|
|
11815
|
+
type: Div
|
|
11816
|
+
}, ...gutterDom, {
|
|
11817
|
+
childCount: 4,
|
|
11818
|
+
className: 'EditorContent',
|
|
11819
|
+
type: Div
|
|
11820
|
+
}, {
|
|
11821
|
+
childCount: 4,
|
|
11822
|
+
className: 'EditorLayers',
|
|
11823
|
+
type: Div
|
|
11824
|
+
}, {
|
|
11825
|
+
childCount: selectionsDom.length,
|
|
11826
|
+
className: 'Selections',
|
|
11827
|
+
type: Div
|
|
11828
|
+
}, ...selectionsDom, {
|
|
11829
|
+
childCount: textInfos.length,
|
|
11830
|
+
className: 'EditorRows',
|
|
11831
|
+
type: Div
|
|
11832
|
+
}, ...rowsDom, {
|
|
11833
|
+
childCount: cursorsDom.length,
|
|
11834
|
+
className: 'LayerCursor',
|
|
11835
|
+
type: Div
|
|
11836
|
+
}, ...cursorsDom, {
|
|
11837
|
+
childCount: diagnosticsDom.length,
|
|
11838
|
+
className: 'LayerDiagnostics',
|
|
11839
|
+
type: Div
|
|
11840
|
+
}, ...diagnosticsDom, {
|
|
11841
|
+
childCount: scrollBarDiagnosticsDom.length,
|
|
11842
|
+
className: 'EditorScrollBarDiagnostics',
|
|
11843
|
+
type: Div
|
|
11844
|
+
}, ...scrollBarDiagnosticsDom, {
|
|
11845
|
+
childCount: 1,
|
|
11846
|
+
className: 'ScrollBar ScrollBarVertical',
|
|
11847
|
+
type: Div
|
|
11848
|
+
}, {
|
|
11849
|
+
childCount: 0,
|
|
11850
|
+
className: 'ScrollBarThumb ScrollBarThumbVertical',
|
|
11851
|
+
type: Div
|
|
11852
|
+
}, {
|
|
11853
|
+
childCount: 1,
|
|
11854
|
+
className: 'ScrollBar ScrollBarHorizontal',
|
|
11855
|
+
type: Div
|
|
11856
|
+
}, {
|
|
11857
|
+
childCount: 0,
|
|
11858
|
+
className: 'ScrollBarThumb ScrollBarThumbHorizontal',
|
|
11859
|
+
type: Div
|
|
11860
|
+
}];
|
|
11861
|
+
};
|
|
11862
|
+
|
|
11863
|
+
const getDom = state => {
|
|
11864
|
+
if (state.initial) {
|
|
11865
|
+
return [];
|
|
11866
|
+
}
|
|
11867
|
+
return getEditorVirtualDom(state);
|
|
11868
|
+
};
|
|
11869
|
+
const renderIncremental = (oldState, newState) => {
|
|
11870
|
+
const oldDom = getDom(oldState);
|
|
11871
|
+
const newDom = getDom(newState);
|
|
11872
|
+
const patches = diffTree(oldDom, newDom);
|
|
11873
|
+
return [SetPatches, newState.uid, patches];
|
|
11874
|
+
};
|
|
11875
|
+
|
|
11876
|
+
const getRenderer = diffType => {
|
|
11877
|
+
switch (diffType) {
|
|
11878
|
+
case RenderCss:
|
|
11879
|
+
return renderCss;
|
|
11880
|
+
case RenderFocus:
|
|
11881
|
+
return renderFocus$2;
|
|
11882
|
+
case RenderFocusContext:
|
|
11883
|
+
return renderFocusContext$1;
|
|
11884
|
+
case RenderIncremental:
|
|
11885
|
+
return renderIncremental;
|
|
11886
|
+
default:
|
|
11887
|
+
throw new Error('unknown renderer');
|
|
11888
|
+
}
|
|
11889
|
+
};
|
|
11890
|
+
|
|
11891
|
+
const applyRender = (oldState, newState, diffResult) => {
|
|
11892
|
+
const commands = [];
|
|
11893
|
+
for (const item of diffResult) {
|
|
11894
|
+
const fn = getRenderer(item);
|
|
11895
|
+
const result = fn(oldState, newState);
|
|
11896
|
+
if (result.length > 0) {
|
|
11897
|
+
commands.push(result);
|
|
11898
|
+
}
|
|
11899
|
+
}
|
|
11900
|
+
return commands;
|
|
11901
|
+
};
|
|
11902
|
+
|
|
11903
|
+
const render2 = (uid, diffResult) => {
|
|
11904
|
+
const {
|
|
11905
|
+
newState,
|
|
11906
|
+
oldState
|
|
11907
|
+
} = get$7(uid);
|
|
11908
|
+
set$8(uid, newState, newState);
|
|
11909
|
+
const commands = applyRender(oldState, newState, diffResult);
|
|
11910
|
+
return commands;
|
|
11911
|
+
};
|
|
11912
|
+
|
|
11098
11913
|
const addWidget = widget => {
|
|
11099
11914
|
const module = get$6(widget.id);
|
|
11100
11915
|
if (!module) {
|
|
@@ -11353,6 +12168,15 @@ const renderEventListeners = () => {
|
|
|
11353
12168
|
}];
|
|
11354
12169
|
};
|
|
11355
12170
|
|
|
12171
|
+
const saveState = (state, savedState) => {
|
|
12172
|
+
const {
|
|
12173
|
+
lines
|
|
12174
|
+
} = state;
|
|
12175
|
+
return {
|
|
12176
|
+
lines
|
|
12177
|
+
};
|
|
12178
|
+
};
|
|
12179
|
+
|
|
11356
12180
|
const setDebugEnabled = (state, enabled) => {
|
|
11357
12181
|
return state;
|
|
11358
12182
|
};
|
|
@@ -11369,7 +12193,7 @@ const unregisterListener = (listenerType, rpcId) => {
|
|
|
11369
12193
|
};
|
|
11370
12194
|
|
|
11371
12195
|
const invoke = async (method, ...params) => {
|
|
11372
|
-
const worker = get$
|
|
12196
|
+
const worker = get$8(DebugWorker);
|
|
11373
12197
|
return worker.invoke(method, ...params);
|
|
11374
12198
|
};
|
|
11375
12199
|
|
|
@@ -11379,7 +12203,7 @@ const getDebugHighlight = async debugId => {
|
|
|
11379
12203
|
};
|
|
11380
12204
|
|
|
11381
12205
|
const getKey = () => {
|
|
11382
|
-
const keys = getKeys$
|
|
12206
|
+
const keys = getKeys$2();
|
|
11383
12207
|
return parseInt(keys[0]);
|
|
11384
12208
|
};
|
|
11385
12209
|
const updateDebugInfo = async debugId => {
|
|
@@ -11427,7 +12251,7 @@ const wrapCommand = fn => async (editorUid, ...args) => {
|
|
|
11427
12251
|
const commandMap = {
|
|
11428
12252
|
'ActivateByEvent.activateByEvent': activateByEvent,
|
|
11429
12253
|
'CodeGenerator.accept': codeGeneratorAccept,
|
|
11430
|
-
'ColorPicker.loadContent': loadContent$
|
|
12254
|
+
'ColorPicker.loadContent': loadContent$3,
|
|
11431
12255
|
'Editor.addCursorAbove': wrapCommand(addCursorAbove),
|
|
11432
12256
|
'Editor.addCursorBelow': wrapCommand(addCursorBelow),
|
|
11433
12257
|
'Editor.applyDocumentEdits': wrapCommand(applyDocumentEdits),
|
|
@@ -11450,6 +12274,7 @@ const commandMap = {
|
|
|
11450
12274
|
'Editor.copyLineDown': wrapCommand(copyLineDown),
|
|
11451
12275
|
'Editor.copyLineUp': wrapCommand(copyLineUp),
|
|
11452
12276
|
'Editor.create': createEditor,
|
|
12277
|
+
'Editor.create2': createEditor2,
|
|
11453
12278
|
'Editor.cursorCharacterLeft': wrapCommand(cursorCharacterLeft),
|
|
11454
12279
|
'Editor.cursorCharacterRight': wrapCommand(cursorCharacterRight),
|
|
11455
12280
|
'Editor.cursorDown': wrapCommand(cursorDown),
|
|
@@ -11476,12 +12301,14 @@ const commandMap = {
|
|
|
11476
12301
|
'Editor.deleteWordPartLeft': wrapCommand(deleteWordPartLeft),
|
|
11477
12302
|
'Editor.deleteWordPartRight': wrapCommand(deleteWordPartRight),
|
|
11478
12303
|
'Editor.deleteWordRight': wrapCommand(deleteWordRight),
|
|
12304
|
+
'Editor.diff2': diff2,
|
|
11479
12305
|
'Editor.executeWidgetCommand': wrapCommand(executeWidgetCommand),
|
|
11480
12306
|
'Editor.findAllReferences': wrapCommand(findAllReferences$1),
|
|
11481
12307
|
'Editor.format': wrapCommand(format),
|
|
12308
|
+
'Editor.getCommandIds': getCommandIds,
|
|
11482
12309
|
'Editor.getDiagnostics': getDiagnostics$1,
|
|
11483
12310
|
'Editor.getKeyBindings': getKeyBindings,
|
|
11484
|
-
'Editor.getKeys': getKeys,
|
|
12311
|
+
'Editor.getKeys': getKeys$1,
|
|
11485
12312
|
'Editor.getLanguageId': getLanguageId,
|
|
11486
12313
|
'Editor.getLines2': getLines2,
|
|
11487
12314
|
'Editor.getMenuEntries': getMenuEntries,
|
|
@@ -11533,6 +12360,7 @@ const commandMap = {
|
|
|
11533
12360
|
'Editor.indendLess': wrapCommand(indentLess),
|
|
11534
12361
|
'Editor.indentMore': wrapCommand(indentMore),
|
|
11535
12362
|
'Editor.insertLineBreak': wrapCommand(insertLineBreak),
|
|
12363
|
+
'Editor.loadContent': wrapCommand$1(loadContent),
|
|
11536
12364
|
'Editor.moveLineDown': wrapCommand(moveLineDown),
|
|
11537
12365
|
'Editor.moveLineUp': wrapCommand(moveLineUp),
|
|
11538
12366
|
'Editor.moveRectangleSelection': wrapCommand(moveRectangleSelection),
|
|
@@ -11550,10 +12378,12 @@ const commandMap = {
|
|
|
11550
12378
|
'Editor.paste': wrapCommand(paste),
|
|
11551
12379
|
'Editor.pasteText': wrapCommand(pasteText),
|
|
11552
12380
|
'Editor.render': renderEditor,
|
|
12381
|
+
'Editor.render2': render2,
|
|
11553
12382
|
'Editor.renderEventListeners': renderEventListeners,
|
|
11554
12383
|
'Editor.replaceRange': wrapCommand(replaceRange),
|
|
11555
12384
|
'Editor.rerender': wrapCommand(rerender),
|
|
11556
12385
|
'Editor.save': wrapCommand(save),
|
|
12386
|
+
'Editor.saveState': wrapGetter(saveState),
|
|
11557
12387
|
'Editor.selectAll': wrapCommand(selectAll),
|
|
11558
12388
|
'Editor.selectAllLeft': wrapCommand(editorSelectAllLeft),
|
|
11559
12389
|
'Editor.selectAllOccurrences': wrapCommand(selectAllOccurrences),
|
|
@@ -11585,6 +12415,7 @@ const commandMap = {
|
|
|
11585
12415
|
'Editor.showSourceActions3': showSourceActions,
|
|
11586
12416
|
'Editor.sortLinesAscending': wrapCommand(sortLinesAscending),
|
|
11587
12417
|
'Editor.tabCompletion': wrapCommand(tabCompletion),
|
|
12418
|
+
'Editor.terminate': terminate,
|
|
11588
12419
|
'Editor.toggleBlockComment': wrapCommand(toggleBlockComment),
|
|
11589
12420
|
'Editor.toggleComment': wrapCommand(toggleComment),
|
|
11590
12421
|
'Editor.toggleLineComment': wrapCommand(editorToggleLineComment),
|
|
@@ -11646,7 +12477,7 @@ const commandMap = {
|
|
|
11646
12477
|
'FindWidget.handleReplaceFocus': handleReplaceFocus,
|
|
11647
12478
|
'FindWidget.handleReplaceInput': handleReplaceInput,
|
|
11648
12479
|
'FindWidget.handleToggleReplaceFocus': handleToggleReplaceFocus,
|
|
11649
|
-
'FindWidget.loadContent': loadContent$
|
|
12480
|
+
'FindWidget.loadContent': loadContent$2,
|
|
11650
12481
|
'FindWidget.replace': replace,
|
|
11651
12482
|
'FindWidget.replaceAll': replaceAll,
|
|
11652
12483
|
'FindWidget.toggleMatchCase': toggleMatchCase,
|
|
@@ -11660,10 +12491,11 @@ const commandMap = {
|
|
|
11660
12491
|
'Hover.handleSashPointerDown': handleSashPointerDown,
|
|
11661
12492
|
'Hover.handleSashPointerMove': handleSashPointerMove,
|
|
11662
12493
|
'Hover.handleSashPointerUp': handleSashPointerUp,
|
|
11663
|
-
'Hover.loadContent': loadContent,
|
|
12494
|
+
'Hover.loadContent': loadContent$1,
|
|
11664
12495
|
'Hover.render': renderHover,
|
|
11665
12496
|
'Initialize.initialize': intialize,
|
|
11666
12497
|
'Listener.register': registerListener,
|
|
12498
|
+
'Listener.registerListener': registerListener$1,
|
|
11667
12499
|
'Listener.unregister': unregisterListener,
|
|
11668
12500
|
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker': sendMessagePortToExtensionHostWorker2
|
|
11669
12501
|
};
|
|
@@ -11674,7 +12506,7 @@ const send = port => {
|
|
|
11674
12506
|
};
|
|
11675
12507
|
const createTextMeasurementWorkerRpc = async () => {
|
|
11676
12508
|
try {
|
|
11677
|
-
const rpc = await
|
|
12509
|
+
const rpc = await create$c({
|
|
11678
12510
|
commandMap: {},
|
|
11679
12511
|
send
|
|
11680
12512
|
});
|
|
@@ -11686,10 +12518,10 @@ const createTextMeasurementWorkerRpc = async () => {
|
|
|
11686
12518
|
|
|
11687
12519
|
const listen = async () => {
|
|
11688
12520
|
setFactory$1(createTextMeasurementWorkerRpc);
|
|
11689
|
-
const rpc = await
|
|
12521
|
+
const rpc = await create$b({
|
|
11690
12522
|
commandMap: commandMap
|
|
11691
12523
|
});
|
|
11692
|
-
set$
|
|
12524
|
+
set$c(rpc);
|
|
11693
12525
|
};
|
|
11694
12526
|
|
|
11695
12527
|
const CodeGeneratorInput = 'CodeGeneratorInput';
|