@lvce-editor/editor-worker 19.18.0 → 19.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editorWorkerMain.js +614 -248
- package/package.json +1 -1
- package/dist/editorWorkerMain.min.js +0 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -3,10 +3,67 @@ const toCommandId = key => {
|
|
|
3
3
|
return key.slice(dotIndex + 1);
|
|
4
4
|
};
|
|
5
5
|
const create$j = () => {
|
|
6
|
+
const commandQueues = new Map();
|
|
7
|
+
const generations = Object.create(null);
|
|
6
8
|
const states = Object.create(null);
|
|
7
9
|
const commandMapRef = {};
|
|
10
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
11
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
12
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
13
|
+
};
|
|
14
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
15
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
16
|
+
return Promise.resolve(fallbackState);
|
|
17
|
+
}
|
|
18
|
+
const current = states[uid];
|
|
19
|
+
const updatedState = updater(current.newState);
|
|
20
|
+
if (updatedState !== current.newState) {
|
|
21
|
+
states[uid] = {
|
|
22
|
+
newState: updatedState,
|
|
23
|
+
oldState: current.oldState,
|
|
24
|
+
scheduledState: updatedState
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return Promise.resolve(updatedState);
|
|
28
|
+
};
|
|
29
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
30
|
+
let latestState = states[uid].newState;
|
|
31
|
+
return {
|
|
32
|
+
getState: () => {
|
|
33
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
34
|
+
latestState = states[uid].newState;
|
|
35
|
+
}
|
|
36
|
+
return latestState;
|
|
37
|
+
},
|
|
38
|
+
updateState: async updater => {
|
|
39
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
40
|
+
return latestState;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const enqueueCommand = async (uid, command) => {
|
|
45
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
46
|
+
const run = async () => {
|
|
47
|
+
try {
|
|
48
|
+
await previous;
|
|
49
|
+
} catch {
|
|
50
|
+
// The previous caller receives its error; later commands must still run.
|
|
51
|
+
}
|
|
52
|
+
await command();
|
|
53
|
+
};
|
|
54
|
+
const current = run();
|
|
55
|
+
commandQueues.set(uid, current);
|
|
56
|
+
try {
|
|
57
|
+
await current;
|
|
58
|
+
} finally {
|
|
59
|
+
if (commandQueues.get(uid) === current) {
|
|
60
|
+
commandQueues.delete(uid);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
8
64
|
return {
|
|
9
65
|
clear() {
|
|
66
|
+
commandQueues.clear();
|
|
10
67
|
for (const key of Object.keys(states)) {
|
|
11
68
|
delete states[key];
|
|
12
69
|
}
|
|
@@ -26,6 +83,7 @@ const create$j = () => {
|
|
|
26
83
|
return diffResult;
|
|
27
84
|
},
|
|
28
85
|
dispose(uid) {
|
|
86
|
+
commandQueues.delete(uid);
|
|
29
87
|
delete states[uid];
|
|
30
88
|
},
|
|
31
89
|
get(uid) {
|
|
@@ -43,14 +101,27 @@ const create$j = () => {
|
|
|
43
101
|
Object.assign(commandMapRef, commandMap);
|
|
44
102
|
},
|
|
45
103
|
set(uid, oldState, newState, scheduledState) {
|
|
104
|
+
const current = states[uid];
|
|
105
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
106
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
107
|
+
}
|
|
46
108
|
states[uid] = {
|
|
47
109
|
newState,
|
|
48
110
|
oldState,
|
|
49
111
|
scheduledState: scheduledState ?? newState
|
|
50
112
|
};
|
|
51
113
|
},
|
|
114
|
+
wrapAsyncCommand(fn) {
|
|
115
|
+
const wrapped = async (uid, ...args) => {
|
|
116
|
+
const generation = getGeneration(uid);
|
|
117
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
118
|
+
await fn(context, ...args);
|
|
119
|
+
};
|
|
120
|
+
return wrapped;
|
|
121
|
+
},
|
|
52
122
|
wrapCommand(fn) {
|
|
53
123
|
const wrapped = async (uid, ...args) => {
|
|
124
|
+
const generation = getGeneration(uid);
|
|
54
125
|
const {
|
|
55
126
|
newState,
|
|
56
127
|
oldState
|
|
@@ -59,6 +130,9 @@ const create$j = () => {
|
|
|
59
130
|
if (oldState === newerState || newState === newerState) {
|
|
60
131
|
return;
|
|
61
132
|
}
|
|
133
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
62
136
|
const latestOld = states[uid];
|
|
63
137
|
const latestNew = {
|
|
64
138
|
...latestOld.newState,
|
|
@@ -83,6 +157,7 @@ const create$j = () => {
|
|
|
83
157
|
},
|
|
84
158
|
wrapLoadContent(fn) {
|
|
85
159
|
const wrapped = async (uid, ...args) => {
|
|
160
|
+
const generation = getGeneration(uid);
|
|
86
161
|
const {
|
|
87
162
|
newState,
|
|
88
163
|
oldState
|
|
@@ -97,6 +172,11 @@ const create$j = () => {
|
|
|
97
172
|
error
|
|
98
173
|
};
|
|
99
174
|
}
|
|
175
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
176
|
+
return {
|
|
177
|
+
error
|
|
178
|
+
};
|
|
179
|
+
}
|
|
100
180
|
const latestOld = states[uid];
|
|
101
181
|
const latestNew = {
|
|
102
182
|
...latestOld.newState,
|
|
@@ -112,6 +192,51 @@ const create$j = () => {
|
|
|
112
192
|
};
|
|
113
193
|
};
|
|
114
194
|
return wrapped;
|
|
195
|
+
},
|
|
196
|
+
wrapSerialAsyncCommand(fn) {
|
|
197
|
+
const wrapped = async (uid, ...args) => {
|
|
198
|
+
await enqueueCommand(uid, async () => {
|
|
199
|
+
if (!states[uid]) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const generation = getGeneration(uid);
|
|
203
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
204
|
+
await fn(context, ...args);
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
return wrapped;
|
|
208
|
+
},
|
|
209
|
+
wrapSerialCommand(fn) {
|
|
210
|
+
const wrapped = async (uid, ...args) => {
|
|
211
|
+
await enqueueCommand(uid, async () => {
|
|
212
|
+
if (!states[uid]) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const generation = getGeneration(uid);
|
|
216
|
+
const {
|
|
217
|
+
newState,
|
|
218
|
+
oldState
|
|
219
|
+
} = states[uid];
|
|
220
|
+
const newerState = await fn(newState, ...args);
|
|
221
|
+
if (oldState === newerState || newState === newerState) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const latestOld = states[uid];
|
|
228
|
+
const latestNew = {
|
|
229
|
+
...latestOld.newState,
|
|
230
|
+
...newerState
|
|
231
|
+
};
|
|
232
|
+
states[uid] = {
|
|
233
|
+
newState: latestNew,
|
|
234
|
+
oldState: latestOld.oldState,
|
|
235
|
+
scheduledState: latestNew
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
return wrapped;
|
|
115
240
|
}
|
|
116
241
|
};
|
|
117
242
|
};
|
|
@@ -284,7 +409,6 @@ const walkValue = (value, transferrables, isTransferrable) => {
|
|
|
284
409
|
for (const property of Object.values(value)) {
|
|
285
410
|
walkValue(property, transferrables, isTransferrable);
|
|
286
411
|
}
|
|
287
|
-
return;
|
|
288
412
|
}
|
|
289
413
|
};
|
|
290
414
|
const getTransferrables = value => {
|
|
@@ -438,7 +562,14 @@ class IpcError extends VError {
|
|
|
438
562
|
const cause = new Error(message);
|
|
439
563
|
// @ts-ignore
|
|
440
564
|
cause.code = code;
|
|
441
|
-
|
|
565
|
+
if (stack) {
|
|
566
|
+
Object.defineProperty(cause, 'stack', {
|
|
567
|
+
configurable: true,
|
|
568
|
+
enumerable: false,
|
|
569
|
+
value: stack,
|
|
570
|
+
writable: true
|
|
571
|
+
});
|
|
572
|
+
}
|
|
442
573
|
super(cause, betterMessage);
|
|
443
574
|
} else {
|
|
444
575
|
super(betterMessage);
|
|
@@ -725,7 +856,10 @@ const constructError = (message, type, name) => {
|
|
|
725
856
|
if (ErrorConstructor === Error) {
|
|
726
857
|
const error = new Error(message);
|
|
727
858
|
if (name && name !== 'VError') {
|
|
728
|
-
error
|
|
859
|
+
Object.defineProperty(error, 'name', {
|
|
860
|
+
configurable: true,
|
|
861
|
+
value: name
|
|
862
|
+
});
|
|
729
863
|
}
|
|
730
864
|
return error;
|
|
731
865
|
}
|
|
@@ -742,8 +876,10 @@ const getCurrentStack = () => {
|
|
|
742
876
|
const currentStack = joinLines$1(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
|
|
743
877
|
return currentStack;
|
|
744
878
|
};
|
|
745
|
-
const getNewLineIndex = (string, startIndex
|
|
746
|
-
|
|
879
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
880
|
+
{
|
|
881
|
+
return string.indexOf(NewLine$1);
|
|
882
|
+
}
|
|
747
883
|
};
|
|
748
884
|
const getParentStack = error => {
|
|
749
885
|
let parentStack = error.stack || error.data || error.message || '';
|
|
@@ -754,55 +890,91 @@ const getParentStack = error => {
|
|
|
754
890
|
};
|
|
755
891
|
const MethodNotFound = -32601;
|
|
756
892
|
const Custom = -32001;
|
|
893
|
+
const setStack = (error, stack) => {
|
|
894
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
895
|
+
if (descriptor) {
|
|
896
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
900
|
+
error.stack = stack;
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
Object.defineProperty(error, 'stack', {
|
|
905
|
+
configurable: true,
|
|
906
|
+
value: stack,
|
|
907
|
+
writable: true
|
|
908
|
+
});
|
|
909
|
+
};
|
|
910
|
+
const restoreExistingError = (error, currentStack) => {
|
|
911
|
+
if (typeof error.stack === 'string') {
|
|
912
|
+
setStack(error, `${error.stack}${NewLine$1}${currentStack}`);
|
|
913
|
+
}
|
|
914
|
+
return error;
|
|
915
|
+
};
|
|
916
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
917
|
+
const restoredError = new JsonRpcError(error.message);
|
|
918
|
+
const parentStack = getParentStack(error);
|
|
919
|
+
setStack(restoredError, `${parentStack}${NewLine$1}${currentStack}`);
|
|
920
|
+
return restoredError;
|
|
921
|
+
};
|
|
922
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
923
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
924
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine$1}${error.data.stack}${NewLine$1}${currentStack}`);
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (error.data.stack) {
|
|
928
|
+
setStack(restoredError, error.data.stack);
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
const applyDataProperties = (restoredError, error) => {
|
|
932
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
933
|
+
if (error.data.codeFrame) {
|
|
934
|
+
// @ts-ignore
|
|
935
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
936
|
+
}
|
|
937
|
+
if (error.data.code) {
|
|
938
|
+
// @ts-ignore
|
|
939
|
+
restoredError.code = error.data.code;
|
|
940
|
+
}
|
|
941
|
+
if (error.data.type) {
|
|
942
|
+
// @ts-ignore
|
|
943
|
+
restoredError.name = error.data.type;
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
947
|
+
if (error.stack) {
|
|
948
|
+
const lowerStack = restoredError.stack || '';
|
|
949
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
950
|
+
const parentStack = getParentStack(error);
|
|
951
|
+
// @ts-ignore
|
|
952
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
953
|
+
}
|
|
954
|
+
if (error.codeFrame) {
|
|
955
|
+
// @ts-ignore
|
|
956
|
+
restoredError.codeFrame = error.codeFrame;
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
960
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
961
|
+
if (error.data) {
|
|
962
|
+
applyDataProperties(restoredError, error);
|
|
963
|
+
} else {
|
|
964
|
+
applyDirectProperties(restoredError, error);
|
|
965
|
+
}
|
|
966
|
+
return restoredError;
|
|
967
|
+
};
|
|
757
968
|
const restoreJsonRpcError = error => {
|
|
758
969
|
const currentStack = getCurrentStack();
|
|
759
970
|
if (error && error instanceof Error) {
|
|
760
|
-
|
|
761
|
-
error.stack = error.stack + NewLine$1 + currentStack;
|
|
762
|
-
}
|
|
763
|
-
return error;
|
|
971
|
+
return restoreExistingError(error, currentStack);
|
|
764
972
|
}
|
|
765
973
|
if (error && error.code && error.code === MethodNotFound) {
|
|
766
|
-
|
|
767
|
-
const parentStack = getParentStack(error);
|
|
768
|
-
restoredError.stack = parentStack + NewLine$1 + currentStack;
|
|
769
|
-
return restoredError;
|
|
974
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
770
975
|
}
|
|
771
976
|
if (error && error.message) {
|
|
772
|
-
|
|
773
|
-
if (error.data) {
|
|
774
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
775
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
|
|
776
|
-
} else if (error.data.stack) {
|
|
777
|
-
restoredError.stack = error.data.stack;
|
|
778
|
-
}
|
|
779
|
-
if (error.data.codeFrame) {
|
|
780
|
-
// @ts-ignore
|
|
781
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
782
|
-
}
|
|
783
|
-
if (error.data.code) {
|
|
784
|
-
// @ts-ignore
|
|
785
|
-
restoredError.code = error.data.code;
|
|
786
|
-
}
|
|
787
|
-
if (error.data.type) {
|
|
788
|
-
// @ts-ignore
|
|
789
|
-
restoredError.name = error.data.type;
|
|
790
|
-
}
|
|
791
|
-
} else {
|
|
792
|
-
if (error.stack) {
|
|
793
|
-
const lowerStack = restoredError.stack || '';
|
|
794
|
-
// @ts-ignore
|
|
795
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
796
|
-
const parentStack = getParentStack(error);
|
|
797
|
-
// @ts-ignore
|
|
798
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
799
|
-
}
|
|
800
|
-
if (error.codeFrame) {
|
|
801
|
-
// @ts-ignore
|
|
802
|
-
restoredError.codeFrame = error.codeFrame;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
return restoredError;
|
|
977
|
+
return restoreMessageError(error);
|
|
806
978
|
}
|
|
807
979
|
if (typeof error === 'string') {
|
|
808
980
|
return new Error(`JsonRpc Error: ${error}`);
|
|
@@ -1272,9 +1444,175 @@ const create$9 = rpcId => {
|
|
|
1272
1444
|
};
|
|
1273
1445
|
};
|
|
1274
1446
|
|
|
1447
|
+
const Audio = 0;
|
|
1448
|
+
const Button$1 = 1;
|
|
1449
|
+
const Col = 2;
|
|
1450
|
+
const ColGroup = 3;
|
|
1451
|
+
const Div$1 = 4;
|
|
1452
|
+
const H1 = 5;
|
|
1453
|
+
const Input$1 = 6;
|
|
1454
|
+
const Kbd = 7;
|
|
1455
|
+
const Span$1 = 8;
|
|
1456
|
+
const Table = 9;
|
|
1457
|
+
const TBody = 10;
|
|
1458
|
+
const Td = 11;
|
|
1275
1459
|
const Text$1 = 12;
|
|
1460
|
+
const Th = 13;
|
|
1461
|
+
const THead = 14;
|
|
1462
|
+
const Tr = 15;
|
|
1463
|
+
const I = 16;
|
|
1464
|
+
const Img = 17;
|
|
1465
|
+
const Root = 0;
|
|
1466
|
+
const Ins = 20;
|
|
1467
|
+
const Del = 21;
|
|
1468
|
+
const H2 = 22;
|
|
1469
|
+
const H3 = 23;
|
|
1470
|
+
const H4 = 24;
|
|
1471
|
+
const H5 = 25;
|
|
1472
|
+
const H6 = 26;
|
|
1473
|
+
const Article = 27;
|
|
1474
|
+
const Aside = 28;
|
|
1475
|
+
const Footer = 29;
|
|
1476
|
+
const Header = 30;
|
|
1477
|
+
const Nav = 40;
|
|
1478
|
+
const Section = 41;
|
|
1479
|
+
const Search = 42;
|
|
1480
|
+
const Dd = 43;
|
|
1481
|
+
const Dl = 44;
|
|
1482
|
+
const Figcaption = 45;
|
|
1483
|
+
const Figure = 46;
|
|
1484
|
+
const Hr = 47;
|
|
1485
|
+
const Li = 48;
|
|
1486
|
+
const Ol = 49;
|
|
1487
|
+
const P = 50;
|
|
1488
|
+
const Pre = 51;
|
|
1489
|
+
const A = 53;
|
|
1490
|
+
const Abbr = 54;
|
|
1491
|
+
const Br = 55;
|
|
1492
|
+
const Cite = 56;
|
|
1493
|
+
const Data = 57;
|
|
1494
|
+
const Time = 58;
|
|
1495
|
+
const Tfoot = 59;
|
|
1496
|
+
const Ul = 60;
|
|
1497
|
+
const Video = 61;
|
|
1498
|
+
const TextArea$1 = 62;
|
|
1499
|
+
const Select = 63;
|
|
1500
|
+
const Option = 64;
|
|
1501
|
+
const Code = 65;
|
|
1502
|
+
const Label = 66;
|
|
1503
|
+
const Dt = 67;
|
|
1504
|
+
const Iframe = 68;
|
|
1505
|
+
const Main = 69;
|
|
1506
|
+
const Strong = 70;
|
|
1507
|
+
const Em = 71;
|
|
1508
|
+
const Style = 72;
|
|
1509
|
+
const Html = 73;
|
|
1510
|
+
const Head = 74;
|
|
1511
|
+
const Title = 75;
|
|
1512
|
+
const Meta = 76;
|
|
1513
|
+
const Canvas = 77;
|
|
1514
|
+
const Form = 78;
|
|
1515
|
+
const BlockQuote = 79;
|
|
1516
|
+
const Quote = 80;
|
|
1517
|
+
const Circle = 81;
|
|
1518
|
+
const Defs = 82;
|
|
1519
|
+
const Ellipse = 83;
|
|
1520
|
+
const G = 84;
|
|
1521
|
+
const Line = 85;
|
|
1522
|
+
const Path = 86;
|
|
1523
|
+
const Polygon = 87;
|
|
1524
|
+
const Polyline = 88;
|
|
1525
|
+
const Rect = 89;
|
|
1526
|
+
const Svg = 90;
|
|
1527
|
+
const Use = 91;
|
|
1276
1528
|
const Reference = 100;
|
|
1277
1529
|
|
|
1530
|
+
const VirtualDomElements = {
|
|
1531
|
+
__proto__: null,
|
|
1532
|
+
A,
|
|
1533
|
+
Abbr,
|
|
1534
|
+
Article,
|
|
1535
|
+
Aside,
|
|
1536
|
+
Audio,
|
|
1537
|
+
BlockQuote,
|
|
1538
|
+
Br,
|
|
1539
|
+
Button: Button$1,
|
|
1540
|
+
Canvas,
|
|
1541
|
+
Circle,
|
|
1542
|
+
Cite,
|
|
1543
|
+
Code,
|
|
1544
|
+
Col,
|
|
1545
|
+
ColGroup,
|
|
1546
|
+
Data,
|
|
1547
|
+
Dd,
|
|
1548
|
+
Defs,
|
|
1549
|
+
Del,
|
|
1550
|
+
Div: Div$1,
|
|
1551
|
+
Dl,
|
|
1552
|
+
Dt,
|
|
1553
|
+
Ellipse,
|
|
1554
|
+
Em,
|
|
1555
|
+
Figcaption,
|
|
1556
|
+
Figure,
|
|
1557
|
+
Footer,
|
|
1558
|
+
Form,
|
|
1559
|
+
G,
|
|
1560
|
+
H1,
|
|
1561
|
+
H2,
|
|
1562
|
+
H3,
|
|
1563
|
+
H4,
|
|
1564
|
+
H5,
|
|
1565
|
+
H6,
|
|
1566
|
+
Head,
|
|
1567
|
+
Header,
|
|
1568
|
+
Hr,
|
|
1569
|
+
Html,
|
|
1570
|
+
I,
|
|
1571
|
+
Iframe,
|
|
1572
|
+
Img,
|
|
1573
|
+
Input: Input$1,
|
|
1574
|
+
Ins,
|
|
1575
|
+
Kbd,
|
|
1576
|
+
Label,
|
|
1577
|
+
Li,
|
|
1578
|
+
Line,
|
|
1579
|
+
Main,
|
|
1580
|
+
Meta,
|
|
1581
|
+
Nav,
|
|
1582
|
+
Ol,
|
|
1583
|
+
Option,
|
|
1584
|
+
P,
|
|
1585
|
+
Path,
|
|
1586
|
+
Polygon,
|
|
1587
|
+
Polyline,
|
|
1588
|
+
Pre,
|
|
1589
|
+
Quote,
|
|
1590
|
+
Rect,
|
|
1591
|
+
Reference,
|
|
1592
|
+
Root,
|
|
1593
|
+
Search,
|
|
1594
|
+
Section,
|
|
1595
|
+
Select,
|
|
1596
|
+
Span: Span$1,
|
|
1597
|
+
Strong,
|
|
1598
|
+
Style,
|
|
1599
|
+
Svg,
|
|
1600
|
+
TBody,
|
|
1601
|
+
THead,
|
|
1602
|
+
Table,
|
|
1603
|
+
Td,
|
|
1604
|
+
Text: Text$1,
|
|
1605
|
+
TextArea: TextArea$1,
|
|
1606
|
+
Tfoot,
|
|
1607
|
+
Th,
|
|
1608
|
+
Time,
|
|
1609
|
+
Title,
|
|
1610
|
+
Tr,
|
|
1611
|
+
Ul,
|
|
1612
|
+
Use,
|
|
1613
|
+
Video
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1278
1616
|
const AltKey = 'event.altKey';
|
|
1279
1617
|
const Button = 'event.button';
|
|
1280
1618
|
const ClientX = 'event.clientX';
|
|
@@ -1817,6 +2155,8 @@ const Ts272 = 272;
|
|
|
1817
2155
|
|
|
1818
2156
|
const getDecorationClassName = type => {
|
|
1819
2157
|
switch (type) {
|
|
2158
|
+
case 3:
|
|
2159
|
+
return 'R';
|
|
1820
2160
|
case DefinitionLink:
|
|
1821
2161
|
return EditorGoToDefinitionLink;
|
|
1822
2162
|
case Link:
|
|
@@ -3167,9 +3507,9 @@ const splitLines = lines => {
|
|
|
3167
3507
|
const {
|
|
3168
3508
|
invoke: invoke$7} = RendererWorker;
|
|
3169
3509
|
|
|
3170
|
-
const notifyTabModifiedStatusChange = async uri => {
|
|
3510
|
+
const notifyTabModifiedStatusChange = async (uri, modified) => {
|
|
3171
3511
|
try {
|
|
3172
|
-
await invoke$7('Main.handleModifiedStatusChange', uri,
|
|
3512
|
+
await invoke$7('Main.handleModifiedStatusChange', uri, modified);
|
|
3173
3513
|
} catch {
|
|
3174
3514
|
// ignore
|
|
3175
3515
|
}
|
|
@@ -3577,7 +3917,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
|
|
|
3577
3917
|
|
|
3578
3918
|
// Notify main-area-worker about modified status change
|
|
3579
3919
|
if (!editor.modified) {
|
|
3580
|
-
await notifyTabModifiedStatusChange(editor.uri);
|
|
3920
|
+
await notifyTabModifiedStatusChange(editor.uri, true);
|
|
3581
3921
|
}
|
|
3582
3922
|
|
|
3583
3923
|
// Notify registered listeners about editor changes
|
|
@@ -4513,50 +4853,20 @@ const applyWorkspaceEdit = async (editor, changes) => {
|
|
|
4513
4853
|
return scheduleDocumentAndCursorsSelections(editor, textChanges);
|
|
4514
4854
|
};
|
|
4515
4855
|
|
|
4516
|
-
const
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
focused: false
|
|
4856
|
+
const getFormattingEdits = async editor => {
|
|
4857
|
+
const textDocument = {
|
|
4858
|
+
documentId: editor.id || editor.uid,
|
|
4859
|
+
languageId: editor.languageId,
|
|
4860
|
+
text: getText$1(editor),
|
|
4861
|
+
uri: editor.uri
|
|
4523
4862
|
};
|
|
4524
|
-
return
|
|
4525
|
-
};
|
|
4526
|
-
|
|
4527
|
-
const replaceRange = (editor, ranges, replacement, origin) => {
|
|
4528
|
-
const changes = [];
|
|
4529
|
-
const rangesLength = ranges.length;
|
|
4530
|
-
for (let i = 0; i < rangesLength; i += 4) {
|
|
4531
|
-
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(ranges, i);
|
|
4532
|
-
const start = {
|
|
4533
|
-
columnIndex: selectionStartColumn,
|
|
4534
|
-
rowIndex: selectionStartRow
|
|
4535
|
-
};
|
|
4536
|
-
const end = {
|
|
4537
|
-
columnIndex: selectionEndColumn,
|
|
4538
|
-
rowIndex: selectionEndRow
|
|
4539
|
-
};
|
|
4540
|
-
const selection = {
|
|
4541
|
-
end,
|
|
4542
|
-
start
|
|
4543
|
-
};
|
|
4544
|
-
changes.push({
|
|
4545
|
-
deleted: getSelectionText(editor, selection),
|
|
4546
|
-
end: end,
|
|
4547
|
-
inserted: replacement,
|
|
4548
|
-
origin,
|
|
4549
|
-
start: start
|
|
4550
|
-
});
|
|
4551
|
-
}
|
|
4552
|
-
return changes;
|
|
4863
|
+
return invoke$e('Extensions.executeFormattingProvider', textDocument);
|
|
4553
4864
|
};
|
|
4554
4865
|
|
|
4555
|
-
const
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
return replaceRange(editor, selections, replacement, origin);
|
|
4866
|
+
const expectedErrorMessage$1 = 'Failed to execute formatting provider: FormattingError:';
|
|
4867
|
+
const isFormattingError = error => {
|
|
4868
|
+
// @ts-ignore
|
|
4869
|
+
return error && error instanceof Error && error.message.startsWith(expectedErrorMessage$1);
|
|
4560
4870
|
};
|
|
4561
4871
|
|
|
4562
4872
|
const create$8 = () => {
|
|
@@ -4776,6 +5086,188 @@ const showErrorMessage = (editor, rowIndex, columnIndex, message) => {
|
|
|
4776
5086
|
return editorShowMessage(editor, rowIndex, columnIndex, message);
|
|
4777
5087
|
};
|
|
4778
5088
|
|
|
5089
|
+
const expectedErrorMessage = 'Failed to execute formatting provider: FormattingError:';
|
|
5090
|
+
|
|
5091
|
+
// TODO also format with cursor
|
|
5092
|
+
const format = async editor => {
|
|
5093
|
+
try {
|
|
5094
|
+
const edits = await getFormattingEdits(editor);
|
|
5095
|
+
return applyDocumentEdits(editor, edits);
|
|
5096
|
+
} catch (error) {
|
|
5097
|
+
if (isFormattingError(error)) {
|
|
5098
|
+
console.error('Formatting Error:',
|
|
5099
|
+
// @ts-ignore
|
|
5100
|
+
error.message.slice(expectedErrorMessage.length));
|
|
5101
|
+
return editor;
|
|
5102
|
+
}
|
|
5103
|
+
console.error(error);
|
|
5104
|
+
|
|
5105
|
+
// TODO configure editor message as widget
|
|
5106
|
+
const displayErrorMessage = String(error);
|
|
5107
|
+
await editorShowMessage(editor, 0, 0, displayErrorMessage);
|
|
5108
|
+
return editor;
|
|
5109
|
+
}
|
|
5110
|
+
};
|
|
5111
|
+
|
|
5112
|
+
// @ts-ignore
|
|
5113
|
+
const getNewEditor$1 = async editor => {
|
|
5114
|
+
return editor;
|
|
5115
|
+
};
|
|
5116
|
+
|
|
5117
|
+
const isUntitledFile = uri => {
|
|
5118
|
+
return uri.startsWith('untitled:');
|
|
5119
|
+
};
|
|
5120
|
+
|
|
5121
|
+
const saveNormalFile = async (uri, content) => {
|
|
5122
|
+
await invoke$b('FileSystem.writeFile', uri, content);
|
|
5123
|
+
};
|
|
5124
|
+
|
|
5125
|
+
const showFilePicker = async platform => {
|
|
5126
|
+
const dialogTitle = 'Save File'; // TODO use i18n string
|
|
5127
|
+
const {
|
|
5128
|
+
canceled,
|
|
5129
|
+
filePath
|
|
5130
|
+
} = await invoke$d('Open.showSaveDialog', dialogTitle, [], platform);
|
|
5131
|
+
if (canceled) {
|
|
5132
|
+
return '';
|
|
5133
|
+
}
|
|
5134
|
+
return filePath;
|
|
5135
|
+
};
|
|
5136
|
+
|
|
5137
|
+
const saveUntitledFile = async (uri, content, platform) => {
|
|
5138
|
+
const filePath = await showFilePicker(platform);
|
|
5139
|
+
if (!filePath) {
|
|
5140
|
+
return;
|
|
5141
|
+
}
|
|
5142
|
+
await invoke$b('FileSystem.writeFile', filePath, content);
|
|
5143
|
+
await handleWorkspaceRefresh();
|
|
5144
|
+
await invoke$b('Main.handleUriChange', uri, filePath);
|
|
5145
|
+
return filePath;
|
|
5146
|
+
};
|
|
5147
|
+
|
|
5148
|
+
const isPermissionDeniedError = error => {
|
|
5149
|
+
const errorCode = 'code' in error ? error.code : undefined;
|
|
5150
|
+
return errorCode === 'EACCES' || error.message.includes('EACCES:');
|
|
5151
|
+
};
|
|
5152
|
+
const showSaveErrorDialog = async error => {
|
|
5153
|
+
if (isPermissionDeniedError(error)) {
|
|
5154
|
+
await invoke$b('ElectronDialog.showMessageBox', {
|
|
5155
|
+
buttons: ['OK'],
|
|
5156
|
+
defaultId: 0,
|
|
5157
|
+
message: "You don't have permission to save changes to this file.",
|
|
5158
|
+
title: 'Unable to Save File',
|
|
5159
|
+
type: 'error'
|
|
5160
|
+
});
|
|
5161
|
+
return;
|
|
5162
|
+
}
|
|
5163
|
+
await invoke$b('ElectronDialog.showMessageBox', {
|
|
5164
|
+
buttons: ['OK'],
|
|
5165
|
+
defaultId: 0,
|
|
5166
|
+
detail: error.message,
|
|
5167
|
+
message: 'Saving the file failed.',
|
|
5168
|
+
title: 'Failed to Save File',
|
|
5169
|
+
type: 'error'
|
|
5170
|
+
});
|
|
5171
|
+
};
|
|
5172
|
+
|
|
5173
|
+
const save = async editor => {
|
|
5174
|
+
try {
|
|
5175
|
+
const {
|
|
5176
|
+
platform,
|
|
5177
|
+
uri
|
|
5178
|
+
} = editor;
|
|
5179
|
+
const newEditor = await getNewEditor$1(editor);
|
|
5180
|
+
const content = getText$1(newEditor);
|
|
5181
|
+
if (isUntitledFile(uri)) {
|
|
5182
|
+
const pickedFilePath = await saveUntitledFile(uri, content, platform);
|
|
5183
|
+
if (pickedFilePath) {
|
|
5184
|
+
if (editor.modified) {
|
|
5185
|
+
await notifyTabModifiedStatusChange(uri, false);
|
|
5186
|
+
}
|
|
5187
|
+
return {
|
|
5188
|
+
...newEditor,
|
|
5189
|
+
modified: false,
|
|
5190
|
+
uri: pickedFilePath
|
|
5191
|
+
};
|
|
5192
|
+
}
|
|
5193
|
+
return newEditor;
|
|
5194
|
+
}
|
|
5195
|
+
await saveNormalFile(uri, content);
|
|
5196
|
+
if (editor.modified) {
|
|
5197
|
+
await notifyTabModifiedStatusChange(uri, false);
|
|
5198
|
+
}
|
|
5199
|
+
return {
|
|
5200
|
+
...newEditor,
|
|
5201
|
+
modified: false
|
|
5202
|
+
};
|
|
5203
|
+
} catch (error) {
|
|
5204
|
+
// @ts-ignore
|
|
5205
|
+
const betterError = new VError(error, `Failed to save file "${editor.uri}"`);
|
|
5206
|
+
await handleError$1(betterError);
|
|
5207
|
+
if (editor.platform === Electron) {
|
|
5208
|
+
try {
|
|
5209
|
+
await showSaveErrorDialog(betterError);
|
|
5210
|
+
} catch (dialogError) {
|
|
5211
|
+
await handleError$1(dialogError);
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
return editor;
|
|
5215
|
+
}
|
|
5216
|
+
};
|
|
5217
|
+
|
|
5218
|
+
const handleBlur$1 = async editor => {
|
|
5219
|
+
if (!editor.focused) {
|
|
5220
|
+
return editor;
|
|
5221
|
+
}
|
|
5222
|
+
const newEditor = {
|
|
5223
|
+
...editor,
|
|
5224
|
+
focused: false
|
|
5225
|
+
};
|
|
5226
|
+
if (!editor.modified) {
|
|
5227
|
+
return newEditor;
|
|
5228
|
+
}
|
|
5229
|
+
const autoSave = await get$2('files.autoSave');
|
|
5230
|
+
if (autoSave === 'off') {
|
|
5231
|
+
return newEditor;
|
|
5232
|
+
}
|
|
5233
|
+
return save(newEditor);
|
|
5234
|
+
};
|
|
5235
|
+
|
|
5236
|
+
const replaceRange = (editor, ranges, replacement, origin) => {
|
|
5237
|
+
const changes = [];
|
|
5238
|
+
const rangesLength = ranges.length;
|
|
5239
|
+
for (let i = 0; i < rangesLength; i += 4) {
|
|
5240
|
+
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(ranges, i);
|
|
5241
|
+
const start = {
|
|
5242
|
+
columnIndex: selectionStartColumn,
|
|
5243
|
+
rowIndex: selectionStartRow
|
|
5244
|
+
};
|
|
5245
|
+
const end = {
|
|
5246
|
+
columnIndex: selectionEndColumn,
|
|
5247
|
+
rowIndex: selectionEndRow
|
|
5248
|
+
};
|
|
5249
|
+
const selection = {
|
|
5250
|
+
end,
|
|
5251
|
+
start
|
|
5252
|
+
};
|
|
5253
|
+
changes.push({
|
|
5254
|
+
deleted: getSelectionText(editor, selection),
|
|
5255
|
+
end: end,
|
|
5256
|
+
inserted: replacement,
|
|
5257
|
+
origin,
|
|
5258
|
+
start: start
|
|
5259
|
+
});
|
|
5260
|
+
}
|
|
5261
|
+
return changes;
|
|
5262
|
+
};
|
|
5263
|
+
|
|
5264
|
+
const editorReplaceSelections = (editor, replacement, origin) => {
|
|
5265
|
+
const {
|
|
5266
|
+
selections
|
|
5267
|
+
} = editor;
|
|
5268
|
+
return replaceRange(editor, selections, replacement, origin);
|
|
5269
|
+
};
|
|
5270
|
+
|
|
4779
5271
|
// @ts-ignore
|
|
4780
5272
|
const getErrorMessage$4 = String;
|
|
4781
5273
|
|
|
@@ -5784,45 +6276,6 @@ const findAllReferences$1 = async editor => {
|
|
|
5784
6276
|
return editor;
|
|
5785
6277
|
};
|
|
5786
6278
|
|
|
5787
|
-
const getFormattingEdits = async editor => {
|
|
5788
|
-
const textDocument = {
|
|
5789
|
-
documentId: editor.id || editor.uid,
|
|
5790
|
-
languageId: editor.languageId,
|
|
5791
|
-
text: getText$1(editor),
|
|
5792
|
-
uri: editor.uri
|
|
5793
|
-
};
|
|
5794
|
-
return invoke$e('Extensions.executeFormattingProvider', textDocument);
|
|
5795
|
-
};
|
|
5796
|
-
|
|
5797
|
-
const expectedErrorMessage$1 = 'Failed to execute formatting provider: FormattingError:';
|
|
5798
|
-
const isFormattingError = error => {
|
|
5799
|
-
// @ts-ignore
|
|
5800
|
-
return error && error instanceof Error && error.message.startsWith(expectedErrorMessage$1);
|
|
5801
|
-
};
|
|
5802
|
-
|
|
5803
|
-
const expectedErrorMessage = 'Failed to execute formatting provider: FormattingError:';
|
|
5804
|
-
|
|
5805
|
-
// TODO also format with cursor
|
|
5806
|
-
const format = async editor => {
|
|
5807
|
-
try {
|
|
5808
|
-
const edits = await getFormattingEdits(editor);
|
|
5809
|
-
return applyDocumentEdits(editor, edits);
|
|
5810
|
-
} catch (error) {
|
|
5811
|
-
if (isFormattingError(error)) {
|
|
5812
|
-
console.error('Formatting Error:',
|
|
5813
|
-
// @ts-ignore
|
|
5814
|
-
error.message.slice(expectedErrorMessage.length));
|
|
5815
|
-
return editor;
|
|
5816
|
-
}
|
|
5817
|
-
console.error(error);
|
|
5818
|
-
|
|
5819
|
-
// TODO configure editor message as widget
|
|
5820
|
-
const displayErrorMessage = String(error);
|
|
5821
|
-
await editorShowMessage(editor, 0, 0, displayErrorMessage);
|
|
5822
|
-
return editor;
|
|
5823
|
-
}
|
|
5824
|
-
};
|
|
5825
|
-
|
|
5826
6279
|
/* eslint-disable sonarjs/super-linear-regex */
|
|
5827
6280
|
|
|
5828
6281
|
const RE_WORD_START$1 = /^[\w\-]+/;
|
|
@@ -5875,15 +6328,15 @@ const getDefinition = async (editor, offset) => {
|
|
|
5875
6328
|
};
|
|
5876
6329
|
|
|
5877
6330
|
const emptyObject = {};
|
|
5878
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
5879
6331
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
5880
6332
|
if (placeholders === emptyObject) {
|
|
5881
6333
|
return key;
|
|
5882
6334
|
}
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
6335
|
+
let result = key;
|
|
6336
|
+
for (const [placeholder, replacement] of Object.entries(placeholders)) {
|
|
6337
|
+
result = result.split(`{${placeholder}}`).join(String(replacement));
|
|
6338
|
+
}
|
|
6339
|
+
return result;
|
|
5887
6340
|
};
|
|
5888
6341
|
|
|
5889
6342
|
const Copy = 'Copy';
|
|
@@ -6786,7 +7239,7 @@ const editorMoveSelection = (editor, position) => {
|
|
|
6786
7239
|
};
|
|
6787
7240
|
|
|
6788
7241
|
// @ts-ignore
|
|
6789
|
-
const getNewEditor
|
|
7242
|
+
const getNewEditor = (editor, position) => {
|
|
6790
7243
|
const {
|
|
6791
7244
|
maxLineY,
|
|
6792
7245
|
minLineY,
|
|
@@ -6834,7 +7287,7 @@ const continueScrollingAndMovingSelection = async editorUid => {
|
|
|
6834
7287
|
if (position.rowIndex === 0) {
|
|
6835
7288
|
return;
|
|
6836
7289
|
}
|
|
6837
|
-
const newEditor = getNewEditor
|
|
7290
|
+
const newEditor = getNewEditor(editor, position);
|
|
6838
7291
|
if (editor === newEditor) {
|
|
6839
7292
|
return;
|
|
6840
7293
|
}
|
|
@@ -7499,6 +7952,16 @@ const openFind = async state => {
|
|
|
7499
7952
|
return openFind2(state);
|
|
7500
7953
|
};
|
|
7501
7954
|
|
|
7955
|
+
const getOffsetAtCursor$1 = editor => {
|
|
7956
|
+
const {
|
|
7957
|
+
selections
|
|
7958
|
+
} = editor;
|
|
7959
|
+
const rowIndex = selections[0];
|
|
7960
|
+
const columnIndex = selections[1];
|
|
7961
|
+
const offset = offsetAt(editor, rowIndex, columnIndex);
|
|
7962
|
+
return offset;
|
|
7963
|
+
};
|
|
7964
|
+
|
|
7502
7965
|
const getPositionAtCursor$1 = editor => {
|
|
7503
7966
|
const {
|
|
7504
7967
|
selections
|
|
@@ -7574,7 +8037,16 @@ const openRename = async editor => {
|
|
|
7574
8037
|
return editor;
|
|
7575
8038
|
}
|
|
7576
8039
|
const fullFocus = true;
|
|
7577
|
-
|
|
8040
|
+
const editorWithRenameWidget = await addWidgetToEditor(Rename$1, FocusEditorRename$1, editor, create$2, newStateGenerator$2, fullFocus);
|
|
8041
|
+
if (editorWithRenameWidget === editor) {
|
|
8042
|
+
return editor;
|
|
8043
|
+
}
|
|
8044
|
+
const wordBefore = getWordBefore(editor, rowIndex, columnIndex);
|
|
8045
|
+
const offset = getOffsetAtCursor$1(editor) - wordBefore.length;
|
|
8046
|
+
return {
|
|
8047
|
+
...editorWithRenameWidget,
|
|
8048
|
+
decorations: [...editorWithRenameWidget.decorations, offset, word.length, 3, 0]
|
|
8049
|
+
};
|
|
7578
8050
|
};
|
|
7579
8051
|
|
|
7580
8052
|
const getOrganizeImportEdits = async editor => {
|
|
@@ -7623,106 +8095,6 @@ const redo = state => {
|
|
|
7623
8095
|
return scheduleDocumentAndCursorsSelectionIsUndo(newState, last);
|
|
7624
8096
|
};
|
|
7625
8097
|
|
|
7626
|
-
// @ts-ignore
|
|
7627
|
-
const getNewEditor = async editor => {
|
|
7628
|
-
return editor;
|
|
7629
|
-
};
|
|
7630
|
-
|
|
7631
|
-
const isUntitledFile = uri => {
|
|
7632
|
-
return uri.startsWith('untitled:');
|
|
7633
|
-
};
|
|
7634
|
-
|
|
7635
|
-
const saveNormalFile = async (uri, content) => {
|
|
7636
|
-
await invoke$b('FileSystem.writeFile', uri, content);
|
|
7637
|
-
};
|
|
7638
|
-
|
|
7639
|
-
const showFilePicker = async platform => {
|
|
7640
|
-
const dialogTitle = 'Save File'; // TODO use i18n string
|
|
7641
|
-
const {
|
|
7642
|
-
canceled,
|
|
7643
|
-
filePath
|
|
7644
|
-
} = await invoke$d('Open.showSaveDialog', dialogTitle, [], platform);
|
|
7645
|
-
if (canceled) {
|
|
7646
|
-
return '';
|
|
7647
|
-
}
|
|
7648
|
-
return filePath;
|
|
7649
|
-
};
|
|
7650
|
-
|
|
7651
|
-
const saveUntitledFile = async (uri, content, platform) => {
|
|
7652
|
-
const filePath = await showFilePicker(platform);
|
|
7653
|
-
if (!filePath) {
|
|
7654
|
-
return;
|
|
7655
|
-
}
|
|
7656
|
-
await invoke$b('FileSystem.writeFile', filePath, content);
|
|
7657
|
-
await handleWorkspaceRefresh();
|
|
7658
|
-
await invoke$b('Main.handleUriChange', uri, filePath);
|
|
7659
|
-
return filePath;
|
|
7660
|
-
};
|
|
7661
|
-
|
|
7662
|
-
const isPermissionDeniedError = error => {
|
|
7663
|
-
const errorCode = 'code' in error ? error.code : undefined;
|
|
7664
|
-
return errorCode === 'EACCES' || error.message.includes('EACCES:');
|
|
7665
|
-
};
|
|
7666
|
-
const showSaveErrorDialog = async error => {
|
|
7667
|
-
if (isPermissionDeniedError(error)) {
|
|
7668
|
-
await invoke$b('ElectronDialog.showMessageBox', {
|
|
7669
|
-
buttons: ['OK'],
|
|
7670
|
-
defaultId: 0,
|
|
7671
|
-
message: "You don't have permission to save changes to this file.",
|
|
7672
|
-
title: 'Unable to Save File',
|
|
7673
|
-
type: 'error'
|
|
7674
|
-
});
|
|
7675
|
-
return;
|
|
7676
|
-
}
|
|
7677
|
-
await invoke$b('ElectronDialog.showMessageBox', {
|
|
7678
|
-
buttons: ['OK'],
|
|
7679
|
-
defaultId: 0,
|
|
7680
|
-
detail: error.message,
|
|
7681
|
-
message: 'Saving the file failed.',
|
|
7682
|
-
title: 'Failed to Save File',
|
|
7683
|
-
type: 'error'
|
|
7684
|
-
});
|
|
7685
|
-
};
|
|
7686
|
-
|
|
7687
|
-
const save = async editor => {
|
|
7688
|
-
try {
|
|
7689
|
-
const {
|
|
7690
|
-
platform,
|
|
7691
|
-
uri
|
|
7692
|
-
} = editor;
|
|
7693
|
-
const newEditor = await getNewEditor(editor);
|
|
7694
|
-
const content = getText$1(newEditor);
|
|
7695
|
-
if (isUntitledFile(uri)) {
|
|
7696
|
-
const pickedFilePath = await saveUntitledFile(uri, content, platform);
|
|
7697
|
-
if (pickedFilePath) {
|
|
7698
|
-
return {
|
|
7699
|
-
...newEditor,
|
|
7700
|
-
modified: false,
|
|
7701
|
-
uri: pickedFilePath
|
|
7702
|
-
};
|
|
7703
|
-
}
|
|
7704
|
-
return newEditor;
|
|
7705
|
-
}
|
|
7706
|
-
await saveNormalFile(uri, content);
|
|
7707
|
-
return {
|
|
7708
|
-
...newEditor,
|
|
7709
|
-
modified: false
|
|
7710
|
-
};
|
|
7711
|
-
} catch (error) {
|
|
7712
|
-
// @ts-ignore
|
|
7713
|
-
const betterError = new VError(error, `Failed to save file "${editor.uri}"`);
|
|
7714
|
-
await handleError$1(betterError);
|
|
7715
|
-
if (editor.platform === Electron) {
|
|
7716
|
-
try {
|
|
7717
|
-
await showSaveErrorDialog(betterError);
|
|
7718
|
-
} catch (dialogError) {
|
|
7719
|
-
await handleError$1(dialogError);
|
|
7720
|
-
}
|
|
7721
|
-
}
|
|
7722
|
-
return editor;
|
|
7723
|
-
}
|
|
7724
|
-
};
|
|
7725
|
-
|
|
7726
8098
|
// @ts-ignore
|
|
7727
8099
|
|
|
7728
8100
|
// @ts-ignore
|
|
@@ -8567,16 +8939,6 @@ const executeTabCompletionProvider = async (editor, offset) => {
|
|
|
8567
8939
|
});
|
|
8568
8940
|
};
|
|
8569
8941
|
|
|
8570
|
-
const getOffsetAtCursor$1 = editor => {
|
|
8571
|
-
const {
|
|
8572
|
-
selections
|
|
8573
|
-
} = editor;
|
|
8574
|
-
const rowIndex = selections[0];
|
|
8575
|
-
const columnIndex = selections[1];
|
|
8576
|
-
const offset = offsetAt(editor, rowIndex, columnIndex);
|
|
8577
|
-
return offset;
|
|
8578
|
-
};
|
|
8579
|
-
|
|
8580
8942
|
const getTabCompletion = async editor => {
|
|
8581
8943
|
const offset = getOffsetAtCursor$1(editor);
|
|
8582
8944
|
const completions = await executeTabCompletionProvider(editor, offset);
|
|
@@ -10279,6 +10641,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
|
|
|
10279
10641
|
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
10280
10642
|
const newEditor = {
|
|
10281
10643
|
...editor,
|
|
10644
|
+
decorations: widgetId === Rename$1 ? editor.decorations.slice(0, -4) : editor.decorations,
|
|
10282
10645
|
focused: true,
|
|
10283
10646
|
widgets: newWidgets
|
|
10284
10647
|
};
|
|
@@ -11364,6 +11727,7 @@ ${editorSelector} .EditorRow {
|
|
|
11364
11727
|
height: var(--EditorRowHeight);
|
|
11365
11728
|
line-height: var(--EditorRowHeight);
|
|
11366
11729
|
}
|
|
11730
|
+
${editorSelector} .R{background-color:#add6ff40}
|
|
11367
11731
|
${editorSelector} .ScrollBarThumbVertical {
|
|
11368
11732
|
height: var(--ScrollBarHeight);
|
|
11369
11733
|
translate: 0px var(--ScrollBarTop);
|
|
@@ -11411,6 +11775,8 @@ const renderFocusContext$1 = (oldState, newState) => {
|
|
|
11411
11775
|
return [SetFocusContext$1, newState.uid, newState.focus];
|
|
11412
11776
|
};
|
|
11413
11777
|
|
|
11778
|
+
new Set(Object.values(VirtualDomElements));
|
|
11779
|
+
|
|
11414
11780
|
const SetText = 1;
|
|
11415
11781
|
const Replace = 2;
|
|
11416
11782
|
const SetAttribute = 3;
|