@lvce-editor/editor-worker 19.77.2 → 19.77.4
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/README.md +8 -0
- package/dist/diff-sdk.d.ts +1 -0
- package/dist/diff-sdk.js +1851 -386
- package/dist/editorWorkerMain.js +1961 -462
- package/dist/settings.json +8 -0
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -559,7 +559,7 @@ const execute$1 = (command, ...args) => {
|
|
|
559
559
|
|
|
560
560
|
const Two$1 = '2.0';
|
|
561
561
|
const callbacks = Object.create(null);
|
|
562
|
-
const get$
|
|
562
|
+
const get$b = id => {
|
|
563
563
|
return callbacks[id];
|
|
564
564
|
};
|
|
565
565
|
const remove$9 = id => {
|
|
@@ -780,7 +780,7 @@ const warn$1 = (...args) => {
|
|
|
780
780
|
console.warn(...args);
|
|
781
781
|
};
|
|
782
782
|
const resolve = (id, response) => {
|
|
783
|
-
const fn = get$
|
|
783
|
+
const fn = get$b(id);
|
|
784
784
|
if (!fn) {
|
|
785
785
|
console.log(response);
|
|
786
786
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -1187,10 +1187,10 @@ const createMockRpc = ({
|
|
|
1187
1187
|
};
|
|
1188
1188
|
|
|
1189
1189
|
const rpcs = Object.create(null);
|
|
1190
|
-
const set$
|
|
1190
|
+
const set$l = (id, rpc) => {
|
|
1191
1191
|
rpcs[id] = rpc;
|
|
1192
1192
|
};
|
|
1193
|
-
const get$
|
|
1193
|
+
const get$a = id => {
|
|
1194
1194
|
return rpcs[id];
|
|
1195
1195
|
};
|
|
1196
1196
|
const remove$8 = id => {
|
|
@@ -1201,18 +1201,18 @@ const remove$8 = id => {
|
|
|
1201
1201
|
const create$c = rpcId => {
|
|
1202
1202
|
return {
|
|
1203
1203
|
async dispose() {
|
|
1204
|
-
const rpc = get$
|
|
1204
|
+
const rpc = get$a(rpcId);
|
|
1205
1205
|
await rpc.dispose();
|
|
1206
1206
|
},
|
|
1207
1207
|
// @ts-ignore
|
|
1208
1208
|
invoke(method, ...params) {
|
|
1209
|
-
const rpc = get$
|
|
1209
|
+
const rpc = get$a(rpcId);
|
|
1210
1210
|
// @ts-ignore
|
|
1211
1211
|
return rpc.invoke(method, ...params);
|
|
1212
1212
|
},
|
|
1213
1213
|
// @ts-ignore
|
|
1214
1214
|
invokeAndTransfer(method, ...params) {
|
|
1215
|
-
const rpc = get$
|
|
1215
|
+
const rpc = get$a(rpcId);
|
|
1216
1216
|
// @ts-ignore
|
|
1217
1217
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1218
1218
|
},
|
|
@@ -1220,7 +1220,7 @@ const create$c = rpcId => {
|
|
|
1220
1220
|
const mockRpc = createMockRpc({
|
|
1221
1221
|
commandMap
|
|
1222
1222
|
});
|
|
1223
|
-
set$
|
|
1223
|
+
set$l(rpcId, mockRpc);
|
|
1224
1224
|
// @ts-ignore
|
|
1225
1225
|
mockRpc[Symbol.dispose] = () => {
|
|
1226
1226
|
remove$8(rpcId);
|
|
@@ -1229,11 +1229,22 @@ const create$c = rpcId => {
|
|
|
1229
1229
|
return mockRpc;
|
|
1230
1230
|
},
|
|
1231
1231
|
set(rpc) {
|
|
1232
|
-
set$
|
|
1232
|
+
set$l(rpcId, rpc);
|
|
1233
1233
|
}
|
|
1234
1234
|
};
|
|
1235
1235
|
};
|
|
1236
1236
|
|
|
1237
|
+
const {
|
|
1238
|
+
invoke: invoke$l,
|
|
1239
|
+
set: set$k
|
|
1240
|
+
} = create$c(19_001);
|
|
1241
|
+
const getCacheStorageJsonItem = async (request, cacheName, bucketName, bucketOptions) => {
|
|
1242
|
+
return invoke$l('Cache.getCacheStorageJsonItem', request, cacheName, bucketName, bucketOptions);
|
|
1243
|
+
};
|
|
1244
|
+
const setCacheStorageJsonItem = async (request, value, cacheName, bucketName, bucketOptions) => {
|
|
1245
|
+
return invoke$l('Cache.setCacheStorageJsonItem', request, value, cacheName, bucketName, bucketOptions);
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1237
1248
|
const Text$1 = 12;
|
|
1238
1249
|
const Reference = 100;
|
|
1239
1250
|
|
|
@@ -1328,23 +1339,23 @@ const FocusEditorText$1 = 12;
|
|
|
1328
1339
|
|
|
1329
1340
|
const {
|
|
1330
1341
|
invoke: invoke$k,
|
|
1331
|
-
set: set$
|
|
1342
|
+
set: set$j
|
|
1332
1343
|
} = create$c(DialogWorker);
|
|
1333
1344
|
|
|
1334
1345
|
const {
|
|
1335
1346
|
invoke: invoke$j,
|
|
1336
|
-
set: set$
|
|
1347
|
+
set: set$i
|
|
1337
1348
|
} = create$c(DragAndDropWorker);
|
|
1338
1349
|
|
|
1339
1350
|
const {
|
|
1340
1351
|
invoke: invoke$i,
|
|
1341
|
-
set: set$
|
|
1352
|
+
set: set$h
|
|
1342
1353
|
} = create$c(ErrorWorker);
|
|
1343
1354
|
|
|
1344
1355
|
const {
|
|
1345
1356
|
invoke: invoke$h,
|
|
1346
1357
|
invokeAndTransfer: invokeAndTransfer$2,
|
|
1347
|
-
set: set$
|
|
1358
|
+
set: set$g
|
|
1348
1359
|
} = create$c(ExtensionManagementWorker);
|
|
1349
1360
|
const getLanguages$1 = (platform, assetDir) => {
|
|
1350
1361
|
return invoke$h('Extensions.getLanguages', platform, assetDir);
|
|
@@ -1363,7 +1374,7 @@ const createLazyRpc = rpcId => {
|
|
|
1363
1374
|
throw new Error('Lazy RPC launch was superseded');
|
|
1364
1375
|
}
|
|
1365
1376
|
activeRpc = rpc;
|
|
1366
|
-
set$
|
|
1377
|
+
set$l(rpcId, rpc);
|
|
1367
1378
|
return rpc;
|
|
1368
1379
|
};
|
|
1369
1380
|
const ensureRpc = async () => {
|
|
@@ -1386,7 +1397,7 @@ const createLazyRpc = rpcId => {
|
|
|
1386
1397
|
const rpc = activeRpc;
|
|
1387
1398
|
activeRpc = undefined;
|
|
1388
1399
|
rpcPromise = undefined;
|
|
1389
|
-
if (rpc && get$
|
|
1400
|
+
if (rpc && get$a(rpcId) === rpc) {
|
|
1390
1401
|
remove$8(rpcId);
|
|
1391
1402
|
}
|
|
1392
1403
|
if (notify) {
|
|
@@ -1425,7 +1436,7 @@ const createLazyRpc = rpcId => {
|
|
|
1425
1436
|
|
|
1426
1437
|
const {
|
|
1427
1438
|
invoke: invoke$g,
|
|
1428
|
-
set: set$
|
|
1439
|
+
set: set$f
|
|
1429
1440
|
} = create$c(OpenerWorker);
|
|
1430
1441
|
const openUrl = async (url, platform) => {
|
|
1431
1442
|
return invoke$g('Open.openUrl', url, platform);
|
|
@@ -1433,13 +1444,13 @@ const openUrl = async (url, platform) => {
|
|
|
1433
1444
|
|
|
1434
1445
|
const {
|
|
1435
1446
|
invoke: invoke$f,
|
|
1436
|
-
set: set$
|
|
1447
|
+
set: set$e
|
|
1437
1448
|
} = create$c(TextMeasurementWorker);
|
|
1438
1449
|
|
|
1439
1450
|
const {
|
|
1440
1451
|
invoke: invoke$e,
|
|
1441
1452
|
invokeAndTransfer: invokeAndTransfer$1,
|
|
1442
|
-
set: set$
|
|
1453
|
+
set: set$d
|
|
1443
1454
|
} = create$c(RendererWorker);
|
|
1444
1455
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1445
1456
|
number(uid);
|
|
@@ -1474,6 +1485,10 @@ const sendMessagePortToTextMeasurementWorker = async port => {
|
|
|
1474
1485
|
const command = 'TextMeasurement.handleMessagePort';
|
|
1475
1486
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1476
1487
|
};
|
|
1488
|
+
const sendMessagePortToCacheWorker = async port => {
|
|
1489
|
+
const command = 'CacheWorker.handleMessagePort';
|
|
1490
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToCacheWorker', port, command, 0);
|
|
1491
|
+
};
|
|
1477
1492
|
const sendMessagePortToExtensionManagementWorker$1 = async (port, rpcId) => {
|
|
1478
1493
|
const command = 'Extensions.handleMessagePort';
|
|
1479
1494
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
@@ -1494,7 +1509,7 @@ const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
|
|
|
1494
1509
|
|
|
1495
1510
|
const {
|
|
1496
1511
|
invoke: invoke$d,
|
|
1497
|
-
set: set$
|
|
1512
|
+
set: set$c
|
|
1498
1513
|
} = create$c(MarkdownWorker);
|
|
1499
1514
|
|
|
1500
1515
|
const toCommandId = key => {
|
|
@@ -1799,19 +1814,19 @@ const {
|
|
|
1799
1814
|
wrapCommand: wrapCommand$2,
|
|
1800
1815
|
wrapGetter
|
|
1801
1816
|
} = editorStates;
|
|
1802
|
-
const get$
|
|
1817
|
+
const get$9 = id => {
|
|
1803
1818
|
return editorStates.get(id);
|
|
1804
1819
|
};
|
|
1805
1820
|
const getKeys$2 = () => {
|
|
1806
1821
|
const keys = editorStates.getKeys();
|
|
1807
1822
|
return keys.map(String);
|
|
1808
1823
|
};
|
|
1809
|
-
const set$
|
|
1824
|
+
const set$b = (id, oldEditor, newEditor) => {
|
|
1810
1825
|
editorStates.set(id, oldEditor, newEditor);
|
|
1811
1826
|
};
|
|
1812
1827
|
|
|
1813
1828
|
const getEditor$1 = editorUid => {
|
|
1814
|
-
const instance = get$
|
|
1829
|
+
const instance = get$9(editorUid);
|
|
1815
1830
|
if (!instance) {
|
|
1816
1831
|
throw new Error(`editor ${editorUid} not found`);
|
|
1817
1832
|
}
|
|
@@ -1857,15 +1872,15 @@ const ToggleBlockComment$1 = 'toggleBlockComment';
|
|
|
1857
1872
|
const Unknown$2 = 'unknown';
|
|
1858
1873
|
|
|
1859
1874
|
const map$1 = Object.create(null);
|
|
1860
|
-
const set$
|
|
1875
|
+
const set$a = (id, widget) => {
|
|
1861
1876
|
map$1[id] = widget;
|
|
1862
1877
|
};
|
|
1863
|
-
const get$
|
|
1878
|
+
const get$8 = id => {
|
|
1864
1879
|
return map$1[id];
|
|
1865
1880
|
};
|
|
1866
1881
|
|
|
1867
1882
|
const getModule = id => {
|
|
1868
|
-
return get$
|
|
1883
|
+
return get$8(id);
|
|
1869
1884
|
};
|
|
1870
1885
|
|
|
1871
1886
|
const applyWidgetChange = async (editor, widget, changes) => {
|
|
@@ -2255,6 +2270,1196 @@ const findRange = (lines, rowIndex) => {
|
|
|
2255
2270
|
return ranges.filter(range => range.start <= rowIndex && rowIndex <= range.end).toSorted((a, b) => a.end - a.start - (b.end - b.start))[0];
|
|
2256
2271
|
};
|
|
2257
2272
|
|
|
2273
|
+
function bidiFactory$1() {
|
|
2274
|
+
var bidi = (function (exports) {
|
|
2275
|
+
|
|
2276
|
+
// Bidi character types data, auto generated
|
|
2277
|
+
var DATA = {
|
|
2278
|
+
"R": "13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",
|
|
2279
|
+
"EN": "1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",
|
|
2280
|
+
"ES": "17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",
|
|
2281
|
+
"ET": "z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",
|
|
2282
|
+
"AN": "16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",
|
|
2283
|
+
"CS": "18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",
|
|
2284
|
+
"B": "a,3,f+2,2v,690",
|
|
2285
|
+
"S": "9,2,k",
|
|
2286
|
+
"WS": "c,k,4f4,1vk+a,u,1j,335",
|
|
2287
|
+
"ON": "x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",
|
|
2288
|
+
"BN": "0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",
|
|
2289
|
+
"NSM": "lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",
|
|
2290
|
+
"AL": "16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",
|
|
2291
|
+
"LRO": "6ct",
|
|
2292
|
+
"RLO": "6cu",
|
|
2293
|
+
"LRE": "6cq",
|
|
2294
|
+
"RLE": "6cr",
|
|
2295
|
+
"PDF": "6cs",
|
|
2296
|
+
"LRI": "6ee",
|
|
2297
|
+
"RLI": "6ef",
|
|
2298
|
+
"FSI": "6eg",
|
|
2299
|
+
"PDI": "6eh"
|
|
2300
|
+
};
|
|
2301
|
+
|
|
2302
|
+
var TYPES = {};
|
|
2303
|
+
var TYPES_TO_NAMES = {};
|
|
2304
|
+
TYPES.L = 1; //L is the default
|
|
2305
|
+
TYPES_TO_NAMES[1] = 'L';
|
|
2306
|
+
Object.keys(DATA).forEach(function (type, i) {
|
|
2307
|
+
TYPES[type] = 1 << (i + 1);
|
|
2308
|
+
TYPES_TO_NAMES[TYPES[type]] = type;
|
|
2309
|
+
});
|
|
2310
|
+
Object.freeze(TYPES);
|
|
2311
|
+
|
|
2312
|
+
var ISOLATE_INIT_TYPES = TYPES.LRI | TYPES.RLI | TYPES.FSI;
|
|
2313
|
+
var STRONG_TYPES = TYPES.L | TYPES.R | TYPES.AL;
|
|
2314
|
+
var NEUTRAL_ISOLATE_TYPES = TYPES.B | TYPES.S | TYPES.WS | TYPES.ON | TYPES.FSI | TYPES.LRI | TYPES.RLI | TYPES.PDI;
|
|
2315
|
+
var BN_LIKE_TYPES = TYPES.BN | TYPES.RLE | TYPES.LRE | TYPES.RLO | TYPES.LRO | TYPES.PDF;
|
|
2316
|
+
var TRAILING_TYPES = TYPES.S | TYPES.WS | TYPES.B | ISOLATE_INIT_TYPES | TYPES.PDI | BN_LIKE_TYPES;
|
|
2317
|
+
|
|
2318
|
+
var map = null;
|
|
2319
|
+
|
|
2320
|
+
function parseData () {
|
|
2321
|
+
if (!map) {
|
|
2322
|
+
//const start = performance.now()
|
|
2323
|
+
map = new Map();
|
|
2324
|
+
var start = 0;
|
|
2325
|
+
for (var type in DATA) {
|
|
2326
|
+
if (DATA.hasOwnProperty(type)) {
|
|
2327
|
+
var segments = DATA[type];
|
|
2328
|
+
var temp = '';
|
|
2329
|
+
var end = (void 0);
|
|
2330
|
+
var state = false;
|
|
2331
|
+
var lastCode = 0;
|
|
2332
|
+
for (var i = 0; i <= segments.length + 1; i += 1) {
|
|
2333
|
+
var char = segments[i];
|
|
2334
|
+
if (char !== ',' && i !== segments.length) {
|
|
2335
|
+
if (char === '+') {
|
|
2336
|
+
state = true;
|
|
2337
|
+
lastCode = start = lastCode + parseInt(temp, 36);
|
|
2338
|
+
temp = '';
|
|
2339
|
+
} else {
|
|
2340
|
+
temp += char;
|
|
2341
|
+
}
|
|
2342
|
+
} else {
|
|
2343
|
+
if (!state) {
|
|
2344
|
+
lastCode = start = lastCode + parseInt(temp, 36);
|
|
2345
|
+
end = start;
|
|
2346
|
+
} else {
|
|
2347
|
+
end = start + parseInt(temp, 36);
|
|
2348
|
+
}
|
|
2349
|
+
state = false;
|
|
2350
|
+
temp = '';
|
|
2351
|
+
lastCode = end;
|
|
2352
|
+
for (var j = start; j < end + 1; j += 1) {
|
|
2353
|
+
map.set(j, TYPES[type]);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
//console.log(`char types parsed in ${performance.now() - start}ms`)
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
/**
|
|
2364
|
+
* @param {string} char
|
|
2365
|
+
* @return {number}
|
|
2366
|
+
*/
|
|
2367
|
+
function getBidiCharType (char) {
|
|
2368
|
+
parseData();
|
|
2369
|
+
return map.get(char.codePointAt(0)) || TYPES.L
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
/**
|
|
2373
|
+
* Get Bidi Character Type Name
|
|
2374
|
+
* @param {string} char
|
|
2375
|
+
* @returns { "L" | "R" | "EN" | "ES" | "ET" | "AN" | "CS" | "B" | "S" | "WS" | "ON" | "BN" | "NSM" | "AL" | "LRO" | "RLO" | "LRE" | "RLE" | "PDF" | "LRI" | "RLI" | "FSI" | "PDI" }
|
|
2376
|
+
*/
|
|
2377
|
+
function getBidiCharTypeName(char) {
|
|
2378
|
+
return TYPES_TO_NAMES[getBidiCharType(char)]
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
// Bidi bracket pairs data, auto generated
|
|
2382
|
+
var data$1 = {
|
|
2383
|
+
"pairs": "14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",
|
|
2384
|
+
"canonical": "6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2387
|
+
/**
|
|
2388
|
+
* Parses an string that holds encoded codepoint mappings, e.g. for bracket pairs or
|
|
2389
|
+
* mirroring characters, as encoded by scripts/generateBidiData.js. Returns an object
|
|
2390
|
+
* holding the `map`, and optionally a `reverseMap` if `includeReverse:true`.
|
|
2391
|
+
* @param {string} encodedString
|
|
2392
|
+
* @param {boolean} includeReverse - true if you want reverseMap in the output
|
|
2393
|
+
* @return {{map: Map<number, number>, reverseMap?: Map<number, number>}}
|
|
2394
|
+
*/
|
|
2395
|
+
function parseCharacterMap (encodedString, includeReverse) {
|
|
2396
|
+
var radix = 36;
|
|
2397
|
+
var lastCode = 0;
|
|
2398
|
+
var map = new Map();
|
|
2399
|
+
var reverseMap = includeReverse && new Map();
|
|
2400
|
+
var prevPair;
|
|
2401
|
+
encodedString.split(',').forEach(function visit(entry) {
|
|
2402
|
+
if (entry.indexOf('+') !== -1) {
|
|
2403
|
+
for (var i = +entry; i--;) {
|
|
2404
|
+
visit(prevPair);
|
|
2405
|
+
}
|
|
2406
|
+
} else {
|
|
2407
|
+
prevPair = entry;
|
|
2408
|
+
var ref = entry.split('>');
|
|
2409
|
+
var a = ref[0];
|
|
2410
|
+
var b = ref[1];
|
|
2411
|
+
a = String.fromCodePoint(lastCode += parseInt(a, radix));
|
|
2412
|
+
b = String.fromCodePoint(lastCode += parseInt(b, radix));
|
|
2413
|
+
map.set(a, b);
|
|
2414
|
+
includeReverse && reverseMap.set(b, a);
|
|
2415
|
+
}
|
|
2416
|
+
});
|
|
2417
|
+
return { map: map, reverseMap: reverseMap }
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
var openToClose, closeToOpen, canonical;
|
|
2421
|
+
|
|
2422
|
+
function parse$1 () {
|
|
2423
|
+
if (!openToClose) {
|
|
2424
|
+
//const start = performance.now()
|
|
2425
|
+
var ref = parseCharacterMap(data$1.pairs, true);
|
|
2426
|
+
var map = ref.map;
|
|
2427
|
+
var reverseMap = ref.reverseMap;
|
|
2428
|
+
openToClose = map;
|
|
2429
|
+
closeToOpen = reverseMap;
|
|
2430
|
+
canonical = parseCharacterMap(data$1.canonical, false).map;
|
|
2431
|
+
//console.log(`brackets parsed in ${performance.now() - start}ms`)
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
/**
|
|
2436
|
+
* Get the opening bracket character corresponding to a given closing bracket character.
|
|
2437
|
+
* @param {string} char
|
|
2438
|
+
* @returns {string | null}
|
|
2439
|
+
*/
|
|
2440
|
+
function openingToClosingBracket (char) {
|
|
2441
|
+
parse$1();
|
|
2442
|
+
return openToClose.get(char) || null
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
/**
|
|
2446
|
+
* Get the closing bracket character corresponding to a given opening bracket character.
|
|
2447
|
+
* @param {string} char
|
|
2448
|
+
* @returns {string | null}
|
|
2449
|
+
*/
|
|
2450
|
+
function closingToOpeningBracket (char) {
|
|
2451
|
+
parse$1();
|
|
2452
|
+
return closeToOpen.get(char) || null
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
/**
|
|
2456
|
+
* Retrieves the canonical form of a bracket character.
|
|
2457
|
+
* @param {string} char
|
|
2458
|
+
* @returns {string | null}
|
|
2459
|
+
*/
|
|
2460
|
+
function getCanonicalBracket (char) {
|
|
2461
|
+
parse$1();
|
|
2462
|
+
return canonical.get(char) || null
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
// Local type aliases
|
|
2466
|
+
var TYPE_L = TYPES.L;
|
|
2467
|
+
var TYPE_R = TYPES.R;
|
|
2468
|
+
var TYPE_EN = TYPES.EN;
|
|
2469
|
+
var TYPE_ES = TYPES.ES;
|
|
2470
|
+
var TYPE_ET = TYPES.ET;
|
|
2471
|
+
var TYPE_AN = TYPES.AN;
|
|
2472
|
+
var TYPE_CS = TYPES.CS;
|
|
2473
|
+
var TYPE_B = TYPES.B;
|
|
2474
|
+
var TYPE_S = TYPES.S;
|
|
2475
|
+
var TYPE_ON = TYPES.ON;
|
|
2476
|
+
var TYPE_BN = TYPES.BN;
|
|
2477
|
+
var TYPE_NSM = TYPES.NSM;
|
|
2478
|
+
var TYPE_AL = TYPES.AL;
|
|
2479
|
+
var TYPE_LRO = TYPES.LRO;
|
|
2480
|
+
var TYPE_RLO = TYPES.RLO;
|
|
2481
|
+
var TYPE_LRE = TYPES.LRE;
|
|
2482
|
+
var TYPE_RLE = TYPES.RLE;
|
|
2483
|
+
var TYPE_PDF = TYPES.PDF;
|
|
2484
|
+
var TYPE_LRI = TYPES.LRI;
|
|
2485
|
+
var TYPE_RLI = TYPES.RLI;
|
|
2486
|
+
var TYPE_FSI = TYPES.FSI;
|
|
2487
|
+
var TYPE_PDI = TYPES.PDI;
|
|
2488
|
+
|
|
2489
|
+
/**
|
|
2490
|
+
* @typedef {object} GetEmbeddingLevelsResult
|
|
2491
|
+
* @property {{start: number, end: number, level: number}[]} paragraphs
|
|
2492
|
+
* @property {Uint8Array} levels
|
|
2493
|
+
*/
|
|
2494
|
+
|
|
2495
|
+
/**
|
|
2496
|
+
* This function applies the Bidirectional Algorithm to a string, returning the resolved embedding levels
|
|
2497
|
+
* in a single Uint8Array plus a list of objects holding each paragraph's start and end indices and resolved
|
|
2498
|
+
* base embedding level.
|
|
2499
|
+
*
|
|
2500
|
+
* @param {string} string - The input string
|
|
2501
|
+
* @param {"ltr"|"rtl"|"auto"} [baseDirection] - Use "ltr" or "rtl" to force a base paragraph direction,
|
|
2502
|
+
* otherwise a direction will be chosen automatically from each paragraph's contents.
|
|
2503
|
+
* @return {GetEmbeddingLevelsResult}
|
|
2504
|
+
*/
|
|
2505
|
+
function getEmbeddingLevels (string, baseDirection) {
|
|
2506
|
+
var MAX_DEPTH = 125;
|
|
2507
|
+
|
|
2508
|
+
// Start by mapping all characters to their unicode type, as a bitmask integer
|
|
2509
|
+
var charTypes = new Uint32Array(string.length);
|
|
2510
|
+
for (var i = 0; i < string.length; i++) {
|
|
2511
|
+
charTypes[i] = getBidiCharType(string[i]);
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
var charTypeCounts = new Map(); //will be cleared at start of each paragraph
|
|
2515
|
+
function changeCharType(i, type) {
|
|
2516
|
+
var oldType = charTypes[i];
|
|
2517
|
+
charTypes[i] = type;
|
|
2518
|
+
charTypeCounts.set(oldType, charTypeCounts.get(oldType) - 1);
|
|
2519
|
+
if (oldType & NEUTRAL_ISOLATE_TYPES) {
|
|
2520
|
+
charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) - 1);
|
|
2521
|
+
}
|
|
2522
|
+
charTypeCounts.set(type, (charTypeCounts.get(type) || 0) + 1);
|
|
2523
|
+
if (type & NEUTRAL_ISOLATE_TYPES) {
|
|
2524
|
+
charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) || 0) + 1);
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
var embedLevels = new Uint8Array(string.length);
|
|
2529
|
+
var isolationPairs = new Map(); //init->pdi and pdi->init
|
|
2530
|
+
|
|
2531
|
+
// === 3.3.1 The Paragraph Level ===
|
|
2532
|
+
// 3.3.1 P1: Split the text into paragraphs
|
|
2533
|
+
var paragraphs = []; // [{start, end, level}, ...]
|
|
2534
|
+
var paragraph = null;
|
|
2535
|
+
for (var i$1 = 0; i$1 < string.length; i$1++) {
|
|
2536
|
+
if (!paragraph) {
|
|
2537
|
+
paragraphs.push(paragraph = {
|
|
2538
|
+
start: i$1,
|
|
2539
|
+
end: string.length - 1,
|
|
2540
|
+
// 3.3.1 P2-P3: Determine the paragraph level
|
|
2541
|
+
level: baseDirection === 'rtl' ? 1 : baseDirection === 'ltr' ? 0 : determineAutoEmbedLevel(i$1, false)
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
if (charTypes[i$1] & TYPE_B) {
|
|
2545
|
+
paragraph.end = i$1;
|
|
2546
|
+
paragraph = null;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
var FORMATTING_TYPES = TYPE_RLE | TYPE_LRE | TYPE_RLO | TYPE_LRO | ISOLATE_INIT_TYPES | TYPE_PDI | TYPE_PDF | TYPE_B;
|
|
2551
|
+
var nextEven = function (n) { return n + ((n & 1) ? 1 : 2); };
|
|
2552
|
+
var nextOdd = function (n) { return n + ((n & 1) ? 2 : 1); };
|
|
2553
|
+
|
|
2554
|
+
// Everything from here on will operate per paragraph.
|
|
2555
|
+
for (var paraIdx = 0; paraIdx < paragraphs.length; paraIdx++) {
|
|
2556
|
+
paragraph = paragraphs[paraIdx];
|
|
2557
|
+
var statusStack = [{
|
|
2558
|
+
_level: paragraph.level,
|
|
2559
|
+
_override: 0, //0=neutral, 1=L, 2=R
|
|
2560
|
+
_isolate: 0 //bool
|
|
2561
|
+
}];
|
|
2562
|
+
var stackTop = (void 0);
|
|
2563
|
+
var overflowIsolateCount = 0;
|
|
2564
|
+
var overflowEmbeddingCount = 0;
|
|
2565
|
+
var validIsolateCount = 0;
|
|
2566
|
+
charTypeCounts.clear();
|
|
2567
|
+
|
|
2568
|
+
// === 3.3.2 Explicit Levels and Directions ===
|
|
2569
|
+
for (var i$2 = paragraph.start; i$2 <= paragraph.end; i$2++) {
|
|
2570
|
+
var charType = charTypes[i$2];
|
|
2571
|
+
stackTop = statusStack[statusStack.length - 1];
|
|
2572
|
+
|
|
2573
|
+
// Set initial counts
|
|
2574
|
+
charTypeCounts.set(charType, (charTypeCounts.get(charType) || 0) + 1);
|
|
2575
|
+
if (charType & NEUTRAL_ISOLATE_TYPES) {
|
|
2576
|
+
charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) || 0) + 1);
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
// Explicit Embeddings: 3.3.2 X2 - X3
|
|
2580
|
+
if (charType & FORMATTING_TYPES) { //prefilter all formatters
|
|
2581
|
+
if (charType & (TYPE_RLE | TYPE_LRE)) {
|
|
2582
|
+
embedLevels[i$2] = stackTop._level; // 5.2
|
|
2583
|
+
var level = (charType === TYPE_RLE ? nextOdd : nextEven)(stackTop._level);
|
|
2584
|
+
if (level <= MAX_DEPTH && !overflowIsolateCount && !overflowEmbeddingCount) {
|
|
2585
|
+
statusStack.push({
|
|
2586
|
+
_level: level,
|
|
2587
|
+
_override: 0,
|
|
2588
|
+
_isolate: 0
|
|
2589
|
+
});
|
|
2590
|
+
} else if (!overflowIsolateCount) {
|
|
2591
|
+
overflowEmbeddingCount++;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
// Explicit Overrides: 3.3.2 X4 - X5
|
|
2596
|
+
else if (charType & (TYPE_RLO | TYPE_LRO)) {
|
|
2597
|
+
embedLevels[i$2] = stackTop._level; // 5.2
|
|
2598
|
+
var level$1 = (charType === TYPE_RLO ? nextOdd : nextEven)(stackTop._level);
|
|
2599
|
+
if (level$1 <= MAX_DEPTH && !overflowIsolateCount && !overflowEmbeddingCount) {
|
|
2600
|
+
statusStack.push({
|
|
2601
|
+
_level: level$1,
|
|
2602
|
+
_override: (charType & TYPE_RLO) ? TYPE_R : TYPE_L,
|
|
2603
|
+
_isolate: 0
|
|
2604
|
+
});
|
|
2605
|
+
} else if (!overflowIsolateCount) {
|
|
2606
|
+
overflowEmbeddingCount++;
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
// Isolates: 3.3.2 X5a - X5c
|
|
2611
|
+
else if (charType & ISOLATE_INIT_TYPES) {
|
|
2612
|
+
// X5c - FSI becomes either RLI or LRI
|
|
2613
|
+
if (charType & TYPE_FSI) {
|
|
2614
|
+
charType = determineAutoEmbedLevel(i$2 + 1, true) === 1 ? TYPE_RLI : TYPE_LRI;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
embedLevels[i$2] = stackTop._level;
|
|
2618
|
+
if (stackTop._override) {
|
|
2619
|
+
changeCharType(i$2, stackTop._override);
|
|
2620
|
+
}
|
|
2621
|
+
var level$2 = (charType === TYPE_RLI ? nextOdd : nextEven)(stackTop._level);
|
|
2622
|
+
if (level$2 <= MAX_DEPTH && overflowIsolateCount === 0 && overflowEmbeddingCount === 0) {
|
|
2623
|
+
validIsolateCount++;
|
|
2624
|
+
statusStack.push({
|
|
2625
|
+
_level: level$2,
|
|
2626
|
+
_override: 0,
|
|
2627
|
+
_isolate: 1,
|
|
2628
|
+
_isolInitIndex: i$2
|
|
2629
|
+
});
|
|
2630
|
+
} else {
|
|
2631
|
+
overflowIsolateCount++;
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
// Terminating Isolates: 3.3.2 X6a
|
|
2636
|
+
else if (charType & TYPE_PDI) {
|
|
2637
|
+
if (overflowIsolateCount > 0) {
|
|
2638
|
+
overflowIsolateCount--;
|
|
2639
|
+
} else if (validIsolateCount > 0) {
|
|
2640
|
+
overflowEmbeddingCount = 0;
|
|
2641
|
+
while (!statusStack[statusStack.length - 1]._isolate) {
|
|
2642
|
+
statusStack.pop();
|
|
2643
|
+
}
|
|
2644
|
+
// Add to isolation pairs bidirectional mapping:
|
|
2645
|
+
var isolInitIndex = statusStack[statusStack.length - 1]._isolInitIndex;
|
|
2646
|
+
if (isolInitIndex != null) {
|
|
2647
|
+
isolationPairs.set(isolInitIndex, i$2);
|
|
2648
|
+
isolationPairs.set(i$2, isolInitIndex);
|
|
2649
|
+
}
|
|
2650
|
+
statusStack.pop();
|
|
2651
|
+
validIsolateCount--;
|
|
2652
|
+
}
|
|
2653
|
+
stackTop = statusStack[statusStack.length - 1];
|
|
2654
|
+
embedLevels[i$2] = stackTop._level;
|
|
2655
|
+
if (stackTop._override) {
|
|
2656
|
+
changeCharType(i$2, stackTop._override);
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
|
|
2661
|
+
// Terminating Embeddings and Overrides: 3.3.2 X7
|
|
2662
|
+
else if (charType & TYPE_PDF) {
|
|
2663
|
+
if (overflowIsolateCount === 0) {
|
|
2664
|
+
if (overflowEmbeddingCount > 0) {
|
|
2665
|
+
overflowEmbeddingCount--;
|
|
2666
|
+
} else if (!stackTop._isolate && statusStack.length > 1) {
|
|
2667
|
+
statusStack.pop();
|
|
2668
|
+
stackTop = statusStack[statusStack.length - 1];
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
embedLevels[i$2] = stackTop._level; // 5.2
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
// End of Paragraph: 3.3.2 X8
|
|
2675
|
+
else if (charType & TYPE_B) {
|
|
2676
|
+
embedLevels[i$2] = paragraph.level;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
// Non-formatting characters: 3.3.2 X6
|
|
2681
|
+
else {
|
|
2682
|
+
embedLevels[i$2] = stackTop._level;
|
|
2683
|
+
// NOTE: This exclusion of BN seems to go against what section 5.2 says, but is required for test passage
|
|
2684
|
+
if (stackTop._override && charType !== TYPE_BN) {
|
|
2685
|
+
changeCharType(i$2, stackTop._override);
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
// === 3.3.3 Preparations for Implicit Processing ===
|
|
2691
|
+
|
|
2692
|
+
// Remove all RLE, LRE, RLO, LRO, PDF, and BN characters: 3.3.3 X9
|
|
2693
|
+
// Note: Due to section 5.2, we won't remove them, but we'll use the BN_LIKE_TYPES bitset to
|
|
2694
|
+
// easily ignore them all from here on out.
|
|
2695
|
+
|
|
2696
|
+
// 3.3.3 X10
|
|
2697
|
+
// Compute the set of isolating run sequences as specified by BD13
|
|
2698
|
+
var levelRuns = [];
|
|
2699
|
+
var currentRun = null;
|
|
2700
|
+
for (var i$3 = paragraph.start; i$3 <= paragraph.end; i$3++) {
|
|
2701
|
+
var charType$1 = charTypes[i$3];
|
|
2702
|
+
if (!(charType$1 & BN_LIKE_TYPES)) {
|
|
2703
|
+
var lvl = embedLevels[i$3];
|
|
2704
|
+
var isIsolInit = charType$1 & ISOLATE_INIT_TYPES;
|
|
2705
|
+
var isPDI = charType$1 === TYPE_PDI;
|
|
2706
|
+
if (currentRun && lvl === currentRun._level) {
|
|
2707
|
+
currentRun._end = i$3;
|
|
2708
|
+
currentRun._endsWithIsolInit = isIsolInit;
|
|
2709
|
+
} else {
|
|
2710
|
+
levelRuns.push(currentRun = {
|
|
2711
|
+
_start: i$3,
|
|
2712
|
+
_end: i$3,
|
|
2713
|
+
_level: lvl,
|
|
2714
|
+
_startsWithPDI: isPDI,
|
|
2715
|
+
_endsWithIsolInit: isIsolInit
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
var isolatingRunSeqs = []; // [{seqIndices: [], sosType: L|R, eosType: L|R}]
|
|
2721
|
+
for (var runIdx = 0; runIdx < levelRuns.length; runIdx++) {
|
|
2722
|
+
var run = levelRuns[runIdx];
|
|
2723
|
+
if (!run._startsWithPDI || (run._startsWithPDI && !isolationPairs.has(run._start))) {
|
|
2724
|
+
var seqRuns = [currentRun = run];
|
|
2725
|
+
for (var pdiIndex = (void 0); currentRun && currentRun._endsWithIsolInit && (pdiIndex = isolationPairs.get(currentRun._end)) != null;) {
|
|
2726
|
+
for (var i$4 = runIdx + 1; i$4 < levelRuns.length; i$4++) {
|
|
2727
|
+
if (levelRuns[i$4]._start === pdiIndex) {
|
|
2728
|
+
seqRuns.push(currentRun = levelRuns[i$4]);
|
|
2729
|
+
break
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
// build flat list of indices across all runs:
|
|
2734
|
+
var seqIndices = [];
|
|
2735
|
+
for (var i$5 = 0; i$5 < seqRuns.length; i$5++) {
|
|
2736
|
+
var run$1 = seqRuns[i$5];
|
|
2737
|
+
for (var j = run$1._start; j <= run$1._end; j++) {
|
|
2738
|
+
seqIndices.push(j);
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
// determine the sos/eos types:
|
|
2742
|
+
var firstLevel = embedLevels[seqIndices[0]];
|
|
2743
|
+
var prevLevel = paragraph.level;
|
|
2744
|
+
for (var i$6 = seqIndices[0] - 1; i$6 >= 0; i$6--) {
|
|
2745
|
+
if (!(charTypes[i$6] & BN_LIKE_TYPES)) { //5.2
|
|
2746
|
+
prevLevel = embedLevels[i$6];
|
|
2747
|
+
break
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
var lastIndex = seqIndices[seqIndices.length - 1];
|
|
2751
|
+
var lastLevel = embedLevels[lastIndex];
|
|
2752
|
+
var nextLevel = paragraph.level;
|
|
2753
|
+
if (!(charTypes[lastIndex] & ISOLATE_INIT_TYPES)) {
|
|
2754
|
+
for (var i$7 = lastIndex + 1; i$7 <= paragraph.end; i$7++) {
|
|
2755
|
+
if (!(charTypes[i$7] & BN_LIKE_TYPES)) { //5.2
|
|
2756
|
+
nextLevel = embedLevels[i$7];
|
|
2757
|
+
break
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
isolatingRunSeqs.push({
|
|
2762
|
+
_seqIndices: seqIndices,
|
|
2763
|
+
_sosType: Math.max(prevLevel, firstLevel) % 2 ? TYPE_R : TYPE_L,
|
|
2764
|
+
_eosType: Math.max(nextLevel, lastLevel) % 2 ? TYPE_R : TYPE_L
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
// The next steps are done per isolating run sequence
|
|
2770
|
+
for (var seqIdx = 0; seqIdx < isolatingRunSeqs.length; seqIdx++) {
|
|
2771
|
+
var ref = isolatingRunSeqs[seqIdx];
|
|
2772
|
+
var seqIndices$1 = ref._seqIndices;
|
|
2773
|
+
var sosType = ref._sosType;
|
|
2774
|
+
var eosType = ref._eosType;
|
|
2775
|
+
/**
|
|
2776
|
+
* All the level runs in an isolating run sequence have the same embedding level.
|
|
2777
|
+
*
|
|
2778
|
+
* DO NOT change any `embedLevels[i]` within the current scope.
|
|
2779
|
+
*/
|
|
2780
|
+
var embedDirection = ((embedLevels[seqIndices$1[0]]) & 1) ? TYPE_R : TYPE_L;
|
|
2781
|
+
|
|
2782
|
+
// === 3.3.4 Resolving Weak Types ===
|
|
2783
|
+
|
|
2784
|
+
// W1 + 5.2. Search backward from each NSM to the first character in the isolating run sequence whose
|
|
2785
|
+
// bidirectional type is not BN, and set the NSM to ON if it is an isolate initiator or PDI, and to its
|
|
2786
|
+
// type otherwise. If the NSM is the first non-BN character, change the NSM to the type of sos.
|
|
2787
|
+
if (charTypeCounts.get(TYPE_NSM)) {
|
|
2788
|
+
for (var si = 0; si < seqIndices$1.length; si++) {
|
|
2789
|
+
var i$8 = seqIndices$1[si];
|
|
2790
|
+
if (charTypes[i$8] & TYPE_NSM) {
|
|
2791
|
+
var prevType = sosType;
|
|
2792
|
+
for (var sj = si - 1; sj >= 0; sj--) {
|
|
2793
|
+
if (!(charTypes[seqIndices$1[sj]] & BN_LIKE_TYPES)) { //5.2 scan back to first non-BN
|
|
2794
|
+
prevType = charTypes[seqIndices$1[sj]];
|
|
2795
|
+
break
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
changeCharType(i$8, (prevType & (ISOLATE_INIT_TYPES | TYPE_PDI)) ? TYPE_ON : prevType);
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
// W2. Search backward from each instance of a European number until the first strong type (R, L, AL, or sos)
|
|
2804
|
+
// is found. If an AL is found, change the type of the European number to Arabic number.
|
|
2805
|
+
if (charTypeCounts.get(TYPE_EN)) {
|
|
2806
|
+
for (var si$1 = 0; si$1 < seqIndices$1.length; si$1++) {
|
|
2807
|
+
var i$9 = seqIndices$1[si$1];
|
|
2808
|
+
if (charTypes[i$9] & TYPE_EN) {
|
|
2809
|
+
for (var sj$1 = si$1 - 1; sj$1 >= -1; sj$1--) {
|
|
2810
|
+
var prevCharType = sj$1 === -1 ? sosType : charTypes[seqIndices$1[sj$1]];
|
|
2811
|
+
if (prevCharType & STRONG_TYPES) {
|
|
2812
|
+
if (prevCharType === TYPE_AL) {
|
|
2813
|
+
changeCharType(i$9, TYPE_AN);
|
|
2814
|
+
}
|
|
2815
|
+
break
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2822
|
+
// W3. Change all ALs to R
|
|
2823
|
+
if (charTypeCounts.get(TYPE_AL)) {
|
|
2824
|
+
for (var si$2 = 0; si$2 < seqIndices$1.length; si$2++) {
|
|
2825
|
+
var i$10 = seqIndices$1[si$2];
|
|
2826
|
+
if (charTypes[i$10] & TYPE_AL) {
|
|
2827
|
+
changeCharType(i$10, TYPE_R);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
// W4. A single European separator between two European numbers changes to a European number. A single common
|
|
2833
|
+
// separator between two numbers of the same type changes to that type.
|
|
2834
|
+
if (charTypeCounts.get(TYPE_ES) || charTypeCounts.get(TYPE_CS)) {
|
|
2835
|
+
for (var si$3 = 1; si$3 < seqIndices$1.length - 1; si$3++) {
|
|
2836
|
+
var i$11 = seqIndices$1[si$3];
|
|
2837
|
+
if (charTypes[i$11] & (TYPE_ES | TYPE_CS)) {
|
|
2838
|
+
var prevType$1 = 0, nextType = 0;
|
|
2839
|
+
for (var sj$2 = si$3 - 1; sj$2 >= 0; sj$2--) {
|
|
2840
|
+
prevType$1 = charTypes[seqIndices$1[sj$2]];
|
|
2841
|
+
if (!(prevType$1 & BN_LIKE_TYPES)) { //5.2
|
|
2842
|
+
break
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
for (var sj$3 = si$3 + 1; sj$3 < seqIndices$1.length; sj$3++) {
|
|
2846
|
+
nextType = charTypes[seqIndices$1[sj$3]];
|
|
2847
|
+
if (!(nextType & BN_LIKE_TYPES)) { //5.2
|
|
2848
|
+
break
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
if (prevType$1 === nextType && (charTypes[i$11] === TYPE_ES ? prevType$1 === TYPE_EN : (prevType$1 & (TYPE_EN | TYPE_AN)))) {
|
|
2852
|
+
changeCharType(i$11, prevType$1);
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
// W5. A sequence of European terminators adjacent to European numbers changes to all European numbers.
|
|
2859
|
+
if (charTypeCounts.get(TYPE_EN)) {
|
|
2860
|
+
for (var si$4 = 0; si$4 < seqIndices$1.length; si$4++) {
|
|
2861
|
+
var i$12 = seqIndices$1[si$4];
|
|
2862
|
+
if (charTypes[i$12] & TYPE_EN) {
|
|
2863
|
+
for (var sj$4 = si$4 - 1; sj$4 >= 0 && (charTypes[seqIndices$1[sj$4]] & (TYPE_ET | BN_LIKE_TYPES)); sj$4--) {
|
|
2864
|
+
changeCharType(seqIndices$1[sj$4], TYPE_EN);
|
|
2865
|
+
}
|
|
2866
|
+
for (si$4++; si$4 < seqIndices$1.length && (charTypes[seqIndices$1[si$4]] & (TYPE_ET | BN_LIKE_TYPES | TYPE_EN)); si$4++) {
|
|
2867
|
+
if (charTypes[seqIndices$1[si$4]] !== TYPE_EN) {
|
|
2868
|
+
changeCharType(seqIndices$1[si$4], TYPE_EN);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
// W6. Otherwise, separators and terminators change to Other Neutral.
|
|
2876
|
+
if (charTypeCounts.get(TYPE_ET) || charTypeCounts.get(TYPE_ES) || charTypeCounts.get(TYPE_CS)) {
|
|
2877
|
+
for (var si$5 = 0; si$5 < seqIndices$1.length; si$5++) {
|
|
2878
|
+
var i$13 = seqIndices$1[si$5];
|
|
2879
|
+
if (charTypes[i$13] & (TYPE_ET | TYPE_ES | TYPE_CS)) {
|
|
2880
|
+
changeCharType(i$13, TYPE_ON);
|
|
2881
|
+
// 5.2 transform adjacent BNs too:
|
|
2882
|
+
for (var sj$5 = si$5 - 1; sj$5 >= 0 && (charTypes[seqIndices$1[sj$5]] & BN_LIKE_TYPES); sj$5--) {
|
|
2883
|
+
changeCharType(seqIndices$1[sj$5], TYPE_ON);
|
|
2884
|
+
}
|
|
2885
|
+
for (var sj$6 = si$5 + 1; sj$6 < seqIndices$1.length && (charTypes[seqIndices$1[sj$6]] & BN_LIKE_TYPES); sj$6++) {
|
|
2886
|
+
changeCharType(seqIndices$1[sj$6], TYPE_ON);
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
// W7. Search backward from each instance of a European number until the first strong type (R, L, or sos)
|
|
2893
|
+
// is found. If an L is found, then change the type of the European number to L.
|
|
2894
|
+
// NOTE: implemented in single forward pass for efficiency
|
|
2895
|
+
if (charTypeCounts.get(TYPE_EN)) {
|
|
2896
|
+
for (var si$6 = 0, prevStrongType = sosType; si$6 < seqIndices$1.length; si$6++) {
|
|
2897
|
+
var i$14 = seqIndices$1[si$6];
|
|
2898
|
+
var type = charTypes[i$14];
|
|
2899
|
+
if (type & TYPE_EN) {
|
|
2900
|
+
if (prevStrongType === TYPE_L) {
|
|
2901
|
+
changeCharType(i$14, TYPE_L);
|
|
2902
|
+
}
|
|
2903
|
+
} else if (type & STRONG_TYPES) {
|
|
2904
|
+
prevStrongType = type;
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
// === 3.3.5 Resolving Neutral and Isolate Formatting Types ===
|
|
2910
|
+
|
|
2911
|
+
if (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES)) {
|
|
2912
|
+
// N0. Process bracket pairs in an isolating run sequence sequentially in the logical order of the text
|
|
2913
|
+
// positions of the opening paired brackets using the logic given below. Within this scope, bidirectional
|
|
2914
|
+
// types EN and AN are treated as R.
|
|
2915
|
+
var R_TYPES_FOR_N_STEPS = (TYPE_R | TYPE_EN | TYPE_AN);
|
|
2916
|
+
var STRONG_TYPES_FOR_N_STEPS = R_TYPES_FOR_N_STEPS | TYPE_L;
|
|
2917
|
+
|
|
2918
|
+
// * Identify the bracket pairs in the current isolating run sequence according to BD16.
|
|
2919
|
+
var bracketPairs = [];
|
|
2920
|
+
{
|
|
2921
|
+
var openerStack = [];
|
|
2922
|
+
for (var si$7 = 0; si$7 < seqIndices$1.length; si$7++) {
|
|
2923
|
+
// NOTE: for any potential bracket character we also test that it still carries a NI
|
|
2924
|
+
// type, as that may have been changed earlier. This doesn't seem to be explicitly
|
|
2925
|
+
// called out in the spec, but is required for passage of certain tests.
|
|
2926
|
+
if (charTypes[seqIndices$1[si$7]] & NEUTRAL_ISOLATE_TYPES) {
|
|
2927
|
+
var char = string[seqIndices$1[si$7]];
|
|
2928
|
+
var oppositeBracket = (void 0);
|
|
2929
|
+
// Opening bracket
|
|
2930
|
+
if (openingToClosingBracket(char) !== null) {
|
|
2931
|
+
if (openerStack.length < 63) {
|
|
2932
|
+
openerStack.push({ char: char, seqIndex: si$7 });
|
|
2933
|
+
} else {
|
|
2934
|
+
break
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
// Closing bracket
|
|
2938
|
+
else if ((oppositeBracket = closingToOpeningBracket(char)) !== null) {
|
|
2939
|
+
for (var stackIdx = openerStack.length - 1; stackIdx >= 0; stackIdx--) {
|
|
2940
|
+
var stackChar = openerStack[stackIdx].char;
|
|
2941
|
+
if (stackChar === oppositeBracket ||
|
|
2942
|
+
stackChar === closingToOpeningBracket(getCanonicalBracket(char)) ||
|
|
2943
|
+
openingToClosingBracket(getCanonicalBracket(stackChar)) === char
|
|
2944
|
+
) {
|
|
2945
|
+
bracketPairs.push([openerStack[stackIdx].seqIndex, si$7]);
|
|
2946
|
+
openerStack.length = stackIdx; //pop the matching bracket and all following
|
|
2947
|
+
break
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
bracketPairs.sort(function (a, b) { return a[0] - b[0]; });
|
|
2954
|
+
}
|
|
2955
|
+
// * For each bracket-pair element in the list of pairs of text positions
|
|
2956
|
+
for (var pairIdx = 0; pairIdx < bracketPairs.length; pairIdx++) {
|
|
2957
|
+
var ref$1 = bracketPairs[pairIdx];
|
|
2958
|
+
var openSeqIdx = ref$1[0];
|
|
2959
|
+
var closeSeqIdx = ref$1[1];
|
|
2960
|
+
// a. Inspect the bidirectional types of the characters enclosed within the bracket pair.
|
|
2961
|
+
// b. If any strong type (either L or R) matching the embedding direction is found, set the type for both
|
|
2962
|
+
// brackets in the pair to match the embedding direction.
|
|
2963
|
+
var foundStrongType = false;
|
|
2964
|
+
var useStrongType = 0;
|
|
2965
|
+
for (var si$8 = openSeqIdx + 1; si$8 < closeSeqIdx; si$8++) {
|
|
2966
|
+
var i$15 = seqIndices$1[si$8];
|
|
2967
|
+
if (charTypes[i$15] & STRONG_TYPES_FOR_N_STEPS) {
|
|
2968
|
+
foundStrongType = true;
|
|
2969
|
+
var lr = (charTypes[i$15] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L;
|
|
2970
|
+
if (lr === embedDirection) {
|
|
2971
|
+
useStrongType = lr;
|
|
2972
|
+
break
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
// c. Otherwise, if there is a strong type it must be opposite the embedding direction. Therefore, test
|
|
2977
|
+
// for an established context with a preceding strong type by checking backwards before the opening paired
|
|
2978
|
+
// bracket until the first strong type (L, R, or sos) is found.
|
|
2979
|
+
// 1. If the preceding strong type is also opposite the embedding direction, context is established, so
|
|
2980
|
+
// set the type for both brackets in the pair to that direction.
|
|
2981
|
+
// 2. Otherwise set the type for both brackets in the pair to the embedding direction.
|
|
2982
|
+
if (foundStrongType && !useStrongType) {
|
|
2983
|
+
useStrongType = sosType;
|
|
2984
|
+
for (var si$9 = openSeqIdx - 1; si$9 >= 0; si$9--) {
|
|
2985
|
+
var i$16 = seqIndices$1[si$9];
|
|
2986
|
+
if (charTypes[i$16] & STRONG_TYPES_FOR_N_STEPS) {
|
|
2987
|
+
var lr$1 = (charTypes[i$16] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L;
|
|
2988
|
+
if (lr$1 !== embedDirection) {
|
|
2989
|
+
useStrongType = lr$1;
|
|
2990
|
+
} else {
|
|
2991
|
+
useStrongType = embedDirection;
|
|
2992
|
+
}
|
|
2993
|
+
break
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
if (useStrongType) {
|
|
2998
|
+
charTypes[seqIndices$1[openSeqIdx]] = charTypes[seqIndices$1[closeSeqIdx]] = useStrongType;
|
|
2999
|
+
// * Any number of characters that had original bidirectional character type NSM prior to the application
|
|
3000
|
+
// of W1 that immediately follow a paired bracket which changed to L or R under N0 should change to match
|
|
3001
|
+
// the type of their preceding bracket.
|
|
3002
|
+
if (useStrongType !== embedDirection) {
|
|
3003
|
+
for (var si$10 = openSeqIdx + 1; si$10 < seqIndices$1.length; si$10++) {
|
|
3004
|
+
if (!(charTypes[seqIndices$1[si$10]] & BN_LIKE_TYPES)) {
|
|
3005
|
+
if (getBidiCharType(string[seqIndices$1[si$10]]) & TYPE_NSM) {
|
|
3006
|
+
charTypes[seqIndices$1[si$10]] = useStrongType;
|
|
3007
|
+
}
|
|
3008
|
+
break
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
if (useStrongType !== embedDirection) {
|
|
3013
|
+
for (var si$11 = closeSeqIdx + 1; si$11 < seqIndices$1.length; si$11++) {
|
|
3014
|
+
if (!(charTypes[seqIndices$1[si$11]] & BN_LIKE_TYPES)) {
|
|
3015
|
+
if (getBidiCharType(string[seqIndices$1[si$11]]) & TYPE_NSM) {
|
|
3016
|
+
charTypes[seqIndices$1[si$11]] = useStrongType;
|
|
3017
|
+
}
|
|
3018
|
+
break
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
// N1. A sequence of NIs takes the direction of the surrounding strong text if the text on both sides has the
|
|
3026
|
+
// same direction.
|
|
3027
|
+
// N2. Any remaining NIs take the embedding direction.
|
|
3028
|
+
for (var si$12 = 0; si$12 < seqIndices$1.length; si$12++) {
|
|
3029
|
+
if (charTypes[seqIndices$1[si$12]] & NEUTRAL_ISOLATE_TYPES) {
|
|
3030
|
+
var niRunStart = si$12, niRunEnd = si$12;
|
|
3031
|
+
var prevType$2 = sosType; //si === 0 ? sosType : (charTypes[seqIndices[si - 1]] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L
|
|
3032
|
+
for (var si2 = si$12 - 1; si2 >= 0; si2--) {
|
|
3033
|
+
if (charTypes[seqIndices$1[si2]] & BN_LIKE_TYPES) {
|
|
3034
|
+
niRunStart = si2; //5.2 treat BNs adjacent to NIs as NIs
|
|
3035
|
+
} else {
|
|
3036
|
+
prevType$2 = (charTypes[seqIndices$1[si2]] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L;
|
|
3037
|
+
break
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
var nextType$1 = eosType;
|
|
3041
|
+
for (var si2$1 = si$12 + 1; si2$1 < seqIndices$1.length; si2$1++) {
|
|
3042
|
+
if (charTypes[seqIndices$1[si2$1]] & (NEUTRAL_ISOLATE_TYPES | BN_LIKE_TYPES)) {
|
|
3043
|
+
niRunEnd = si2$1;
|
|
3044
|
+
} else {
|
|
3045
|
+
nextType$1 = (charTypes[seqIndices$1[si2$1]] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L;
|
|
3046
|
+
break
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
for (var sj$7 = niRunStart; sj$7 <= niRunEnd; sj$7++) {
|
|
3050
|
+
charTypes[seqIndices$1[sj$7]] = prevType$2 === nextType$1 ? prevType$2 : embedDirection;
|
|
3051
|
+
}
|
|
3052
|
+
si$12 = niRunEnd;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
|
|
3058
|
+
// === 3.3.6 Resolving Implicit Levels ===
|
|
3059
|
+
|
|
3060
|
+
for (var i$17 = paragraph.start; i$17 <= paragraph.end; i$17++) {
|
|
3061
|
+
var level$3 = embedLevels[i$17];
|
|
3062
|
+
var type$1 = charTypes[i$17];
|
|
3063
|
+
// I2. For all characters with an odd (right-to-left) embedding level, those of type L, EN or AN go up one level.
|
|
3064
|
+
if (level$3 & 1) {
|
|
3065
|
+
if (type$1 & (TYPE_L | TYPE_EN | TYPE_AN)) {
|
|
3066
|
+
embedLevels[i$17]++;
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
// I1. For all characters with an even (left-to-right) embedding level, those of type R go up one level
|
|
3070
|
+
// and those of type AN or EN go up two levels.
|
|
3071
|
+
else {
|
|
3072
|
+
if (type$1 & TYPE_R) {
|
|
3073
|
+
embedLevels[i$17]++;
|
|
3074
|
+
} else if (type$1 & (TYPE_AN | TYPE_EN)) {
|
|
3075
|
+
embedLevels[i$17] += 2;
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
// 5.2: Resolve any LRE, RLE, LRO, RLO, PDF, or BN to the level of the preceding character if there is one,
|
|
3080
|
+
// and otherwise to the base level.
|
|
3081
|
+
if (type$1 & BN_LIKE_TYPES) {
|
|
3082
|
+
embedLevels[i$17] = i$17 === 0 ? paragraph.level : embedLevels[i$17 - 1];
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3085
|
+
// 3.4 L1.1-4: Reset the embedding level of segment/paragraph separators, and any sequence of whitespace or
|
|
3086
|
+
// isolate formatting characters preceding them or the end of the paragraph, to the paragraph level.
|
|
3087
|
+
// NOTE: this will also need to be applied to each individual line ending after line wrapping occurs.
|
|
3088
|
+
if (i$17 === paragraph.end || getBidiCharType(string[i$17]) & (TYPE_S | TYPE_B)) {
|
|
3089
|
+
for (var j$1 = i$17; j$1 >= 0 && (getBidiCharType(string[j$1]) & TRAILING_TYPES); j$1--) {
|
|
3090
|
+
embedLevels[j$1] = paragraph.level;
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
// DONE! The resolved levels can then be used, after line wrapping, to flip runs of characters
|
|
3097
|
+
// according to section 3.4 Reordering Resolved Levels
|
|
3098
|
+
return {
|
|
3099
|
+
levels: embedLevels,
|
|
3100
|
+
paragraphs: paragraphs
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
function determineAutoEmbedLevel (start, isFSI) {
|
|
3104
|
+
// 3.3.1 P2 - P3
|
|
3105
|
+
for (var i = start; i < string.length; i++) {
|
|
3106
|
+
var charType = charTypes[i];
|
|
3107
|
+
if (charType & (TYPE_R | TYPE_AL)) {
|
|
3108
|
+
return 1
|
|
3109
|
+
}
|
|
3110
|
+
if ((charType & (TYPE_B | TYPE_L)) || (isFSI && charType === TYPE_PDI)) {
|
|
3111
|
+
return 0
|
|
3112
|
+
}
|
|
3113
|
+
if (charType & ISOLATE_INIT_TYPES) {
|
|
3114
|
+
var pdi = indexOfMatchingPDI(i);
|
|
3115
|
+
i = pdi === -1 ? string.length : pdi;
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
return 0
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
function indexOfMatchingPDI (isolateStart) {
|
|
3122
|
+
// 3.1.2 BD9
|
|
3123
|
+
var isolationLevel = 1;
|
|
3124
|
+
for (var i = isolateStart + 1; i < string.length; i++) {
|
|
3125
|
+
var charType = charTypes[i];
|
|
3126
|
+
if (charType & TYPE_B) {
|
|
3127
|
+
break
|
|
3128
|
+
}
|
|
3129
|
+
if (charType & TYPE_PDI) {
|
|
3130
|
+
if (--isolationLevel === 0) {
|
|
3131
|
+
return i
|
|
3132
|
+
}
|
|
3133
|
+
} else if (charType & ISOLATE_INIT_TYPES) {
|
|
3134
|
+
isolationLevel++;
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
return -1
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
// Bidi mirrored chars data, auto generated
|
|
3142
|
+
var data = "14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1";
|
|
3143
|
+
|
|
3144
|
+
var mirrorMap;
|
|
3145
|
+
|
|
3146
|
+
function parse () {
|
|
3147
|
+
if (!mirrorMap) {
|
|
3148
|
+
//const start = performance.now()
|
|
3149
|
+
var ref = parseCharacterMap(data, true);
|
|
3150
|
+
var map = ref.map;
|
|
3151
|
+
var reverseMap = ref.reverseMap;
|
|
3152
|
+
// Combine both maps into one
|
|
3153
|
+
reverseMap.forEach(function (value, key) {
|
|
3154
|
+
map.set(key, value);
|
|
3155
|
+
});
|
|
3156
|
+
mirrorMap = map;
|
|
3157
|
+
//console.log(`mirrored chars parsed in ${performance.now() - start}ms`)
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
/**
|
|
3162
|
+
* Get the mirrored character for a given character, if one exists.
|
|
3163
|
+
* @param {string} char
|
|
3164
|
+
* @return {string|null}
|
|
3165
|
+
*/
|
|
3166
|
+
function getMirroredCharacter (char) {
|
|
3167
|
+
parse();
|
|
3168
|
+
return mirrorMap.get(char) || null
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/**
|
|
3172
|
+
* Given a string and its resolved embedding levels, build a map of indices to replacement chars
|
|
3173
|
+
* for any characters in right-to-left segments that have defined mirrored characters.
|
|
3174
|
+
* @param {string} string
|
|
3175
|
+
* @param {Uint8Array} embeddingLevels
|
|
3176
|
+
* @param {number?} [start]
|
|
3177
|
+
* @param {number?} [end]
|
|
3178
|
+
* @return {Map<number, string>}
|
|
3179
|
+
*/
|
|
3180
|
+
function getMirroredCharactersMap(string, embeddingLevels, start, end) {
|
|
3181
|
+
var strLen = string.length;
|
|
3182
|
+
start = Math.max(0, start == null ? 0 : +start);
|
|
3183
|
+
end = Math.min(strLen - 1, end == null ? strLen - 1 : +end);
|
|
3184
|
+
|
|
3185
|
+
var map = new Map();
|
|
3186
|
+
for (var i = start; i <= end; i++) {
|
|
3187
|
+
if (embeddingLevels[i] & 1) { //only odd (rtl) levels
|
|
3188
|
+
var mirror = getMirroredCharacter(string[i]);
|
|
3189
|
+
if (mirror !== null) {
|
|
3190
|
+
map.set(i, mirror);
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
return map
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
/**
|
|
3198
|
+
* Given a start and end denoting a single line within a string, and a set of precalculated
|
|
3199
|
+
* bidi embedding levels, produce a list of segments whose ordering should be flipped, in sequence.
|
|
3200
|
+
* @param {string} string - the full input string
|
|
3201
|
+
* @param {GetEmbeddingLevelsResult} embeddingLevelsResult - the result object from getEmbeddingLevels
|
|
3202
|
+
* @param {number} [start] - first character in a subset of the full string
|
|
3203
|
+
* @param {number} [end] - last character in a subset of the full string
|
|
3204
|
+
* @return {number[][]} - the list of start/end segments that should be flipped, in order.
|
|
3205
|
+
*/
|
|
3206
|
+
function getReorderSegments(string, embeddingLevelsResult, start, end) {
|
|
3207
|
+
var strLen = string.length;
|
|
3208
|
+
start = Math.max(0, start == null ? 0 : +start);
|
|
3209
|
+
end = Math.min(strLen - 1, end == null ? strLen - 1 : +end);
|
|
3210
|
+
|
|
3211
|
+
var segments = [];
|
|
3212
|
+
embeddingLevelsResult.paragraphs.forEach(function (paragraph) {
|
|
3213
|
+
var lineStart = Math.max(start, paragraph.start);
|
|
3214
|
+
var lineEnd = Math.min(end, paragraph.end);
|
|
3215
|
+
if (lineStart < lineEnd) {
|
|
3216
|
+
// Local slice for mutation
|
|
3217
|
+
var lineLevels = embeddingLevelsResult.levels.slice(lineStart, lineEnd + 1);
|
|
3218
|
+
|
|
3219
|
+
// 3.4 L1.4: Reset any sequence of whitespace characters and/or isolate formatting characters at the
|
|
3220
|
+
// end of the line to the paragraph level.
|
|
3221
|
+
for (var i = lineEnd; i >= lineStart && (getBidiCharType(string[i]) & TRAILING_TYPES); i--) {
|
|
3222
|
+
lineLevels[i] = paragraph.level;
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
// L2. From the highest level found in the text to the lowest odd level on each line, including intermediate levels
|
|
3226
|
+
// not actually present in the text, reverse any contiguous sequence of characters that are at that level or higher.
|
|
3227
|
+
var maxLevel = paragraph.level;
|
|
3228
|
+
var minOddLevel = Infinity;
|
|
3229
|
+
for (var i$1 = 0; i$1 < lineLevels.length; i$1++) {
|
|
3230
|
+
var level = lineLevels[i$1];
|
|
3231
|
+
if (level > maxLevel) { maxLevel = level; }
|
|
3232
|
+
if (level < minOddLevel) { minOddLevel = level | 1; }
|
|
3233
|
+
}
|
|
3234
|
+
for (var lvl = maxLevel; lvl >= minOddLevel; lvl--) {
|
|
3235
|
+
for (var i$2 = 0; i$2 < lineLevels.length; i$2++) {
|
|
3236
|
+
if (lineLevels[i$2] >= lvl) {
|
|
3237
|
+
var segStart = i$2;
|
|
3238
|
+
while (i$2 + 1 < lineLevels.length && lineLevels[i$2 + 1] >= lvl) {
|
|
3239
|
+
i$2++;
|
|
3240
|
+
}
|
|
3241
|
+
if (i$2 > segStart) {
|
|
3242
|
+
segments.push([segStart + lineStart, i$2 + lineStart]);
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
});
|
|
3249
|
+
return segments
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
/**
|
|
3253
|
+
* @param {string} string
|
|
3254
|
+
* @param {GetEmbeddingLevelsResult} embedLevelsResult
|
|
3255
|
+
* @param {number} [start]
|
|
3256
|
+
* @param {number} [end]
|
|
3257
|
+
* @return {string} the new string with bidi segments reordered
|
|
3258
|
+
*/
|
|
3259
|
+
function getReorderedString(string, embedLevelsResult, start, end) {
|
|
3260
|
+
var indices = getReorderedIndices(string, embedLevelsResult, start, end);
|
|
3261
|
+
var chars = [].concat( string );
|
|
3262
|
+
indices.forEach(function (charIndex, i) {
|
|
3263
|
+
chars[i] = (
|
|
3264
|
+
(embedLevelsResult.levels[charIndex] & 1) ? getMirroredCharacter(string[charIndex]) : null
|
|
3265
|
+
) || string[charIndex];
|
|
3266
|
+
});
|
|
3267
|
+
return chars.join('')
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3270
|
+
/**
|
|
3271
|
+
* @param {string} string
|
|
3272
|
+
* @param {GetEmbeddingLevelsResult} embedLevelsResult
|
|
3273
|
+
* @param {number} [start]
|
|
3274
|
+
* @param {number} [end]
|
|
3275
|
+
* @return {number[]} an array with character indices in their new bidi order
|
|
3276
|
+
*/
|
|
3277
|
+
function getReorderedIndices(string, embedLevelsResult, start, end) {
|
|
3278
|
+
var segments = getReorderSegments(string, embedLevelsResult, start, end);
|
|
3279
|
+
// Fill an array with indices
|
|
3280
|
+
var indices = [];
|
|
3281
|
+
for (var i = 0; i < string.length; i++) {
|
|
3282
|
+
indices[i] = i;
|
|
3283
|
+
}
|
|
3284
|
+
// Reverse each segment in order
|
|
3285
|
+
segments.forEach(function (ref) {
|
|
3286
|
+
var start = ref[0];
|
|
3287
|
+
var end = ref[1];
|
|
3288
|
+
|
|
3289
|
+
var slice = indices.slice(start, end + 1);
|
|
3290
|
+
for (var i = slice.length; i--;) {
|
|
3291
|
+
indices[end - i] = slice[i];
|
|
3292
|
+
}
|
|
3293
|
+
});
|
|
3294
|
+
return indices
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
exports.closingToOpeningBracket = closingToOpeningBracket;
|
|
3298
|
+
exports.getBidiCharType = getBidiCharType;
|
|
3299
|
+
exports.getBidiCharTypeName = getBidiCharTypeName;
|
|
3300
|
+
exports.getCanonicalBracket = getCanonicalBracket;
|
|
3301
|
+
exports.getEmbeddingLevels = getEmbeddingLevels;
|
|
3302
|
+
exports.getMirroredCharacter = getMirroredCharacter;
|
|
3303
|
+
exports.getMirroredCharactersMap = getMirroredCharactersMap;
|
|
3304
|
+
exports.getReorderSegments = getReorderSegments;
|
|
3305
|
+
exports.getReorderedIndices = getReorderedIndices;
|
|
3306
|
+
exports.getReorderedString = getReorderedString;
|
|
3307
|
+
exports.openingToClosingBracket = openingToClosingBracket;
|
|
3308
|
+
|
|
3309
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3310
|
+
|
|
3311
|
+
return exports;
|
|
3312
|
+
|
|
3313
|
+
})({});
|
|
3314
|
+
return bidi}
|
|
3315
|
+
|
|
3316
|
+
// bidi-js ships ES module declarations for a CommonJS package; its runtime
|
|
3317
|
+
// default export is the factory in both Node and the browser bundle.
|
|
3318
|
+
const bidiFactory = bidiFactory$1;
|
|
3319
|
+
// Keep the paragraph LTR, as in source code. Individual RTL runs still shape RTL.
|
|
3320
|
+
// Do not initialize the Unicode tables or segment ASCII lines.
|
|
3321
|
+
const state$g = {};
|
|
3322
|
+
const rtlCharacters = /[\u{590}-\u{8FF}\u{200F}\u{202A}-\u{202E}\u{2066}-\u{2069}\u{FB1D}-\u{FDFF}\u{FE70}-\u{FEFF}]|\p{Script=Adlam}/u;
|
|
3323
|
+
const isBidi = (line, enabled = false) => enabled && rtlCharacters.test(line);
|
|
3324
|
+
const getRuns = line => {
|
|
3325
|
+
const bidi = state$g.bidi ??= bidiFactory();
|
|
3326
|
+
const embedding = bidi.getEmbeddingLevels(line, 'ltr');
|
|
3327
|
+
const order = bidi.getReorderedIndices(line, embedding);
|
|
3328
|
+
const runs = [];
|
|
3329
|
+
let previousIndex = -2;
|
|
3330
|
+
for (const index of order) {
|
|
3331
|
+
const previous = runs.at(-1);
|
|
3332
|
+
const level = embedding.levels[index];
|
|
3333
|
+
if (previous && previous.level === level && Math.abs(index - previousIndex) === 1) {
|
|
3334
|
+
previous.start = Math.min(previous.start, index);
|
|
3335
|
+
previous.end = Math.max(previous.end, index + 1);
|
|
3336
|
+
} else {
|
|
3337
|
+
runs.push({
|
|
3338
|
+
end: index + 1,
|
|
3339
|
+
level,
|
|
3340
|
+
start: index
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
previousIndex = index;
|
|
3344
|
+
}
|
|
3345
|
+
return runs;
|
|
3346
|
+
};
|
|
3347
|
+
const getBoundaries = line => {
|
|
3348
|
+
const segmenter = new Intl.Segmenter(undefined, {
|
|
3349
|
+
granularity: 'grapheme'
|
|
3350
|
+
});
|
|
3351
|
+
return [...Array.from(segmenter.segment(line), ({
|
|
3352
|
+
index
|
|
3353
|
+
}) => index), line.length];
|
|
3354
|
+
};
|
|
3355
|
+
|
|
3356
|
+
// A basic editor has one caret per logical column. At an ambiguous boundary,
|
|
3357
|
+
// prefer the higher embedding level (the RTL side at ordinary LTR/RTL edges).
|
|
3358
|
+
const getCaretRun = (runs, column) => {
|
|
3359
|
+
let result = runs[0];
|
|
3360
|
+
for (const run of runs) {
|
|
3361
|
+
if (column >= run.start && column <= run.end && (column < result.start || column > result.end || run.level > result.level)) {
|
|
3362
|
+
result = run;
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
return result;
|
|
3366
|
+
};
|
|
3367
|
+
const getVisualColumns = line => {
|
|
3368
|
+
const boundaries = getBoundaries(line);
|
|
3369
|
+
if (!isBidi(line, true)) {
|
|
3370
|
+
return boundaries;
|
|
3371
|
+
}
|
|
3372
|
+
const runs = getRuns(line);
|
|
3373
|
+
const logicalRuns = runs.toSorted((left, right) => left.start - right.start);
|
|
3374
|
+
const columnsByRun = new Map(runs.map(run => [run, []]));
|
|
3375
|
+
let runIndex = 0;
|
|
3376
|
+
for (const column of boundaries) {
|
|
3377
|
+
while (runIndex + 1 < logicalRuns.length && column >= logicalRuns[runIndex + 1].start) {
|
|
3378
|
+
runIndex++;
|
|
3379
|
+
}
|
|
3380
|
+
const current = logicalRuns[runIndex];
|
|
3381
|
+
const previous = logicalRuns[runIndex - 1];
|
|
3382
|
+
const owner = previous && column === current.start && previous.level > current.level ? previous : current;
|
|
3383
|
+
columnsByRun.get(owner).push(column);
|
|
3384
|
+
}
|
|
3385
|
+
const columns = [];
|
|
3386
|
+
for (const run of runs) {
|
|
3387
|
+
const part = columnsByRun.get(run);
|
|
3388
|
+
const orderedColumns = run.level % 2 ? part.toReversed() : part;
|
|
3389
|
+
for (const column of orderedColumns) {
|
|
3390
|
+
columns.push(column);
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
return columns;
|
|
3394
|
+
};
|
|
3395
|
+
const getPosition = async (line, column, measure, runs = getRuns(line), selectedRun = getCaretRun(runs, column)) => {
|
|
3396
|
+
let x = 0;
|
|
3397
|
+
for (const run of runs) {
|
|
3398
|
+
const text = line.slice(run.start, run.end);
|
|
3399
|
+
const width = await measure(text);
|
|
3400
|
+
if (run === selectedRun) {
|
|
3401
|
+
const prefix = await measure(line.slice(run.start, column), {
|
|
3402
|
+
offset: column - run.start,
|
|
3403
|
+
rtl: run.level % 2 === 1,
|
|
3404
|
+
text
|
|
3405
|
+
});
|
|
3406
|
+
return x + (run.level % 2 ? width - prefix : prefix);
|
|
3407
|
+
}
|
|
3408
|
+
x += width;
|
|
3409
|
+
}
|
|
3410
|
+
return x;
|
|
3411
|
+
};
|
|
3412
|
+
const getColumn = async (line, x, measure) => {
|
|
3413
|
+
const columns = getVisualColumns(line);
|
|
3414
|
+
// Binary search the same canonical positions used by the caret, including
|
|
3415
|
+
// both line edges. This also keeps clicks out of combining sequences.
|
|
3416
|
+
const runs = getRuns(line);
|
|
3417
|
+
let low = 0;
|
|
3418
|
+
let high = columns.length - 1;
|
|
3419
|
+
while (low < high) {
|
|
3420
|
+
const middle = Math.floor((low + high) / 2);
|
|
3421
|
+
const left = await getPosition(line, columns[middle], measure, runs);
|
|
3422
|
+
const right = await getPosition(line, columns[middle + 1], measure, runs);
|
|
3423
|
+
if (x < (left + right) / 2) {
|
|
3424
|
+
high = middle;
|
|
3425
|
+
} else {
|
|
3426
|
+
low = middle + 1;
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
return columns[low];
|
|
3430
|
+
};
|
|
3431
|
+
const getSelectionRanges = async (line, start, end, measure) => {
|
|
3432
|
+
const runs = getRuns(line);
|
|
3433
|
+
const ranges = [];
|
|
3434
|
+
let x = 0;
|
|
3435
|
+
for (const run of runs) {
|
|
3436
|
+
const text = line.slice(run.start, run.end);
|
|
3437
|
+
const width = await measure(text);
|
|
3438
|
+
const from = Math.max(start, run.start);
|
|
3439
|
+
const to = Math.min(end, run.end);
|
|
3440
|
+
if (from < to) {
|
|
3441
|
+
const leftPrefix = await measure(line.slice(run.start, from), {
|
|
3442
|
+
offset: from - run.start,
|
|
3443
|
+
rtl: run.level % 2 === 1,
|
|
3444
|
+
text
|
|
3445
|
+
});
|
|
3446
|
+
const rightPrefix = await measure(line.slice(run.start, to), {
|
|
3447
|
+
offset: to - run.start,
|
|
3448
|
+
rtl: run.level % 2 === 1,
|
|
3449
|
+
text
|
|
3450
|
+
});
|
|
3451
|
+
const left = run.level % 2 ? width - leftPrefix : leftPrefix;
|
|
3452
|
+
const right = run.level % 2 ? width - rightPrefix : rightPrefix;
|
|
3453
|
+
ranges.push({
|
|
3454
|
+
width: Math.abs(right - left),
|
|
3455
|
+
x: x + Math.min(left, right)
|
|
3456
|
+
});
|
|
3457
|
+
}
|
|
3458
|
+
x += width;
|
|
3459
|
+
}
|
|
3460
|
+
return ranges;
|
|
3461
|
+
};
|
|
3462
|
+
|
|
2258
3463
|
const Link$1 = 'Link';
|
|
2259
3464
|
const EditorGoToDefinitionLink = 'EditorGoToDefinitionLink';
|
|
2260
3465
|
const Function = 'Function';
|
|
@@ -2736,7 +3941,7 @@ const getEnabled$1 = () => {
|
|
|
2736
3941
|
};
|
|
2737
3942
|
|
|
2738
3943
|
const invoke$c = (...args) => invoke$d(...args);
|
|
2739
|
-
const set$
|
|
3944
|
+
const set$9 = (...args) => set$c(...args);
|
|
2740
3945
|
|
|
2741
3946
|
const state$d = {
|
|
2742
3947
|
pending: Object.create(null),
|
|
@@ -2746,10 +3951,10 @@ const state$d = {
|
|
|
2746
3951
|
const has = languageId => {
|
|
2747
3952
|
return Object.hasOwn(state$d.tokenizers, languageId);
|
|
2748
3953
|
};
|
|
2749
|
-
const set$
|
|
3954
|
+
const set$8 = (languageId, tokenizer) => {
|
|
2750
3955
|
state$d.tokenizers[languageId] = tokenizer;
|
|
2751
3956
|
};
|
|
2752
|
-
const get$
|
|
3957
|
+
const get$7 = languageId => {
|
|
2753
3958
|
return state$d.tokenizers[languageId];
|
|
2754
3959
|
};
|
|
2755
3960
|
const setTokenizePath = (languageId, tokenizePath) => {
|
|
@@ -2770,10 +3975,10 @@ const isPending = languageId => {
|
|
|
2770
3975
|
};
|
|
2771
3976
|
|
|
2772
3977
|
const tokenMaps = Object.create(null);
|
|
2773
|
-
const set$
|
|
3978
|
+
const set$7 = (languageId, tokenMap) => {
|
|
2774
3979
|
tokenMaps[languageId] = tokenMap;
|
|
2775
3980
|
};
|
|
2776
|
-
const get$
|
|
3981
|
+
const get$6 = languageId => {
|
|
2777
3982
|
return tokenMaps[languageId] || {};
|
|
2778
3983
|
};
|
|
2779
3984
|
|
|
@@ -2786,7 +3991,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
2786
3991
|
if (getEnabled$1()) {
|
|
2787
3992
|
// @ts-ignore
|
|
2788
3993
|
const tokenMap = await invoke$c('Tokenizer.load', languageId, tokenizePath);
|
|
2789
|
-
set$
|
|
3994
|
+
set$7(languageId, tokenMap);
|
|
2790
3995
|
return;
|
|
2791
3996
|
}
|
|
2792
3997
|
try {
|
|
@@ -2802,8 +4007,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
2802
4007
|
console.warn(`tokenizer.TokenMap should be an object in "${tokenizePath}"`);
|
|
2803
4008
|
return;
|
|
2804
4009
|
}
|
|
2805
|
-
set$
|
|
2806
|
-
set$
|
|
4010
|
+
set$7(languageId, tokenizer.TokenMap);
|
|
4011
|
+
set$8(languageId, tokenizer);
|
|
2807
4012
|
} catch (error) {
|
|
2808
4013
|
// TODO better error handling
|
|
2809
4014
|
console.error(error);
|
|
@@ -2811,7 +4016,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
2811
4016
|
};
|
|
2812
4017
|
const getTokenizer = languageId => {
|
|
2813
4018
|
if (has(languageId)) {
|
|
2814
|
-
return get$
|
|
4019
|
+
return get$7(languageId);
|
|
2815
4020
|
}
|
|
2816
4021
|
if (isPending(languageId)) {
|
|
2817
4022
|
return TokenizePlainText;
|
|
@@ -2820,7 +4025,7 @@ const getTokenizer = languageId => {
|
|
|
2820
4025
|
};
|
|
2821
4026
|
|
|
2822
4027
|
const tokenizers = [TokenizePlainText];
|
|
2823
|
-
const get$
|
|
4028
|
+
const get$5 = id => {
|
|
2824
4029
|
return tokenizers[id] || TokenizePlainText;
|
|
2825
4030
|
};
|
|
2826
4031
|
const register = tokenizer => {
|
|
@@ -2910,7 +4115,7 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
|
|
|
2910
4115
|
lines,
|
|
2911
4116
|
tokenizerId
|
|
2912
4117
|
} = editor;
|
|
2913
|
-
const tokenizer = get$
|
|
4118
|
+
const tokenizer = get$5(tokenizerId);
|
|
2914
4119
|
const {
|
|
2915
4120
|
hasArrayReturn,
|
|
2916
4121
|
initialLineState,
|
|
@@ -3586,7 +4791,7 @@ const getLineInfosViewport = async (editor, tokens, embeddedResults, minLineY, m
|
|
|
3586
4791
|
languageId,
|
|
3587
4792
|
lines
|
|
3588
4793
|
} = editor;
|
|
3589
|
-
const tokenMap = get$
|
|
4794
|
+
const tokenMap = get$6(languageId);
|
|
3590
4795
|
let offset = minLineOffset;
|
|
3591
4796
|
const tabSize = editor.tabSize ?? 2;
|
|
3592
4797
|
const visibleLines = lines.slice(minLineY, maxLineY);
|
|
@@ -3597,7 +4802,7 @@ const getLineInfosViewport = async (editor, tokens, embeddedResults, minLineY, m
|
|
|
3597
4802
|
line,
|
|
3598
4803
|
segments: graphemeSegments?.[index],
|
|
3599
4804
|
tabSize,
|
|
3600
|
-
threshold: horizontalVirtualizationThreshold,
|
|
4805
|
+
threshold: isBidi(line, editor.rtl) ? Infinity : horizontalVirtualizationThreshold,
|
|
3601
4806
|
width
|
|
3602
4807
|
})), texts => measureTextWidths(texts, editor.fontWeight, editor.fontSize, editor.fontFamily, editor.letterSpacing, editor.isMonospaceFont, editor.charWidth));
|
|
3603
4808
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
@@ -3806,6 +5011,9 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
3806
5011
|
return emptyIncrementalEdits;
|
|
3807
5012
|
}
|
|
3808
5013
|
const newLine = lines[rowIndex];
|
|
5014
|
+
if (isBidi(oldLine, oldState.rtl) || isBidi(newLine, newState.rtl)) {
|
|
5015
|
+
return emptyIncrementalEdits;
|
|
5016
|
+
}
|
|
3809
5017
|
// Renderer edit offsets address full lines, so clipped rows need a fresh visible window.
|
|
3810
5018
|
const threshold = newState.horizontalVirtualizationThreshold ?? 500;
|
|
3811
5019
|
if (newState.deltaX !== 0 || oldLine.length > threshold || newLine.length > threshold) {
|
|
@@ -4123,7 +5331,7 @@ const notifyListeners = async (listenerType, method, ...params) => {
|
|
|
4123
5331
|
// Notify all listeners in parallel
|
|
4124
5332
|
const notifications = rpcIds.map(async rpcId => {
|
|
4125
5333
|
try {
|
|
4126
|
-
const rpc = get$
|
|
5334
|
+
const rpc = get$a(rpcId);
|
|
4127
5335
|
if (rpc) {
|
|
4128
5336
|
await rpc.invoke(method, ...params);
|
|
4129
5337
|
}
|
|
@@ -4339,7 +5547,7 @@ const transformDiagnostics = (diagnostics, changes) => {
|
|
|
4339
5547
|
|
|
4340
5548
|
const queues$1 = {};
|
|
4341
5549
|
const enqueue = async (uid, callback) => {
|
|
4342
|
-
const instance = get$
|
|
5550
|
+
const instance = get$9(uid);
|
|
4343
5551
|
if (!instance) {
|
|
4344
5552
|
return undefined;
|
|
4345
5553
|
}
|
|
@@ -4424,7 +5632,53 @@ const getTabCount = string => {
|
|
|
4424
5632
|
return count;
|
|
4425
5633
|
};
|
|
4426
5634
|
|
|
4427
|
-
const
|
|
5635
|
+
const state$9 = {
|
|
5636
|
+
rpc: undefined
|
|
5637
|
+
};
|
|
5638
|
+
const isConnected = () => {
|
|
5639
|
+
const {
|
|
5640
|
+
rpc
|
|
5641
|
+
} = state$9;
|
|
5642
|
+
return rpc !== undefined;
|
|
5643
|
+
};
|
|
5644
|
+
const set$6 = value => {
|
|
5645
|
+
state$9.rpc = value;
|
|
5646
|
+
};
|
|
5647
|
+
const invoke$8 = (method, ...params) => {
|
|
5648
|
+
const {
|
|
5649
|
+
rpc
|
|
5650
|
+
} = state$9;
|
|
5651
|
+
if (!rpc) {
|
|
5652
|
+
throw new Error('Editor renderer process is not connected');
|
|
5653
|
+
}
|
|
5654
|
+
return rpc.invoke(method, ...params);
|
|
5655
|
+
};
|
|
5656
|
+
|
|
5657
|
+
const joiningScript = /\p{Script=Arabic}/u;
|
|
5658
|
+
const createMeasure = (fontWeight, fontSize, fontFamily, letterSpacing, tabSize, charWidth) => {
|
|
5659
|
+
// Owned by this geometry operation, so edits/font changes cannot reuse stale
|
|
5660
|
+
// shaping information and closing editors leaves no persistent text cache.
|
|
5661
|
+
const cache = new Map();
|
|
5662
|
+
const normalize = text => text.replaceAll('\t', () => ' '.repeat(tabSize));
|
|
5663
|
+
return (text, context) => {
|
|
5664
|
+
const key = JSON.stringify([text, context]);
|
|
5665
|
+
let result = cache.get(key);
|
|
5666
|
+
if (!result) {
|
|
5667
|
+
if (context && context.offset > 0 && context.offset < context.text.length && joiningScript.test(context.text)) {
|
|
5668
|
+
const normalizedOffset = normalize(context.text.slice(0, context.offset)).length;
|
|
5669
|
+
result = invoke$8('MeasureBidi.measurePrefix', normalize(context.text), normalizedOffset, fontWeight, fontSize, fontFamily, letterSpacing, context.rtl ? 'rtl' : 'ltr');
|
|
5670
|
+
} else {
|
|
5671
|
+
// The measurement worker's monospace shortcut assumes every glyph has
|
|
5672
|
+
// the ASCII width; RTL fonts and fallback glyphs need real measurement.
|
|
5673
|
+
result = measureTextWidth(normalize(text), fontWeight, fontSize, fontFamily, letterSpacing, false, charWidth);
|
|
5674
|
+
}
|
|
5675
|
+
cache.set(key, result);
|
|
5676
|
+
}
|
|
5677
|
+
return result;
|
|
5678
|
+
};
|
|
5679
|
+
};
|
|
5680
|
+
|
|
5681
|
+
const getX = async (line, column, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference = 0, measuredLineWidth, rtl = false) => {
|
|
4428
5682
|
if (!line) {
|
|
4429
5683
|
return 0;
|
|
4430
5684
|
}
|
|
@@ -4435,6 +5689,11 @@ const getX = async (line, column, fontWeight, fontSize, fontFamily, isMonospaceF
|
|
|
4435
5689
|
boolean(isMonospaceFont);
|
|
4436
5690
|
number(averageCharWidth);
|
|
4437
5691
|
number(difference);
|
|
5692
|
+
if (isBidi(line, rtl)) {
|
|
5693
|
+
const measure = createMeasure(fontWeight, fontSize, fontFamily, letterSpacing, tabSize, averageCharWidth);
|
|
5694
|
+
const x = await getPosition(line, column, measure);
|
|
5695
|
+
return Math.min(width, x - halfCursorWidth + difference);
|
|
5696
|
+
}
|
|
4438
5697
|
if (column === 0) {
|
|
4439
5698
|
return difference === 0 ? 0 : Math.min(width, difference);
|
|
4440
5699
|
}
|
|
@@ -4489,7 +5748,7 @@ const getVisibleDiagnostics = async (editor, diagnostics) => {
|
|
|
4489
5748
|
return visibleDiagnostics;
|
|
4490
5749
|
};
|
|
4491
5750
|
|
|
4492
|
-
const invoke$
|
|
5751
|
+
const invoke$7 = (...args) => invoke$e(...args);
|
|
4493
5752
|
|
|
4494
5753
|
/**
|
|
4495
5754
|
* Merges link decorations with diagnostic decorations
|
|
@@ -4578,7 +5837,7 @@ const mergeDiagnostics = (editor, editorWithDiagnostics) => ({
|
|
|
4578
5837
|
});
|
|
4579
5838
|
const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) => {
|
|
4580
5839
|
return (await enqueue(editor.id, async () => {
|
|
4581
|
-
let latest = get$
|
|
5840
|
+
let latest = get$9(editor.id);
|
|
4582
5841
|
if (!isApplicable(latest, editor, generation)) {
|
|
4583
5842
|
return editor;
|
|
4584
5843
|
}
|
|
@@ -4591,11 +5850,11 @@ const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) =>
|
|
|
4591
5850
|
}
|
|
4592
5851
|
let calculationState = latest.newState;
|
|
4593
5852
|
let editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
|
|
4594
|
-
latest = get$
|
|
5853
|
+
latest = get$9(editor.id);
|
|
4595
5854
|
while (isApplicable(latest, editor, generation) && !diagnosticLayoutEqual(calculationState, latest.newState)) {
|
|
4596
5855
|
calculationState = latest.newState;
|
|
4597
5856
|
editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
|
|
4598
|
-
latest = get$
|
|
5857
|
+
latest = get$9(editor.id);
|
|
4599
5858
|
}
|
|
4600
5859
|
if (!isApplicable(latest, editor, generation)) {
|
|
4601
5860
|
return editor;
|
|
@@ -4604,10 +5863,10 @@ const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) =>
|
|
|
4604
5863
|
return latest.newState;
|
|
4605
5864
|
}
|
|
4606
5865
|
const newEditor = mergeDiagnostics(latest.newState, editorWithDiagnostics);
|
|
4607
|
-
set$
|
|
5866
|
+
set$b(editor.id, latest.oldState, newEditor);
|
|
4608
5867
|
requestDiagnosticSnapshots.set(editor.id, diagnostics);
|
|
4609
5868
|
onAccepted?.();
|
|
4610
|
-
await invoke$
|
|
5869
|
+
await invoke$7('Editor.renderPending', newEditor.id);
|
|
4611
5870
|
pendingDiagnosticNotifications.delete(editor.id);
|
|
4612
5871
|
await notifyDiagnosticsChange(newEditor.uri, newEditor.applicationId);
|
|
4613
5872
|
return newEditor;
|
|
@@ -4635,7 +5894,7 @@ const updateDiagnostics = async (editor, timeoutMs = 0) => {
|
|
|
4635
5894
|
}
|
|
4636
5895
|
const generation = (requestGenerations.get(editor.id) ?? 0) + 1;
|
|
4637
5896
|
requestGenerations.set(editor.id, generation);
|
|
4638
|
-
requestDiagnosticSnapshots.set(editor.id, get$
|
|
5897
|
+
requestDiagnosticSnapshots.set(editor.id, get$9(editor.id)?.newState.diagnostics ?? editor.diagnostics);
|
|
4639
5898
|
const providers = new Map();
|
|
4640
5899
|
const previous = previousProviderResults.get(editor.id);
|
|
4641
5900
|
if (previous && previous.languageId === editor.languageId && previous.uri === editor.uri) {
|
|
@@ -4749,7 +6008,7 @@ const updateDiagnostics = async (editor, timeoutMs = 0) => {
|
|
|
4749
6008
|
};
|
|
4750
6009
|
try {
|
|
4751
6010
|
await Promise.all([request(), completed.promise]);
|
|
4752
|
-
const latest = get$
|
|
6011
|
+
const latest = get$9(editor.id);
|
|
4753
6012
|
if (strict && !isApplicable(latest, editor, generation)) {
|
|
4754
6013
|
throw new Error('Editor changed or closed while waiting for diagnostics');
|
|
4755
6014
|
}
|
|
@@ -4802,7 +6061,7 @@ const transformCachedDiagnostics = (editorId, changes) => {
|
|
|
4802
6061
|
};
|
|
4803
6062
|
const updateDiagnosticsAll = async () => {
|
|
4804
6063
|
for (const key of getKeys$2()) {
|
|
4805
|
-
const editor = get$
|
|
6064
|
+
const editor = get$9(Number(key))?.newState;
|
|
4806
6065
|
if (editor) {
|
|
4807
6066
|
await updateDiagnostics(editor);
|
|
4808
6067
|
}
|
|
@@ -4814,7 +6073,7 @@ const waitForDiagnostics = async (editorId, timeoutMs = 30_000) => {
|
|
|
4814
6073
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > 300_000) {
|
|
4815
6074
|
throw new Error('Diagnostics timeout must be between 1 and 300000ms');
|
|
4816
6075
|
}
|
|
4817
|
-
const editor = get$
|
|
6076
|
+
const editor = get$9(editorId)?.newState;
|
|
4818
6077
|
if (!editor || editor.initial) {
|
|
4819
6078
|
throw new Error(`Editor is not ready: ${editorId}`);
|
|
4820
6079
|
}
|
|
@@ -4845,8 +6104,9 @@ const getFontKey = ({
|
|
|
4845
6104
|
fontWeight,
|
|
4846
6105
|
isMonospaceFont,
|
|
4847
6106
|
letterSpacing,
|
|
6107
|
+
rtl,
|
|
4848
6108
|
tabSize
|
|
4849
|
-
}) => JSON.stringify([charWidth, fontFamily, fontSize, fontWeight, isMonospaceFont, letterSpacing, tabSize]);
|
|
6109
|
+
}) => JSON.stringify([charWidth, fontFamily, fontSize, fontWeight, isMonospaceFont, letterSpacing, rtl, tabSize]);
|
|
4850
6110
|
const getCachedLineWidth = (state, line) => {
|
|
4851
6111
|
const {
|
|
4852
6112
|
largeFile,
|
|
@@ -4880,6 +6140,7 @@ const updateHorizontalLayout = async state => {
|
|
|
4880
6140
|
isMonospaceFont,
|
|
4881
6141
|
letterSpacing,
|
|
4882
6142
|
lines,
|
|
6143
|
+
rtl,
|
|
4883
6144
|
tabSize,
|
|
4884
6145
|
width
|
|
4885
6146
|
} = state;
|
|
@@ -4911,8 +6172,10 @@ const updateHorizontalLayout = async state => {
|
|
|
4911
6172
|
}
|
|
4912
6173
|
}
|
|
4913
6174
|
const texts = [...textsToMeasure];
|
|
4914
|
-
const
|
|
4915
|
-
const
|
|
6175
|
+
const regularTexts = texts.filter(text => !isBidi(text, rtl));
|
|
6176
|
+
const bidiTexts = texts.filter(text => isBidi(text, rtl));
|
|
6177
|
+
const [regularWidths, bidiWidths] = await Promise.all([regularTexts.length > 0 ? measureTextWidths(regularTexts, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth) : [], bidiTexts.length > 0 ? measureTextWidths(bidiTexts, fontWeight, fontSize, fontFamily, letterSpacing, false, charWidth) : []]);
|
|
6178
|
+
const measuredByText = new Map([...regularTexts.map((text, index) => [text, regularWidths[index]]), ...bidiTexts.map((text, index) => [text, bidiWidths[index]])]);
|
|
4916
6179
|
for (const [line, text] of textByLine) {
|
|
4917
6180
|
widths.set(line, measuredByText.get(text));
|
|
4918
6181
|
}
|
|
@@ -5063,6 +6326,9 @@ const getVisible = async editor => {
|
|
|
5063
6326
|
visibleViewLineIndices,
|
|
5064
6327
|
width
|
|
5065
6328
|
} = editor;
|
|
6329
|
+
if (editor.rtl && actualSelectionHasBidi(editor)) {
|
|
6330
|
+
return getBidiVisible(editor);
|
|
6331
|
+
}
|
|
5066
6332
|
const averageCharWidth = charWidth;
|
|
5067
6333
|
const halfCursorWidth = cursorWidth / 2;
|
|
5068
6334
|
const actualVisibleLineIndices = visibleLineIndices || Array.from({
|
|
@@ -5182,6 +6448,76 @@ const getVisible = async editor => {
|
|
|
5182
6448
|
selectionInfos: getSelectionArray(visibleSelections)
|
|
5183
6449
|
};
|
|
5184
6450
|
};
|
|
6451
|
+
const actualSelectionHasBidi = editor => {
|
|
6452
|
+
for (let i = 0; i < editor.selections.length; i += 4) {
|
|
6453
|
+
const [startRow,, endRow] = getSelectionPairs(editor.selections, i);
|
|
6454
|
+
for (let row = Math.max(startRow, editor.minLineY); row <= Math.min(endRow, editor.maxLineY - 1); row++) {
|
|
6455
|
+
if (isBidi(editor.lines[row], true)) {
|
|
6456
|
+
return true;
|
|
6457
|
+
}
|
|
6458
|
+
}
|
|
6459
|
+
}
|
|
6460
|
+
return false;
|
|
6461
|
+
};
|
|
6462
|
+
const getBidiVisible = async editor => {
|
|
6463
|
+
const {
|
|
6464
|
+
charWidth,
|
|
6465
|
+
cursorWidth,
|
|
6466
|
+
deltaX = 0,
|
|
6467
|
+
deltaY,
|
|
6468
|
+
focused,
|
|
6469
|
+
foldingRanges = [],
|
|
6470
|
+
fontFamily,
|
|
6471
|
+
fontSize,
|
|
6472
|
+
fontWeight,
|
|
6473
|
+
itemHeight,
|
|
6474
|
+
letterSpacing,
|
|
6475
|
+
lines,
|
|
6476
|
+
maxLineY,
|
|
6477
|
+
minLineY,
|
|
6478
|
+
rowHeight,
|
|
6479
|
+
selections,
|
|
6480
|
+
tabSize,
|
|
6481
|
+
viewLineIndices
|
|
6482
|
+
} = editor;
|
|
6483
|
+
const measure = createMeasure(fontWeight, fontSize, fontFamily, letterSpacing, tabSize, charWidth);
|
|
6484
|
+
const visibleRows = editor.visibleLineIndices || Array.from({
|
|
6485
|
+
length: maxLineY - minLineY
|
|
6486
|
+
}, (_, index) => minLineY + index);
|
|
6487
|
+
const visualRow = row => viewLineIndices ? getVisualRowForDocumentRow$1(row, viewLineIndices) : getVisualRowForDocumentRow(row, foldingRanges);
|
|
6488
|
+
const top = itemHeight ? Math.floor(deltaY / itemHeight) : visualRow(minLineY);
|
|
6489
|
+
const cursors = [];
|
|
6490
|
+
const rectangles = [];
|
|
6491
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
6492
|
+
const activeRow = selections[i + 2];
|
|
6493
|
+
const activeColumn = selections[i + 3];
|
|
6494
|
+
if (visibleRows.includes(activeRow)) {
|
|
6495
|
+
const line = lines[activeRow];
|
|
6496
|
+
const x = isBidi(line, true) ? await getPosition(line, activeColumn, measure) : await measure(line.slice(0, activeColumn));
|
|
6497
|
+
cursors.push(x - deltaX - cursorWidth / 2, (visualRow(activeRow) - top) * rowHeight);
|
|
6498
|
+
}
|
|
6499
|
+
const [startRow, startColumn, endRow, endColumn] = getSelectionPairs(selections, i);
|
|
6500
|
+
const selectedRows = visibleRows.filter(row => row >= startRow && row <= endRow);
|
|
6501
|
+
for (const row of selectedRows) {
|
|
6502
|
+
const line = lines[row];
|
|
6503
|
+
const start = row === startRow ? startColumn : 0;
|
|
6504
|
+
const end = row === endRow ? endColumn : line.length;
|
|
6505
|
+
const ranges = isBidi(line, true) ? await getSelectionRanges(line, start, end, measure) : [{
|
|
6506
|
+
width: await measure(line.slice(start, end)),
|
|
6507
|
+
x: await measure(line.slice(0, start))
|
|
6508
|
+
}];
|
|
6509
|
+
for (const range of ranges) {
|
|
6510
|
+
if (range.width > 0) {
|
|
6511
|
+
rectangles.push(range.x - deltaX - cursorWidth / 2, (visualRow(row) - top) * rowHeight, range.width, rowHeight);
|
|
6512
|
+
}
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
}
|
|
6516
|
+
return {
|
|
6517
|
+
cursorInfos: getCursorArray(cursors, focused),
|
|
6518
|
+
selectionInfos: getSelectionArray(rectangles)
|
|
6519
|
+
};
|
|
6520
|
+
};
|
|
5185
6521
|
|
|
5186
6522
|
const getSelectionFromChange = change => {
|
|
5187
6523
|
const {
|
|
@@ -5413,7 +6749,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
|
|
|
5413
6749
|
...newEditor,
|
|
5414
6750
|
decorations: linkDecorations
|
|
5415
6751
|
};
|
|
5416
|
-
set$
|
|
6752
|
+
set$b(editor.uid, editor, newEditorWithDecorations);
|
|
5417
6753
|
|
|
5418
6754
|
// Notify main-area-worker about modified status change
|
|
5419
6755
|
if (!editor.modified) {
|
|
@@ -5885,7 +7221,7 @@ const getMinimapLines = async (editor, syncIncremental) => {
|
|
|
5885
7221
|
await loadTokenizers(result.tokenizersToLoad);
|
|
5886
7222
|
result = await getTokensViewport2(editor, 0, lines.length, syncIncremental);
|
|
5887
7223
|
}
|
|
5888
|
-
const tokenMap = get$
|
|
7224
|
+
const tokenMap = get$6(languageId);
|
|
5889
7225
|
return result.tokens.map((lineState, index) => getLine(lineState, result.embeddedResults, tokenMap, lines[index].length));
|
|
5890
7226
|
};
|
|
5891
7227
|
|
|
@@ -6251,23 +7587,23 @@ const getVisibleBracketMatches = async editor => {
|
|
|
6251
7587
|
};
|
|
6252
7588
|
|
|
6253
7589
|
const shouldUpdateDiagnosticData = (oldState, newState) => {
|
|
6254
|
-
return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
|
|
7590
|
+
return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
|
|
6255
7591
|
};
|
|
6256
7592
|
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
6257
|
-
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
7593
|
+
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
6258
7594
|
};
|
|
6259
7595
|
const shouldUpdateBracketMatchData = (oldState, newState) => {
|
|
6260
7596
|
if (!('bracketMatchInfos' in newState)) {
|
|
6261
7597
|
return false;
|
|
6262
7598
|
}
|
|
6263
|
-
return oldState.selections !== newState.selections || oldState.lines !== newState.lines || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
7599
|
+
return oldState.selections !== newState.selections || oldState.lines !== newState.lines || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.rowHeight !== newState.rowHeight || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
6264
7600
|
};
|
|
6265
7601
|
const shouldUpdateLightBulb = (oldState, newState) => oldState.diagnostics !== newState.diagnostics || oldState.languageId !== newState.languageId || oldState.selections !== newState.selections || oldState.uri !== newState.uri;
|
|
6266
7602
|
const shouldUpdateVisibleTextData = (oldState, newState) => {
|
|
6267
7603
|
if (oldState.deltaX === newState.deltaX && (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences)) {
|
|
6268
7604
|
return false;
|
|
6269
7605
|
}
|
|
6270
|
-
return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.tabSize !== newState.tabSize || oldState.horizontalVirtualizationThreshold !== newState.horizontalVirtualizationThreshold || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.letterSpacing !== newState.letterSpacing || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
|
|
7606
|
+
return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.horizontalVirtualizationThreshold !== newState.horizontalVirtualizationThreshold || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.letterSpacing !== newState.letterSpacing || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
|
|
6271
7607
|
};
|
|
6272
7608
|
const shouldUpdateMinimapData = (oldState, newState) => {
|
|
6273
7609
|
return newState.minimapEnabled && (!oldState.minimapEnabled || oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId);
|
|
@@ -6284,7 +7620,7 @@ const mergeConflictsEqual$1 = (oldState, newState) => {
|
|
|
6284
7620
|
});
|
|
6285
7621
|
};
|
|
6286
7622
|
const updateDerivedState = async (oldState, newState, deferGutterDecorations = false) => {
|
|
6287
|
-
const horizontalState = oldState.initial || oldState.lines !== newState.lines || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.tabSize !== newState.tabSize || oldState.lineNumbers !== newState.lineNumbers || oldState.breakPoints !== newState.breakPoints || oldState.gutterDecorations !== newState.gutterDecorations || oldState.lightBulbRowIndex !== newState.lightBulbRowIndex ? await updateHorizontalLayout(newState) : newState;
|
|
7623
|
+
const horizontalState = oldState.initial || oldState.lines !== newState.lines || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.lineNumbers !== newState.lineNumbers || oldState.breakPoints !== newState.breakPoints || oldState.gutterDecorations !== newState.gutterDecorations || oldState.lightBulbRowIndex !== newState.lightBulbRowIndex ? await updateHorizontalLayout(newState) : newState;
|
|
6288
7624
|
const layoutState = oldState.lines !== newState.lines && 'foldingRanges' in newState ? updateLayout(horizontalState, []) : horizontalState;
|
|
6289
7625
|
const nextState = mergeConflictsEqual$1(oldState, layoutState) ? layoutState : {
|
|
6290
7626
|
...layoutState,
|
|
@@ -6390,7 +7726,7 @@ const updateColorPickerValue = async (editorUid, value) => {
|
|
|
6390
7726
|
return;
|
|
6391
7727
|
}
|
|
6392
7728
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
6393
|
-
set$
|
|
7729
|
+
set$b(editorUid, editor, newEditorWithDerivedState);
|
|
6394
7730
|
};
|
|
6395
7731
|
|
|
6396
7732
|
const getColorPickerWorkerCommandMap = () => ({
|
|
@@ -6425,14 +7761,14 @@ const launchColorPickerWorker = async () => {
|
|
|
6425
7761
|
return launchWorker(name, url, undefined, getColorPickerWorkerCommandMap());
|
|
6426
7762
|
};
|
|
6427
7763
|
|
|
6428
|
-
const state$
|
|
7764
|
+
const state$8 = {};
|
|
6429
7765
|
const getOrCreate$2 = () => {
|
|
6430
|
-
if (!state$
|
|
6431
|
-
state$
|
|
7766
|
+
if (!state$8.workerPromise) {
|
|
7767
|
+
state$8.workerPromise = launchColorPickerWorker();
|
|
6432
7768
|
}
|
|
6433
|
-
return state$
|
|
7769
|
+
return state$8.workerPromise;
|
|
6434
7770
|
};
|
|
6435
|
-
const invoke$
|
|
7771
|
+
const invoke$6 = async (method, ...params) => {
|
|
6436
7772
|
const worker = await getOrCreate$2();
|
|
6437
7773
|
return await worker.invoke(method, ...params);
|
|
6438
7774
|
};
|
|
@@ -6446,10 +7782,10 @@ const loadContent$3 = async (state, parentUid) => {
|
|
|
6446
7782
|
x,
|
|
6447
7783
|
y
|
|
6448
7784
|
} = state;
|
|
6449
|
-
await invoke$
|
|
6450
|
-
await invoke$
|
|
6451
|
-
const diff = await invoke$
|
|
6452
|
-
const commands = await invoke$
|
|
7785
|
+
await invoke$6('ColorPicker.create', uid, x, y, width, height, parentUid);
|
|
7786
|
+
await invoke$6('ColorPicker.loadContent', uid, toColorPickerValue(value));
|
|
7787
|
+
const diff = await invoke$6('ColorPicker.diff2', uid);
|
|
7788
|
+
const commands = await invoke$6('ColorPicker.render2', uid, diff);
|
|
6453
7789
|
return {
|
|
6454
7790
|
...state,
|
|
6455
7791
|
commands
|
|
@@ -6603,7 +7939,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir, _langua
|
|
|
6603
7939
|
x,
|
|
6604
7940
|
y
|
|
6605
7941
|
};
|
|
6606
|
-
set$
|
|
7942
|
+
set$b(id, editor, editor);
|
|
6607
7943
|
};
|
|
6608
7944
|
|
|
6609
7945
|
const emptyEditor = {
|
|
@@ -6746,8 +8082,39 @@ const getLanguages = async (platform, assetDir) => {
|
|
|
6746
8082
|
return languages;
|
|
6747
8083
|
};
|
|
6748
8084
|
|
|
8085
|
+
const cacheName = 'lvce-editor-character-widths-v1';
|
|
8086
|
+
const character = 'a';
|
|
8087
|
+
const getKey$1 = (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
8088
|
+
return `/character-width/${encodeURIComponent(JSON.stringify([character, fontWeight, fontSize, fontFamily, letterSpacing]))}`;
|
|
8089
|
+
};
|
|
8090
|
+
const get$4 = async (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
8091
|
+
const item = await getCacheStorageJsonItem(getKey$1(fontWeight, fontSize, fontFamily, letterSpacing), cacheName);
|
|
8092
|
+
const width = item?.value;
|
|
8093
|
+
if (typeof width !== 'number' || !Number.isFinite(width) || width < 0) {
|
|
8094
|
+
return undefined;
|
|
8095
|
+
}
|
|
8096
|
+
return width;
|
|
8097
|
+
};
|
|
8098
|
+
const set$5 = async (fontWeight, fontSize, fontFamily, letterSpacing, width) => {
|
|
8099
|
+
await setCacheStorageJsonItem(getKey$1(fontWeight, fontSize, fontFamily, letterSpacing), width, cacheName);
|
|
8100
|
+
};
|
|
8101
|
+
|
|
6749
8102
|
const measureCharacterWidth = async (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
6750
|
-
|
|
8103
|
+
try {
|
|
8104
|
+
const cachedWidth = await get$4(fontWeight, fontSize, fontFamily, letterSpacing);
|
|
8105
|
+
if (cachedWidth !== undefined) {
|
|
8106
|
+
return cachedWidth;
|
|
8107
|
+
}
|
|
8108
|
+
} catch {
|
|
8109
|
+
// Cache failures must not prevent editor creation.
|
|
8110
|
+
}
|
|
8111
|
+
const width = await measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
|
|
8112
|
+
try {
|
|
8113
|
+
await set$5(fontWeight, fontSize, fontFamily, letterSpacing, width);
|
|
8114
|
+
} catch {
|
|
8115
|
+
// Cache failures must not prevent editor creation.
|
|
8116
|
+
}
|
|
8117
|
+
return width;
|
|
6751
8118
|
};
|
|
6752
8119
|
|
|
6753
8120
|
const normalizeLineEndings = content => {
|
|
@@ -6947,10 +8314,10 @@ const createEditor = async ({
|
|
|
6947
8314
|
focused: true,
|
|
6948
8315
|
textInfos
|
|
6949
8316
|
};
|
|
6950
|
-
set$
|
|
8317
|
+
set$b(id, emptyEditor, newEditor4);
|
|
6951
8318
|
const completionsOnTypeRaw = await get$3('editor.completionsOnType');
|
|
6952
8319
|
const completionsOnType = Boolean(completionsOnTypeRaw);
|
|
6953
|
-
set$
|
|
8320
|
+
set$b(id, emptyEditor, {
|
|
6954
8321
|
...newEditor4,
|
|
6955
8322
|
completionsOnType
|
|
6956
8323
|
});
|
|
@@ -6979,7 +8346,7 @@ const createStandaloneEditor = async ({
|
|
|
6979
8346
|
y
|
|
6980
8347
|
}) => {
|
|
6981
8348
|
createEditor2(id, uri, x, y, width, height, platform, assetDir, undefined, undefined, undefined, applicationId);
|
|
6982
|
-
const createdEditor = get$
|
|
8349
|
+
const createdEditor = get$9(id).newState;
|
|
6983
8350
|
await loadTokenizer(languageId, tokenizePath);
|
|
6984
8351
|
const tokenizerId = register(getTokenizer(languageId));
|
|
6985
8352
|
const configuredEditor = {
|
|
@@ -7026,7 +8393,7 @@ const createStandaloneEditor = async ({
|
|
|
7026
8393
|
selectionInfos
|
|
7027
8394
|
};
|
|
7028
8395
|
if (!createdEditor.lifecycle?.disposed) {
|
|
7029
|
-
set$
|
|
8396
|
+
set$b(id, createdEditor, finalEditor);
|
|
7030
8397
|
}
|
|
7031
8398
|
};
|
|
7032
8399
|
|
|
@@ -7089,7 +8456,7 @@ const diff = (oldState, newState) => {
|
|
|
7089
8456
|
};
|
|
7090
8457
|
|
|
7091
8458
|
const diff2 = uid => {
|
|
7092
|
-
const editor = get$
|
|
8459
|
+
const editor = get$9(uid);
|
|
7093
8460
|
if (!editor) {
|
|
7094
8461
|
return [];
|
|
7095
8462
|
}
|
|
@@ -7103,7 +8470,7 @@ const diff2 = uid => {
|
|
|
7103
8470
|
|
|
7104
8471
|
const autoSaveDelay = 1000;
|
|
7105
8472
|
const pendingSaves = new Map();
|
|
7106
|
-
const state$
|
|
8473
|
+
const state$7 = {
|
|
7107
8474
|
nextToken: 0
|
|
7108
8475
|
};
|
|
7109
8476
|
const run = async (uid, token, save) => {
|
|
@@ -7114,7 +8481,7 @@ const run = async (uid, token, save) => {
|
|
|
7114
8481
|
};
|
|
7115
8482
|
const schedule$1 = (uid, save) => {
|
|
7116
8483
|
dispose$4(uid);
|
|
7117
|
-
const token = ++state$
|
|
8484
|
+
const token = ++state$7.nextToken;
|
|
7118
8485
|
const timeout = setTimeout(run, autoSaveDelay, uid, token, save);
|
|
7119
8486
|
pendingSaves.set(uid, {
|
|
7120
8487
|
timeout,
|
|
@@ -7147,12 +8514,12 @@ const clear$3 = editorUid => {
|
|
|
7147
8514
|
dismissals$1.delete(editorUid);
|
|
7148
8515
|
}
|
|
7149
8516
|
};
|
|
7150
|
-
const set$
|
|
8517
|
+
const set$4 = (editorUid, dismissal) => {
|
|
7151
8518
|
clear$3(editorUid);
|
|
7152
8519
|
dismissals$1.set(editorUid, dismissal);
|
|
7153
8520
|
};
|
|
7154
8521
|
|
|
7155
|
-
const state$
|
|
8522
|
+
const state$6 = {
|
|
7156
8523
|
editor: undefined,
|
|
7157
8524
|
timeout: -1,
|
|
7158
8525
|
token: 0,
|
|
@@ -7160,29 +8527,29 @@ const state$7 = {
|
|
|
7160
8527
|
y: 0
|
|
7161
8528
|
};
|
|
7162
8529
|
const get$2 = () => {
|
|
7163
|
-
return state$
|
|
8530
|
+
return state$6;
|
|
7164
8531
|
};
|
|
7165
|
-
const set$
|
|
7166
|
-
state$
|
|
7167
|
-
state$
|
|
7168
|
-
state$
|
|
7169
|
-
state$
|
|
7170
|
-
state$
|
|
8532
|
+
const set$3 = (editor, timeout, x, y, token) => {
|
|
8533
|
+
state$6.editor = editor;
|
|
8534
|
+
state$6.timeout = timeout;
|
|
8535
|
+
state$6.token = token;
|
|
8536
|
+
state$6.x = x;
|
|
8537
|
+
state$6.y = y;
|
|
7171
8538
|
};
|
|
7172
8539
|
const clear$2 = editorUid => {
|
|
7173
8540
|
const {
|
|
7174
8541
|
editor,
|
|
7175
8542
|
timeout
|
|
7176
|
-
} = state$
|
|
8543
|
+
} = state$6;
|
|
7177
8544
|
if (editorUid !== undefined && editor?.uid !== editorUid) {
|
|
7178
8545
|
return;
|
|
7179
8546
|
}
|
|
7180
8547
|
if (timeout !== -1) {
|
|
7181
8548
|
clearTimeout(timeout);
|
|
7182
8549
|
}
|
|
7183
|
-
state$
|
|
7184
|
-
state$
|
|
7185
|
-
state$
|
|
8550
|
+
state$6.editor = undefined;
|
|
8551
|
+
state$6.timeout = -1;
|
|
8552
|
+
state$6.token++;
|
|
7186
8553
|
};
|
|
7187
8554
|
|
|
7188
8555
|
const dismissals = new Map();
|
|
@@ -7194,7 +8561,7 @@ const clear$1 = editorUid => {
|
|
|
7194
8561
|
clearTimeout(dismissal.timeout);
|
|
7195
8562
|
dismissals.delete(editorUid);
|
|
7196
8563
|
};
|
|
7197
|
-
const set$
|
|
8564
|
+
const set$2 = (editorUid, dismissal) => {
|
|
7198
8565
|
clear$1(editorUid);
|
|
7199
8566
|
dismissals.set(editorUid, dismissal);
|
|
7200
8567
|
};
|
|
@@ -7236,7 +8603,7 @@ const getEditorStatus = editor => {
|
|
|
7236
8603
|
};
|
|
7237
8604
|
|
|
7238
8605
|
const sendToListener = async (rpcId, status) => {
|
|
7239
|
-
const rpc = get$
|
|
8606
|
+
const rpc = get$a(rpcId);
|
|
7240
8607
|
if (rpc) {
|
|
7241
8608
|
await send$2(rpcId, rpc, status);
|
|
7242
8609
|
}
|
|
@@ -7245,7 +8612,7 @@ const initializeListener = async rpcId => {
|
|
|
7245
8612
|
if (!getListeners(EditorSelection$1).includes(rpcId)) {
|
|
7246
8613
|
return;
|
|
7247
8614
|
}
|
|
7248
|
-
const editor = getKeys$2().map(uid => get$
|
|
8615
|
+
const editor = getKeys$2().map(uid => get$9(Number(uid))?.newState).find(state => {
|
|
7249
8616
|
const {
|
|
7250
8617
|
focused,
|
|
7251
8618
|
initial
|
|
@@ -7274,14 +8641,14 @@ const launchRenameWorker = async () => {
|
|
|
7274
8641
|
};
|
|
7275
8642
|
|
|
7276
8643
|
let workerPromise;
|
|
7277
|
-
const invoke$
|
|
8644
|
+
const invoke$5 = async (method, ...params) => {
|
|
7278
8645
|
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function
|
|
7279
8646
|
workerPromise ||= launchRenameWorker();
|
|
7280
8647
|
const worker = await workerPromise;
|
|
7281
8648
|
return await worker.invoke(method, ...params);
|
|
7282
8649
|
};
|
|
7283
8650
|
const dispose$3 = async () => {
|
|
7284
|
-
if (getKeys$2().some(uid => get$
|
|
8651
|
+
if (getKeys$2().some(uid => get$9(Number(uid))?.newState.widgets?.some(widget => widget.id === Rename$1))) {
|
|
7285
8652
|
return;
|
|
7286
8653
|
}
|
|
7287
8654
|
const promise = workerPromise;
|
|
@@ -7298,7 +8665,7 @@ const textAppendPaths = new Map();
|
|
|
7298
8665
|
const get$1 = uid => {
|
|
7299
8666
|
return renderedDoms.get(uid);
|
|
7300
8667
|
};
|
|
7301
|
-
const set$
|
|
8668
|
+
const set$1 = (uid, dom, paths) => {
|
|
7302
8669
|
renderedDoms.set(uid, dom);
|
|
7303
8670
|
setTextAppendPaths(uid, paths);
|
|
7304
8671
|
};
|
|
@@ -7318,14 +8685,14 @@ const dispose$2 = uid => {
|
|
|
7318
8685
|
};
|
|
7319
8686
|
|
|
7320
8687
|
const addWidget$1 = widget => {
|
|
7321
|
-
const module = get$
|
|
8688
|
+
const module = get$8(widget.id);
|
|
7322
8689
|
if (!module) {
|
|
7323
8690
|
throw new Error('unsupported widget');
|
|
7324
8691
|
}
|
|
7325
8692
|
return module.add(widget);
|
|
7326
8693
|
};
|
|
7327
8694
|
const renderWidget = widget => {
|
|
7328
|
-
const module = get$
|
|
8695
|
+
const module = get$8(widget.id);
|
|
7329
8696
|
if (!module) {
|
|
7330
8697
|
throw new Error('unsupported widget');
|
|
7331
8698
|
}
|
|
@@ -7394,7 +8761,7 @@ const renderWidgets$1 = (oldState, newState) => {
|
|
|
7394
8761
|
};
|
|
7395
8762
|
|
|
7396
8763
|
const disposeEditor = async editorUid => {
|
|
7397
|
-
const editor = get$
|
|
8764
|
+
const editor = get$9(editorUid)?.newState;
|
|
7398
8765
|
if (!editor) {
|
|
7399
8766
|
return [];
|
|
7400
8767
|
}
|
|
@@ -7422,7 +8789,7 @@ const disposeEditor = async editorUid => {
|
|
|
7422
8789
|
}
|
|
7423
8790
|
for (const widget of editor.widgets) {
|
|
7424
8791
|
if (widget.id === ColorPicker$2) {
|
|
7425
|
-
pending.push(invoke$
|
|
8792
|
+
pending.push(invoke$6('ColorPicker.dispose', widget.newState.uid));
|
|
7426
8793
|
}
|
|
7427
8794
|
}
|
|
7428
8795
|
const commands = renderWidgets$1(editor, {
|
|
@@ -7497,7 +8864,7 @@ const hydrateWidget = (editor, widgetId, uid, newState) => {
|
|
|
7497
8864
|
};
|
|
7498
8865
|
};
|
|
7499
8866
|
const getLatestEditor = (uid, fallback) => {
|
|
7500
|
-
const instance = get$
|
|
8867
|
+
const instance = get$9(uid);
|
|
7501
8868
|
return instance?.newState || fallback;
|
|
7502
8869
|
};
|
|
7503
8870
|
const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGenerator, fullFocus) => {
|
|
@@ -7529,7 +8896,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7529
8896
|
};
|
|
7530
8897
|
if (fullFocus) {
|
|
7531
8898
|
// Staging changes pending state; only rendering may advance the mounted baseline.
|
|
7532
|
-
set$
|
|
8899
|
+
set$b(editor.uid, get$9(editor.uid)?.oldState || editor, stagedEditor);
|
|
7533
8900
|
}
|
|
7534
8901
|
const newState = await newStateGenerator(initialState, editor.uid);
|
|
7535
8902
|
if (!newState) {
|
|
@@ -7539,7 +8906,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7539
8906
|
if (fullFocus) {
|
|
7540
8907
|
const latestEditor = getLatestEditor(editor.uid, stagedEditor);
|
|
7541
8908
|
if (latestEditor === stagedEditor) {
|
|
7542
|
-
set$
|
|
8909
|
+
set$b(editor.uid, get$9(editor.uid)?.oldState || editor, editor);
|
|
7543
8910
|
}
|
|
7544
8911
|
return latestEditor === stagedEditor ? editor : latestEditor;
|
|
7545
8912
|
}
|
|
@@ -7560,7 +8927,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7560
8927
|
} : currentEditor;
|
|
7561
8928
|
const hydratedEditor = hydrateWidget(latestEditor, widgetId, widgetUid, latestState);
|
|
7562
8929
|
if (hydratedEditor !== latestEditor) {
|
|
7563
|
-
set$
|
|
8930
|
+
set$b(editor.uid, get$9(editor.uid)?.oldState || editor, hydratedEditor);
|
|
7564
8931
|
}
|
|
7565
8932
|
return hydratedEditor;
|
|
7566
8933
|
}
|
|
@@ -7577,7 +8944,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7577
8944
|
};
|
|
7578
8945
|
};
|
|
7579
8946
|
|
|
7580
|
-
const state$
|
|
8947
|
+
const state$5 = {
|
|
7581
8948
|
configured: false,
|
|
7582
8949
|
lastId: -1,
|
|
7583
8950
|
nextId: 0
|
|
@@ -7585,23 +8952,23 @@ const state$6 = {
|
|
|
7585
8952
|
const configure = (start, end) => {
|
|
7586
8953
|
const {
|
|
7587
8954
|
configured
|
|
7588
|
-
} = state$
|
|
8955
|
+
} = state$5;
|
|
7589
8956
|
if (configured) {
|
|
7590
8957
|
throw new Error('Component id range is already configured');
|
|
7591
8958
|
}
|
|
7592
8959
|
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
|
|
7593
8960
|
throw new Error('Invalid component id range');
|
|
7594
8961
|
}
|
|
7595
|
-
state$
|
|
7596
|
-
state$
|
|
7597
|
-
state$
|
|
8962
|
+
state$5.nextId = start;
|
|
8963
|
+
state$5.lastId = end;
|
|
8964
|
+
state$5.configured = true;
|
|
7598
8965
|
};
|
|
7599
8966
|
const create$8 = () => {
|
|
7600
8967
|
const {
|
|
7601
8968
|
configured,
|
|
7602
8969
|
lastId,
|
|
7603
8970
|
nextId
|
|
7604
|
-
} = state$
|
|
8971
|
+
} = state$5;
|
|
7605
8972
|
if (!configured) {
|
|
7606
8973
|
// Compatibility with renderer versions that do not assign worker id ranges.
|
|
7607
8974
|
return Math.random();
|
|
@@ -7609,7 +8976,7 @@ const create$8 = () => {
|
|
|
7609
8976
|
if (nextId > lastId) {
|
|
7610
8977
|
throw new Error('Component id range exhausted');
|
|
7611
8978
|
}
|
|
7612
|
-
return state$
|
|
8979
|
+
return state$5.nextId++;
|
|
7613
8980
|
};
|
|
7614
8981
|
|
|
7615
8982
|
const create$7 = () => {
|
|
@@ -7637,7 +9004,7 @@ const create$7 = () => {
|
|
|
7637
9004
|
};
|
|
7638
9005
|
|
|
7639
9006
|
const {
|
|
7640
|
-
invoke: invoke$
|
|
9007
|
+
invoke: invoke$4,
|
|
7641
9008
|
setFactory
|
|
7642
9009
|
} = createLazyRpc(CompletionWorker);
|
|
7643
9010
|
|
|
@@ -7703,7 +9070,7 @@ const updateWidget = (editor, widgetId, newState) => {
|
|
|
7703
9070
|
|
|
7704
9071
|
const disposeCompletion = async uid => {
|
|
7705
9072
|
try {
|
|
7706
|
-
await invoke$
|
|
9073
|
+
await invoke$4('Completions.dispose', uid);
|
|
7707
9074
|
} catch {
|
|
7708
9075
|
// A completion worker may already have disposed this state during shutdown.
|
|
7709
9076
|
}
|
|
@@ -7718,19 +9085,19 @@ const newStateGenerator$4 = async (state, parentUid, markCreated, automatic) =>
|
|
|
7718
9085
|
} = state;
|
|
7719
9086
|
const {
|
|
7720
9087
|
newState
|
|
7721
|
-
} = get$
|
|
9088
|
+
} = get$9(parentUid);
|
|
7722
9089
|
const {
|
|
7723
9090
|
applicationId,
|
|
7724
9091
|
languageId
|
|
7725
9092
|
} = newState;
|
|
7726
|
-
await invoke$
|
|
9093
|
+
await invoke$4('Completions.create', uid, x, y, width, height, parentUid, languageId, applicationId);
|
|
7727
9094
|
markCreated();
|
|
7728
|
-
await invoke$
|
|
7729
|
-
if (automatic && !(await invoke$
|
|
9095
|
+
await invoke$4('Completions.loadContent', uid, automatic);
|
|
9096
|
+
if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
|
|
7730
9097
|
return undefined;
|
|
7731
9098
|
}
|
|
7732
|
-
const diff = await invoke$
|
|
7733
|
-
const commands = await invoke$
|
|
9099
|
+
const diff = await invoke$4('Completions.diff2', uid);
|
|
9100
|
+
const commands = await invoke$4('Completions.render2', uid, diff);
|
|
7734
9101
|
return {
|
|
7735
9102
|
...state,
|
|
7736
9103
|
automatic,
|
|
@@ -7743,15 +9110,15 @@ const openCompletion = async (editor, automatic = false) => {
|
|
|
7743
9110
|
const {
|
|
7744
9111
|
uid
|
|
7745
9112
|
} = widget.newState;
|
|
7746
|
-
await invoke$
|
|
7747
|
-
if (!isCurrent$1(editor, get$
|
|
7748
|
-
return get$
|
|
9113
|
+
await invoke$4('Completions.loadContent', uid, automatic);
|
|
9114
|
+
if (!isCurrent$1(editor, get$9(editor.uid)?.newState)) {
|
|
9115
|
+
return get$9(editor.uid)?.newState || editor;
|
|
7749
9116
|
}
|
|
7750
|
-
if (automatic && !(await invoke$
|
|
9117
|
+
if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
|
|
7751
9118
|
return closeCompletion(editor);
|
|
7752
9119
|
}
|
|
7753
|
-
const diff = await invoke$
|
|
7754
|
-
const commands = await invoke$
|
|
9120
|
+
const diff = await invoke$4('Completions.diff2', uid);
|
|
9121
|
+
const commands = await invoke$4('Completions.render2', uid, diff);
|
|
7755
9122
|
return updateWidget(editor, Completion, {
|
|
7756
9123
|
...widget.newState,
|
|
7757
9124
|
automatic,
|
|
@@ -7777,7 +9144,7 @@ const openCompletion = async (editor, automatic = false) => {
|
|
|
7777
9144
|
const fullFocus = false;
|
|
7778
9145
|
const result = await addWidgetToEditor(Completion, EditorCompletion, editor, create$7, generateState, fullFocus);
|
|
7779
9146
|
const wasAdded = (result?.widgets || []).some(widget => widget.id === Completion && widget.newState.uid === completionUid);
|
|
7780
|
-
const currentEditor = get$
|
|
9147
|
+
const currentEditor = get$9(editor.uid)?.newState;
|
|
7781
9148
|
if (created && (!wasAdded || !isCurrent$1(editor, currentEditor))) {
|
|
7782
9149
|
await disposeCompletion(completionUid);
|
|
7783
9150
|
}
|
|
@@ -8509,7 +9876,7 @@ const normalizeGuess = (line, guess, tabSize) => {
|
|
|
8509
9876
|
}
|
|
8510
9877
|
return normalizedGuess;
|
|
8511
9878
|
};
|
|
8512
|
-
const getAccurateColumnIndex = async (line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, eventX) => {
|
|
9879
|
+
const getAccurateColumnIndex = async (line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, eventX, rtl = false) => {
|
|
8513
9880
|
string(line);
|
|
8514
9881
|
number(fontWeight);
|
|
8515
9882
|
number(fontSize);
|
|
@@ -8520,6 +9887,10 @@ const getAccurateColumnIndex = async (line, fontWeight, fontSize, fontFamily, le
|
|
|
8520
9887
|
number(tabSize);
|
|
8521
9888
|
number(eventX);
|
|
8522
9889
|
// Assert.greaterZero(charWidth)
|
|
9890
|
+
if (isBidi(line, rtl)) {
|
|
9891
|
+
const measure = createMeasure(fontWeight, fontSize, fontFamily, letterSpacing, tabSize, charWidth);
|
|
9892
|
+
return getColumn(line, eventX, measure);
|
|
9893
|
+
}
|
|
8523
9894
|
const guess = guessOffset(eventX, charWidth);
|
|
8524
9895
|
const normalize = shouldNormalizeText(line);
|
|
8525
9896
|
const normalizedGuess = normalizeGuess(line, guess, tabSize);
|
|
@@ -8569,7 +9940,7 @@ const at = async (editor, eventX, eventY) => {
|
|
|
8569
9940
|
const relativeX = Math.max(0, eventX - x - gutterWidth + deltaX);
|
|
8570
9941
|
const clampedRowIndex = clamp(rowIndex, 0, lines.length - 1);
|
|
8571
9942
|
const line = lines[clampedRowIndex];
|
|
8572
|
-
const columnIndex = await getAccurateColumnIndex(line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, relativeX);
|
|
9943
|
+
const columnIndex = await getAccurateColumnIndex(line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, relativeX, editor.rtl);
|
|
8573
9944
|
return {
|
|
8574
9945
|
columnIndex,
|
|
8575
9946
|
rowIndex: clampedRowIndex
|
|
@@ -8601,7 +9972,7 @@ const getCursorX = async (editor, rowIndex, columnIndex) => {
|
|
|
8601
9972
|
width,
|
|
8602
9973
|
x
|
|
8603
9974
|
} = editor;
|
|
8604
|
-
const textX = await getX(lines[rowIndex] || '', columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth);
|
|
9975
|
+
const textX = await getX(lines[rowIndex] || '', columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth, 0, undefined, editor.rtl);
|
|
8605
9976
|
return x + gutterWidth + textX - deltaX;
|
|
8606
9977
|
};
|
|
8607
9978
|
const y = (editor, rowIndex) => {
|
|
@@ -8652,7 +10023,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, _isErro
|
|
|
8652
10023
|
if (typeof editor.uid === 'number') {
|
|
8653
10024
|
const timeout = setTimeout(async () => {
|
|
8654
10025
|
clear$1(editor.uid);
|
|
8655
|
-
const latestInstance = get$
|
|
10026
|
+
const latestInstance = get$9(editor.uid);
|
|
8656
10027
|
if (!latestInstance) {
|
|
8657
10028
|
return;
|
|
8658
10029
|
}
|
|
@@ -8666,10 +10037,10 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, _isErro
|
|
|
8666
10037
|
widgetRevision: next(editor.uid),
|
|
8667
10038
|
widgets: removeEditorWidget(latestEditor.widgets, Message)
|
|
8668
10039
|
};
|
|
8669
|
-
set$
|
|
10040
|
+
set$b(editor.uid, latestEditor, editorWithoutMessage);
|
|
8670
10041
|
await invoke$e('Editor.renderPending', editor.uid);
|
|
8671
10042
|
}, editor.messageDelay ?? defaultMessageDelay);
|
|
8672
|
-
set$
|
|
10043
|
+
set$2(editor.uid, {
|
|
8673
10044
|
timeout
|
|
8674
10045
|
});
|
|
8675
10046
|
}
|
|
@@ -8865,7 +10236,7 @@ const refresh = async request => {
|
|
|
8865
10236
|
}
|
|
8866
10237
|
const gutterDecorations = await getEditorGutterDecorations(snapshot);
|
|
8867
10238
|
const changed = await enqueue(snapshot.uid, async () => {
|
|
8868
|
-
const current = get$
|
|
10239
|
+
const current = get$9(snapshot.uid)?.newState;
|
|
8869
10240
|
if (!isCurrent(current, snapshot) || current.gutterDecorations.length === gutterDecorations.length && gutterDecorations.every((item, index) => item.rowIndex === current.gutterDecorations[index].rowIndex && item.type === current.gutterDecorations[index].type)) {
|
|
8870
10241
|
return false;
|
|
8871
10242
|
}
|
|
@@ -8874,11 +10245,11 @@ const refresh = async request => {
|
|
|
8874
10245
|
gutterDecorations
|
|
8875
10246
|
});
|
|
8876
10247
|
// Derived state may await layout RPCs while an asynchronous render consumes the baseline.
|
|
8877
|
-
const latest = get$
|
|
10248
|
+
const latest = get$9(snapshot.uid);
|
|
8878
10249
|
if (!isCurrent(latest?.newState, snapshot)) {
|
|
8879
10250
|
return false;
|
|
8880
10251
|
}
|
|
8881
|
-
set$
|
|
10252
|
+
set$b(snapshot.uid, latest.oldState, next);
|
|
8882
10253
|
return true;
|
|
8883
10254
|
});
|
|
8884
10255
|
if (changed) {
|
|
@@ -8952,7 +10323,7 @@ const selectionsEqual = (left, right) => {
|
|
|
8952
10323
|
return true;
|
|
8953
10324
|
};
|
|
8954
10325
|
const saveAfterDelay = async (uid, token) => {
|
|
8955
|
-
if (!get$
|
|
10326
|
+
if (!get$9(uid)) {
|
|
8956
10327
|
consume(uid, token);
|
|
8957
10328
|
return;
|
|
8958
10329
|
}
|
|
@@ -8982,7 +10353,7 @@ const saveAfterDelay = async (uid, token) => {
|
|
|
8982
10353
|
const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true) => {
|
|
8983
10354
|
const command = async (uid, ...args) => {
|
|
8984
10355
|
return enqueue(uid, async () => {
|
|
8985
|
-
const oldInstance = get$
|
|
10356
|
+
const oldInstance = get$9(uid);
|
|
8986
10357
|
if (!oldInstance) {
|
|
8987
10358
|
return undefined;
|
|
8988
10359
|
}
|
|
@@ -9026,18 +10397,18 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
9026
10397
|
cursorUndoStack: [...previousCursorUndoStack.slice(1 - cursorUndoLimit), new Uint32Array(selections)]
|
|
9027
10398
|
};
|
|
9028
10399
|
}
|
|
9029
|
-
if (state === newEditor || !get$
|
|
10400
|
+
if (state === newEditor || !get$9(uid) || lifecycle?.disposed || get$9(uid).newState.lifecycle !== lifecycle) {
|
|
9030
10401
|
return returnState ? newEditor : undefined;
|
|
9031
10402
|
}
|
|
9032
10403
|
const deferGutterDecorations = !initial && uri === newEditor.uri && lines !== newEditor.lines && Boolean(newEditor.lifecycle);
|
|
9033
10404
|
const newEditorWithDerivedState = await updateDerivedState(state, newEditor, deferGutterDecorations);
|
|
9034
|
-
if (!get$
|
|
10405
|
+
if (!get$9(uid) || lifecycle?.disposed || get$9(uid).newState.lifecycle !== lifecycle) {
|
|
9035
10406
|
return returnState ? newEditorWithDerivedState : undefined;
|
|
9036
10407
|
}
|
|
9037
10408
|
// Another command can commit before the renderer consumes this edit.
|
|
9038
10409
|
// Keep its last rendered baseline, including renders completed while we awaited derived state.
|
|
9039
|
-
const renderedState = get$
|
|
9040
|
-
set$
|
|
10410
|
+
const renderedState = get$9(uid)?.oldState ?? oldInstance.oldState;
|
|
10411
|
+
set$b(uid, renderedState, newEditorWithDerivedState);
|
|
9041
10412
|
await dispose$3();
|
|
9042
10413
|
if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
|
|
9043
10414
|
void editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
@@ -9050,7 +10421,7 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
9050
10421
|
if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
9051
10422
|
for (const key of getKeys$2()) {
|
|
9052
10423
|
const otherUid = Number(key);
|
|
9053
|
-
const instance = get$
|
|
10424
|
+
const instance = get$9(otherUid);
|
|
9054
10425
|
const editor = instance?.newState;
|
|
9055
10426
|
if (otherUid === uid || !instance || !editor || editor.initial || editor.uri !== finalEditor.uri || editor.applicationId !== finalEditor.applicationId) {
|
|
9056
10427
|
continue;
|
|
@@ -9069,11 +10440,11 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
9069
10440
|
undoStack: finalEditor.undoStack,
|
|
9070
10441
|
visualDecorations: finalEditor.visualDecorations
|
|
9071
10442
|
}, deferGutterDecorations);
|
|
9072
|
-
const latest = get$
|
|
10443
|
+
const latest = get$9(otherUid);
|
|
9073
10444
|
if (!latest || editor.lifecycle?.disposed || latest.newState.lifecycle !== editor.lifecycle) {
|
|
9074
10445
|
continue;
|
|
9075
10446
|
}
|
|
9076
|
-
set$
|
|
10447
|
+
set$b(otherUid, latest.oldState, synchronizedEditor);
|
|
9077
10448
|
if (deferGutterDecorations) {
|
|
9078
10449
|
schedule(synchronizedEditor);
|
|
9079
10450
|
}
|
|
@@ -9104,7 +10475,7 @@ const wrapFocusCommand$1 = (fn, returnState = true) => {
|
|
|
9104
10475
|
}, false, returnState);
|
|
9105
10476
|
const focusCommand = uid => {
|
|
9106
10477
|
// DOM focus events can arrive while a queued command is still opening a widget.
|
|
9107
|
-
const widgetRevision = get$
|
|
10478
|
+
const widgetRevision = get$9(uid)?.newState.widgetRevision;
|
|
9108
10479
|
return command(uid, widgetRevision);
|
|
9109
10480
|
};
|
|
9110
10481
|
return focusCommand;
|
|
@@ -9135,7 +10506,7 @@ const wrapLatestCommand$1 = (fn, returnState = true) => {
|
|
|
9135
10506
|
const wrapDeferredCommand$1 = (fn, returnState = true) => {
|
|
9136
10507
|
const apply = wrapCommand$1((editor, snapshot, result) => merge(editor, snapshot, result), false, returnState);
|
|
9137
10508
|
const deferredCommand = async (uid, ...args) => {
|
|
9138
|
-
const snapshot = await enqueue(uid, async () => get$
|
|
10509
|
+
const snapshot = await enqueue(uid, async () => get$9(uid)?.newState);
|
|
9139
10510
|
if (!snapshot) {
|
|
9140
10511
|
return undefined;
|
|
9141
10512
|
}
|
|
@@ -9194,7 +10565,7 @@ const getOpenEditor = (currentEditor, uri) => {
|
|
|
9194
10565
|
return currentEditor;
|
|
9195
10566
|
}
|
|
9196
10567
|
for (const key of getKeys$2()) {
|
|
9197
|
-
const editor = get$
|
|
10568
|
+
const editor = get$9(Number(key))?.newState;
|
|
9198
10569
|
if (editor && !editor.initial && editor.uri === uri && editor.applicationId === currentEditor.applicationId) {
|
|
9199
10570
|
return editor;
|
|
9200
10571
|
}
|
|
@@ -9215,7 +10586,7 @@ const applyWorkspaceEdit = async (editor, changes) => {
|
|
|
9215
10586
|
currentEditor = await scheduleDocumentAndCursorsSelections(openEditor, textChanges);
|
|
9216
10587
|
} else {
|
|
9217
10588
|
await updateOpenEditor(openEditor.uid, textChanges);
|
|
9218
|
-
await invoke$
|
|
10589
|
+
await invoke$7('Editor.renderPending', openEditor.uid);
|
|
9219
10590
|
}
|
|
9220
10591
|
continue;
|
|
9221
10592
|
}
|
|
@@ -9698,8 +11069,8 @@ const closeRename = async editor => {
|
|
|
9698
11069
|
return editor;
|
|
9699
11070
|
}
|
|
9700
11071
|
const renameWidget = widgets[renameWidgetIndex];
|
|
9701
|
-
await invoke$
|
|
9702
|
-
const latest = get$
|
|
11072
|
+
await invoke$5('Rename.close', renameWidget.newState.uid);
|
|
11073
|
+
const latest = get$9(uid);
|
|
9703
11074
|
const {
|
|
9704
11075
|
newState
|
|
9705
11076
|
} = latest;
|
|
@@ -9818,12 +11189,12 @@ const closeColorPicker = editor => {
|
|
|
9818
11189
|
};
|
|
9819
11190
|
};
|
|
9820
11191
|
|
|
9821
|
-
const state$
|
|
11192
|
+
const state$4 = {
|
|
9822
11193
|
compositionText: '',
|
|
9823
11194
|
isComposing: false
|
|
9824
11195
|
};
|
|
9825
11196
|
const compositionStart = (editor, event) => {
|
|
9826
|
-
state$
|
|
11197
|
+
state$4.isComposing = true;
|
|
9827
11198
|
return editor;
|
|
9828
11199
|
};
|
|
9829
11200
|
const getCompositionChanges = (selections, data) => {
|
|
@@ -9833,9 +11204,9 @@ const getCompositionChanges = (selections, data) => {
|
|
|
9833
11204
|
const selectionStartColumn = selections[i + 1];
|
|
9834
11205
|
const selectionEndRow = selections[i + 2];
|
|
9835
11206
|
const selectionEndColumn = selections[i + 3];
|
|
9836
|
-
const startColumnIndex = selectionStartColumn - state$
|
|
11207
|
+
const startColumnIndex = selectionStartColumn - state$4.compositionText.length;
|
|
9837
11208
|
changes.push({
|
|
9838
|
-
deleted: [state$
|
|
11209
|
+
deleted: [state$4.compositionText],
|
|
9839
11210
|
end: {
|
|
9840
11211
|
columnIndex: selectionEndColumn,
|
|
9841
11212
|
rowIndex: selectionEndRow
|
|
@@ -9855,7 +11226,7 @@ const compositionUpdate = (editor, data) => {
|
|
|
9855
11226
|
selections
|
|
9856
11227
|
} = editor;
|
|
9857
11228
|
const changes = getCompositionChanges(selections, data);
|
|
9858
|
-
state$
|
|
11229
|
+
state$4.compositionText = data;
|
|
9859
11230
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9860
11231
|
};
|
|
9861
11232
|
const compositionEnd = (editor, data) => {
|
|
@@ -9863,8 +11234,8 @@ const compositionEnd = (editor, data) => {
|
|
|
9863
11234
|
selections
|
|
9864
11235
|
} = editor;
|
|
9865
11236
|
const changes = getCompositionChanges(selections, data);
|
|
9866
|
-
state$
|
|
9867
|
-
state$
|
|
11237
|
+
state$4.isComposing = false;
|
|
11238
|
+
state$4.compositionText = '';
|
|
9868
11239
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9869
11240
|
};
|
|
9870
11241
|
|
|
@@ -9954,153 +11325,69 @@ const getCopyLineOperations = selections => {
|
|
|
9954
11325
|
}
|
|
9955
11326
|
return mergedOperations;
|
|
9956
11327
|
};
|
|
9957
|
-
const copyLineDown = async editor => {
|
|
9958
|
-
const {
|
|
9959
|
-
selections
|
|
9960
|
-
} = editor;
|
|
9961
|
-
const operations = getCopyLineOperations(selections);
|
|
9962
|
-
const changes = operations.map(({
|
|
9963
|
-
endRowIndex,
|
|
9964
|
-
startRowIndex
|
|
9965
|
-
}) => {
|
|
9966
|
-
const selectedLines = editor.lines.slice(startRowIndex, endRowIndex + 1);
|
|
9967
|
-
return {
|
|
9968
|
-
deleted: selectedLines,
|
|
9969
|
-
end: {
|
|
9970
|
-
columnIndex: editor.lines[endRowIndex].length,
|
|
9971
|
-
rowIndex: endRowIndex
|
|
9972
|
-
},
|
|
9973
|
-
inserted: [...selectedLines, ...selectedLines],
|
|
9974
|
-
start: {
|
|
9975
|
-
columnIndex: 0,
|
|
9976
|
-
rowIndex: startRowIndex
|
|
9977
|
-
}
|
|
9978
|
-
};
|
|
9979
|
-
});
|
|
9980
|
-
const getRowOffset = rowIndex => {
|
|
9981
|
-
let offset = 0;
|
|
9982
|
-
for (const operation of operations) {
|
|
9983
|
-
if (operation.startRowIndex <= rowIndex) {
|
|
9984
|
-
offset += operation.endRowIndex - operation.startRowIndex + 1;
|
|
9985
|
-
}
|
|
9986
|
-
}
|
|
9987
|
-
return offset;
|
|
9988
|
-
};
|
|
9989
|
-
const selectionChanges = new Uint32Array(selections.length);
|
|
9990
|
-
for (let i = 0; i < selections.length; i += 4) {
|
|
9991
|
-
selectionChanges[i] = selections[i] + getRowOffset(selections[i]);
|
|
9992
|
-
selectionChanges[i + 1] = selections[i + 1];
|
|
9993
|
-
selectionChanges[i + 2] = selections[i + 2] + getRowOffset(selections[i + 2]);
|
|
9994
|
-
selectionChanges[i + 3] = selections[i + 3];
|
|
9995
|
-
}
|
|
9996
|
-
const newEditor = await scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
9997
|
-
return typeof newEditor.finalDeltaY === 'number' ? scheduleSelections(newEditor, selectionChanges) : newEditor;
|
|
9998
|
-
};
|
|
9999
|
-
|
|
10000
|
-
const copyLineUp = editor => {
|
|
10001
|
-
const {
|
|
10002
|
-
selections
|
|
10003
|
-
} = editor;
|
|
10004
|
-
const rowIndex = selections[0];
|
|
10005
|
-
const position = {
|
|
10006
|
-
columnIndex: 0,
|
|
10007
|
-
rowIndex: rowIndex
|
|
10008
|
-
};
|
|
10009
|
-
const changes = [{
|
|
10010
|
-
deleted: [''],
|
|
10011
|
-
end: position,
|
|
10012
|
-
inserted: [getLine$1(editor, rowIndex), ''],
|
|
10013
|
-
start: position
|
|
10014
|
-
}];
|
|
10015
|
-
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
10016
|
-
};
|
|
10017
|
-
|
|
10018
|
-
const getLineLength = line => {
|
|
10019
|
-
return line.endsWith('\r') ? line.length - 1 : line.length;
|
|
10020
|
-
};
|
|
10021
|
-
|
|
10022
|
-
// @ts-ignore
|
|
10023
|
-
const editorGetPositionLeft = (rowIndex, columnIndex, lines, getDelta) => {
|
|
10024
|
-
if (columnIndex === 0) {
|
|
10025
|
-
if (rowIndex === 0) {
|
|
10026
|
-
return {
|
|
10027
|
-
columnIndex: 0,
|
|
10028
|
-
rowIndex: 0
|
|
10029
|
-
};
|
|
10030
|
-
}
|
|
10031
|
-
return {
|
|
10032
|
-
columnIndex: getLineLength(lines[rowIndex - 1]),
|
|
10033
|
-
rowIndex: rowIndex - 1
|
|
10034
|
-
};
|
|
10035
|
-
}
|
|
10036
|
-
const delta = getDelta(lines[rowIndex], columnIndex);
|
|
10037
|
-
return {
|
|
10038
|
-
columnIndex: columnIndex - delta,
|
|
10039
|
-
rowIndex
|
|
10040
|
-
};
|
|
10041
|
-
};
|
|
10042
|
-
|
|
10043
|
-
// @ts-ignore
|
|
10044
|
-
const moveToPositionEqual = (selections, i, rowIndex, columnIndex) => {
|
|
10045
|
-
selections[i] = rowIndex;
|
|
10046
|
-
selections[i + 1] = columnIndex;
|
|
10047
|
-
};
|
|
10048
|
-
|
|
10049
|
-
// @ts-ignore
|
|
10050
|
-
const moveRangeToPosition = (selections, i, rowIndex, columnIndex) => {
|
|
10051
|
-
selections[i] = selections[i + 2] = rowIndex;
|
|
10052
|
-
selections[i + 1] = selections[i + 3] = columnIndex;
|
|
10053
|
-
};
|
|
10054
|
-
|
|
10055
|
-
// @ts-ignore
|
|
10056
|
-
const moveToPositionLeft = (selections, i, rowIndex, columnIndex, lines, getDelta) => {
|
|
10057
|
-
if (columnIndex === 0) {
|
|
10058
|
-
if (rowIndex === 0) {
|
|
10059
|
-
selections[i] = 0;
|
|
10060
|
-
selections[i + 1] = 0;
|
|
10061
|
-
} else {
|
|
10062
|
-
selections[i] = rowIndex - 1;
|
|
10063
|
-
selections[i + 1] = getLineLength(lines[rowIndex - 1]);
|
|
10064
|
-
}
|
|
10065
|
-
} else {
|
|
10066
|
-
const delta = getDelta(lines[rowIndex], columnIndex);
|
|
10067
|
-
selections[i] = rowIndex;
|
|
10068
|
-
selections[i + 1] = columnIndex - delta;
|
|
10069
|
-
}
|
|
10070
|
-
};
|
|
10071
|
-
|
|
10072
|
-
// @ts-ignore
|
|
10073
|
-
|
|
10074
|
-
// @ts-ignore
|
|
10075
|
-
const getNewSelections$a = (selections, lines, getDelta) => {
|
|
10076
|
-
const newSelections = new Uint32Array(selections.length);
|
|
10077
|
-
for (let i = 0; i < selections.length; i += 4) {
|
|
10078
|
-
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
10079
|
-
if (selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn) {
|
|
10080
|
-
if (selectionStartRow === 0 && selectionStartColumn === 0) {
|
|
10081
|
-
newSelections[i] = 0;
|
|
10082
|
-
newSelections[i + 1] = 0;
|
|
10083
|
-
newSelections[i + 2] = 0;
|
|
10084
|
-
newSelections[i + 3] = 0;
|
|
10085
|
-
} else {
|
|
10086
|
-
moveToPositionLeft(newSelections, i, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
10087
|
-
moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
11328
|
+
const copyLineDown = async editor => {
|
|
11329
|
+
const {
|
|
11330
|
+
selections
|
|
11331
|
+
} = editor;
|
|
11332
|
+
const operations = getCopyLineOperations(selections);
|
|
11333
|
+
const changes = operations.map(({
|
|
11334
|
+
endRowIndex,
|
|
11335
|
+
startRowIndex
|
|
11336
|
+
}) => {
|
|
11337
|
+
const selectedLines = editor.lines.slice(startRowIndex, endRowIndex + 1);
|
|
11338
|
+
return {
|
|
11339
|
+
deleted: selectedLines,
|
|
11340
|
+
end: {
|
|
11341
|
+
columnIndex: editor.lines[endRowIndex].length,
|
|
11342
|
+
rowIndex: endRowIndex
|
|
11343
|
+
},
|
|
11344
|
+
inserted: [...selectedLines, ...selectedLines],
|
|
11345
|
+
start: {
|
|
11346
|
+
columnIndex: 0,
|
|
11347
|
+
rowIndex: startRowIndex
|
|
11348
|
+
}
|
|
11349
|
+
};
|
|
11350
|
+
});
|
|
11351
|
+
const getRowOffset = rowIndex => {
|
|
11352
|
+
let offset = 0;
|
|
11353
|
+
for (const operation of operations) {
|
|
11354
|
+
if (operation.startRowIndex <= rowIndex) {
|
|
11355
|
+
offset += operation.endRowIndex - operation.startRowIndex + 1;
|
|
10088
11356
|
}
|
|
10089
|
-
} else {
|
|
10090
|
-
moveRangeToPosition(newSelections, i, selections[i], selections[i + 1]);
|
|
10091
11357
|
}
|
|
11358
|
+
return offset;
|
|
11359
|
+
};
|
|
11360
|
+
const selectionChanges = new Uint32Array(selections.length);
|
|
11361
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
11362
|
+
selectionChanges[i] = selections[i] + getRowOffset(selections[i]);
|
|
11363
|
+
selectionChanges[i + 1] = selections[i + 1];
|
|
11364
|
+
selectionChanges[i + 2] = selections[i + 2] + getRowOffset(selections[i + 2]);
|
|
11365
|
+
selectionChanges[i + 3] = selections[i + 3];
|
|
10092
11366
|
}
|
|
10093
|
-
|
|
11367
|
+
const newEditor = await scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
11368
|
+
return typeof newEditor.finalDeltaY === 'number' ? scheduleSelections(newEditor, selectionChanges) : newEditor;
|
|
10094
11369
|
};
|
|
10095
11370
|
|
|
10096
|
-
|
|
10097
|
-
const editorCursorHorizontalLeft = (editor, getDelta) => {
|
|
11371
|
+
const copyLineUp = editor => {
|
|
10098
11372
|
const {
|
|
10099
|
-
lines,
|
|
10100
11373
|
selections
|
|
10101
11374
|
} = editor;
|
|
10102
|
-
const
|
|
10103
|
-
|
|
11375
|
+
const rowIndex = selections[0];
|
|
11376
|
+
const position = {
|
|
11377
|
+
columnIndex: 0,
|
|
11378
|
+
rowIndex: rowIndex
|
|
11379
|
+
};
|
|
11380
|
+
const changes = [{
|
|
11381
|
+
deleted: [''],
|
|
11382
|
+
end: position,
|
|
11383
|
+
inserted: [getLine$1(editor, rowIndex), ''],
|
|
11384
|
+
start: position
|
|
11385
|
+
}];
|
|
11386
|
+
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
11387
|
+
};
|
|
11388
|
+
|
|
11389
|
+
const getLineLength = line => {
|
|
11390
|
+
return line.endsWith('\r') ? line.length - 1 : line.length;
|
|
10104
11391
|
};
|
|
10105
11392
|
|
|
10106
11393
|
/* eslint-disable sonarjs/super-linear-regex */
|
|
@@ -10214,7 +11501,161 @@ const wordPartRight = (line, columnIndex) => {
|
|
|
10214
11501
|
return tryRegexArray(partialLine, ARRAY_PARTIAL_WORD_RIGHT_2);
|
|
10215
11502
|
};
|
|
10216
11503
|
|
|
11504
|
+
const moveBidiCharacter = (editor, direction, extend = false) => {
|
|
11505
|
+
const {
|
|
11506
|
+
lines,
|
|
11507
|
+
selections
|
|
11508
|
+
} = editor;
|
|
11509
|
+
if (!editor.rtl) {
|
|
11510
|
+
return undefined;
|
|
11511
|
+
}
|
|
11512
|
+
let relevant = false;
|
|
11513
|
+
for (let i = 0; i < selections.length; i += 2) {
|
|
11514
|
+
const row = selections[i];
|
|
11515
|
+
if ([row - 1, row, row + 1].some(index => isBidi(lines[index] || '', true))) {
|
|
11516
|
+
relevant = true;
|
|
11517
|
+
break;
|
|
11518
|
+
}
|
|
11519
|
+
}
|
|
11520
|
+
if (!relevant) {
|
|
11521
|
+
return undefined;
|
|
11522
|
+
}
|
|
11523
|
+
const result = new Uint32Array(selections);
|
|
11524
|
+
const getColumns = row => getVisualColumns(lines[row]);
|
|
11525
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
11526
|
+
let row = selections[i + 2];
|
|
11527
|
+
let column = selections[i + 3];
|
|
11528
|
+
const [startRow, startColumn, endRow, endColumn] = getSelectionPairs(selections, i);
|
|
11529
|
+
if (!extend && (startRow !== endRow || startColumn !== endColumn)) {
|
|
11530
|
+
row = direction === -1 ? startRow : endRow;
|
|
11531
|
+
column = direction === -1 ? startColumn : endColumn;
|
|
11532
|
+
if (startRow === endRow && isBidi(lines[row], true)) {
|
|
11533
|
+
const columns = getColumns(row);
|
|
11534
|
+
const selectedColumns = columns.filter(value => value >= startColumn && value <= endColumn);
|
|
11535
|
+
column = direction === -1 ? selectedColumns[0] : selectedColumns.at(-1);
|
|
11536
|
+
}
|
|
11537
|
+
} else {
|
|
11538
|
+
const line = lines[row];
|
|
11539
|
+
if (isBidi(line, true)) {
|
|
11540
|
+
const columns = getColumns(row);
|
|
11541
|
+
const index = columns.indexOf(column);
|
|
11542
|
+
const next = index + direction;
|
|
11543
|
+
if (next >= 0 && next < columns.length) {
|
|
11544
|
+
column = columns[next];
|
|
11545
|
+
} else if (row + direction >= 0 && row + direction < lines.length) {
|
|
11546
|
+
row += direction;
|
|
11547
|
+
const nextColumns = getColumns(row);
|
|
11548
|
+
column = direction === -1 ? nextColumns.at(-1) : nextColumns[0];
|
|
11549
|
+
}
|
|
11550
|
+
} else if (direction === -1 && column > 0) {
|
|
11551
|
+
column -= characterLeft(line, column);
|
|
11552
|
+
} else if (direction === 1 && column < line.length) {
|
|
11553
|
+
column += characterRight(line, column);
|
|
11554
|
+
} else if (row + direction >= 0 && row + direction < lines.length) {
|
|
11555
|
+
row += direction;
|
|
11556
|
+
const columns = getColumns(row);
|
|
11557
|
+
column = direction === -1 ? columns.at(-1) : columns[0];
|
|
11558
|
+
}
|
|
11559
|
+
}
|
|
11560
|
+
if (!extend) {
|
|
11561
|
+
result[i] = row;
|
|
11562
|
+
result[i + 1] = column;
|
|
11563
|
+
}
|
|
11564
|
+
result[i + 2] = row;
|
|
11565
|
+
result[i + 3] = column;
|
|
11566
|
+
}
|
|
11567
|
+
return scheduleSelections(editor, result);
|
|
11568
|
+
};
|
|
11569
|
+
|
|
11570
|
+
// @ts-ignore
|
|
11571
|
+
const editorGetPositionLeft = (rowIndex, columnIndex, lines, getDelta) => {
|
|
11572
|
+
if (columnIndex === 0) {
|
|
11573
|
+
if (rowIndex === 0) {
|
|
11574
|
+
return {
|
|
11575
|
+
columnIndex: 0,
|
|
11576
|
+
rowIndex: 0
|
|
11577
|
+
};
|
|
11578
|
+
}
|
|
11579
|
+
return {
|
|
11580
|
+
columnIndex: getLineLength(lines[rowIndex - 1]),
|
|
11581
|
+
rowIndex: rowIndex - 1
|
|
11582
|
+
};
|
|
11583
|
+
}
|
|
11584
|
+
const delta = getDelta(lines[rowIndex], columnIndex);
|
|
11585
|
+
return {
|
|
11586
|
+
columnIndex: columnIndex - delta,
|
|
11587
|
+
rowIndex
|
|
11588
|
+
};
|
|
11589
|
+
};
|
|
11590
|
+
|
|
11591
|
+
// @ts-ignore
|
|
11592
|
+
const moveToPositionEqual = (selections, i, rowIndex, columnIndex) => {
|
|
11593
|
+
selections[i] = rowIndex;
|
|
11594
|
+
selections[i + 1] = columnIndex;
|
|
11595
|
+
};
|
|
11596
|
+
|
|
11597
|
+
// @ts-ignore
|
|
11598
|
+
const moveRangeToPosition = (selections, i, rowIndex, columnIndex) => {
|
|
11599
|
+
selections[i] = selections[i + 2] = rowIndex;
|
|
11600
|
+
selections[i + 1] = selections[i + 3] = columnIndex;
|
|
11601
|
+
};
|
|
11602
|
+
|
|
11603
|
+
// @ts-ignore
|
|
11604
|
+
const moveToPositionLeft = (selections, i, rowIndex, columnIndex, lines, getDelta) => {
|
|
11605
|
+
if (columnIndex === 0) {
|
|
11606
|
+
if (rowIndex === 0) {
|
|
11607
|
+
selections[i] = 0;
|
|
11608
|
+
selections[i + 1] = 0;
|
|
11609
|
+
} else {
|
|
11610
|
+
selections[i] = rowIndex - 1;
|
|
11611
|
+
selections[i + 1] = getLineLength(lines[rowIndex - 1]);
|
|
11612
|
+
}
|
|
11613
|
+
} else {
|
|
11614
|
+
const delta = getDelta(lines[rowIndex], columnIndex);
|
|
11615
|
+
selections[i] = rowIndex;
|
|
11616
|
+
selections[i + 1] = columnIndex - delta;
|
|
11617
|
+
}
|
|
11618
|
+
};
|
|
11619
|
+
|
|
11620
|
+
// @ts-ignore
|
|
11621
|
+
|
|
11622
|
+
// @ts-ignore
|
|
11623
|
+
const getNewSelections$a = (selections, lines, getDelta) => {
|
|
11624
|
+
const newSelections = new Uint32Array(selections.length);
|
|
11625
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
11626
|
+
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
11627
|
+
if (selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn) {
|
|
11628
|
+
if (selectionStartRow === 0 && selectionStartColumn === 0) {
|
|
11629
|
+
newSelections[i] = 0;
|
|
11630
|
+
newSelections[i + 1] = 0;
|
|
11631
|
+
newSelections[i + 2] = 0;
|
|
11632
|
+
newSelections[i + 3] = 0;
|
|
11633
|
+
} else {
|
|
11634
|
+
moveToPositionLeft(newSelections, i, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
11635
|
+
moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
11636
|
+
}
|
|
11637
|
+
} else {
|
|
11638
|
+
moveRangeToPosition(newSelections, i, selections[i], selections[i + 1]);
|
|
11639
|
+
}
|
|
11640
|
+
}
|
|
11641
|
+
return newSelections;
|
|
11642
|
+
};
|
|
11643
|
+
|
|
11644
|
+
// @ts-ignore
|
|
11645
|
+
const editorCursorHorizontalLeft = (editor, getDelta) => {
|
|
11646
|
+
const {
|
|
11647
|
+
lines,
|
|
11648
|
+
selections
|
|
11649
|
+
} = editor;
|
|
11650
|
+
const newSelections = getNewSelections$a(selections, lines, getDelta);
|
|
11651
|
+
return scheduleSelections(editor, newSelections);
|
|
11652
|
+
};
|
|
11653
|
+
|
|
10217
11654
|
const cursorCharacterLeft = editor => {
|
|
11655
|
+
const bidi = moveBidiCharacter(editor, -1, false);
|
|
11656
|
+
if (bidi) {
|
|
11657
|
+
return bidi;
|
|
11658
|
+
}
|
|
10218
11659
|
return editorCursorHorizontalLeft(editor, characterLeft);
|
|
10219
11660
|
};
|
|
10220
11661
|
|
|
@@ -10280,6 +11721,10 @@ const editorCursorHorizontalRight = (editor, getDelta) => {
|
|
|
10280
11721
|
};
|
|
10281
11722
|
|
|
10282
11723
|
const cursorCharacterRight = editor => {
|
|
11724
|
+
const bidi = moveBidiCharacter(editor, 1, false);
|
|
11725
|
+
if (bidi) {
|
|
11726
|
+
return bidi;
|
|
11727
|
+
}
|
|
10283
11728
|
return editorCursorHorizontalRight(editor, characterRight);
|
|
10284
11729
|
};
|
|
10285
11730
|
|
|
@@ -11553,7 +12998,7 @@ const clear = editor => {
|
|
|
11553
12998
|
decorations: filtered
|
|
11554
12999
|
};
|
|
11555
13000
|
};
|
|
11556
|
-
const set
|
|
13001
|
+
const set = (editor, offset, length) => {
|
|
11557
13002
|
if (matches(editor, offset, length)) {
|
|
11558
13003
|
return editor;
|
|
11559
13004
|
}
|
|
@@ -11713,7 +13158,7 @@ const editorHoverDismissDelay = 500;
|
|
|
11713
13158
|
const handleMouseLeave = (viewletUid, editorUidValue) => {
|
|
11714
13159
|
const targetEditorUid = editorUidValue ?? viewletUid;
|
|
11715
13160
|
const editorUid = Number(targetEditorUid);
|
|
11716
|
-
const instance = get$
|
|
13161
|
+
const instance = get$9(editorUid);
|
|
11717
13162
|
if (!instance) {
|
|
11718
13163
|
return;
|
|
11719
13164
|
}
|
|
@@ -11728,7 +13173,7 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
|
|
|
11728
13173
|
}
|
|
11729
13174
|
const timeout = setTimeout(async () => {
|
|
11730
13175
|
clear$3(editorUid);
|
|
11731
|
-
const latestInstance = get$
|
|
13176
|
+
const latestInstance = get$9(editorUid);
|
|
11732
13177
|
if (!latestInstance) {
|
|
11733
13178
|
return;
|
|
11734
13179
|
}
|
|
@@ -11745,10 +13190,10 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
|
|
|
11745
13190
|
widgetRevision: next(editorUid),
|
|
11746
13191
|
widgets: removeEditorWidget(latestEditor.widgets, Hover)
|
|
11747
13192
|
};
|
|
11748
|
-
set$
|
|
13193
|
+
set$b(editorUid, latestEditor, newEditor);
|
|
11749
13194
|
await invoke$e('Editor.renderPending', editorUid);
|
|
11750
13195
|
}, editorHoverDismissDelay);
|
|
11751
|
-
set$
|
|
13196
|
+
set$4(editorUid, {
|
|
11752
13197
|
timeout
|
|
11753
13198
|
});
|
|
11754
13199
|
};
|
|
@@ -11818,7 +13263,7 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
|
|
|
11818
13263
|
if (!definition) {
|
|
11819
13264
|
return clear(editor);
|
|
11820
13265
|
}
|
|
11821
|
-
return set
|
|
13266
|
+
return set(editor, wordOffset, wordLength);
|
|
11822
13267
|
} catch (error) {
|
|
11823
13268
|
if (isNoDefinitionProviderFoundError(error)) {
|
|
11824
13269
|
return clear(editor);
|
|
@@ -11937,10 +13382,10 @@ const getHover = async (editor, offset) => {
|
|
|
11937
13382
|
};
|
|
11938
13383
|
|
|
11939
13384
|
const getVirtualDomFromMarkdown = async markdown => {
|
|
11940
|
-
const html = await invoke$
|
|
13385
|
+
const html = await invoke$7('Markdown.renderMarkdown', markdown, {
|
|
11941
13386
|
linksExternal: true
|
|
11942
13387
|
});
|
|
11943
|
-
return invoke$
|
|
13388
|
+
return invoke$7('Markdown.getVirtualDom', html);
|
|
11944
13389
|
};
|
|
11945
13390
|
|
|
11946
13391
|
const getLineInfo = (line, tokens, TokenMap) => {
|
|
@@ -12008,7 +13453,7 @@ const hoverWidth = 600;
|
|
|
12008
13453
|
const hoverDocumentationWidth = hoverWidth - 18;
|
|
12009
13454
|
const getEditorHoverInfo = async (editorUid, position) => {
|
|
12010
13455
|
number(editorUid);
|
|
12011
|
-
const instance = get$
|
|
13456
|
+
const instance = get$9(editorUid);
|
|
12012
13457
|
const editor = instance.newState;
|
|
12013
13458
|
const {
|
|
12014
13459
|
selections
|
|
@@ -12142,7 +13587,7 @@ const showDiagnostic = async (editor, diagnostic) => {
|
|
|
12142
13587
|
};
|
|
12143
13588
|
|
|
12144
13589
|
const showHover = async (editor, position, token) => {
|
|
12145
|
-
const instance = get$
|
|
13590
|
+
const instance = get$9(editor.uid);
|
|
12146
13591
|
if (!instance) {
|
|
12147
13592
|
return;
|
|
12148
13593
|
}
|
|
@@ -12151,11 +13596,11 @@ const showHover = async (editor, position, token) => {
|
|
|
12151
13596
|
return;
|
|
12152
13597
|
}
|
|
12153
13598
|
const newEditor = await showHover$1(latestEditor, position);
|
|
12154
|
-
const latestInstance = get$
|
|
13599
|
+
const latestInstance = get$9(editor.uid);
|
|
12155
13600
|
if (latestEditor === newEditor || !latestInstance || latestInstance.newState !== latestEditor || get$2().token !== token) {
|
|
12156
13601
|
return;
|
|
12157
13602
|
}
|
|
12158
|
-
set$
|
|
13603
|
+
set$b(editor.uid, latestInstance.oldState, newEditor);
|
|
12159
13604
|
await invoke$e('Editor.renderPending', editor.uid);
|
|
12160
13605
|
};
|
|
12161
13606
|
|
|
@@ -12178,7 +13623,7 @@ const onHoverIdle = async token => {
|
|
|
12178
13623
|
if (latestToken !== token || !editor) {
|
|
12179
13624
|
return;
|
|
12180
13625
|
}
|
|
12181
|
-
const instance = get$
|
|
13626
|
+
const instance = get$9(editor.uid);
|
|
12182
13627
|
if (!instance || !instance.newState.hoverEnabled) {
|
|
12183
13628
|
return;
|
|
12184
13629
|
}
|
|
@@ -12199,7 +13644,7 @@ const handleMouseMove = async (editor, x, y, altKey) => {
|
|
|
12199
13644
|
}
|
|
12200
13645
|
const token = create$8();
|
|
12201
13646
|
const timeout = setTimeout(onHoverIdle, editorWithoutDefinitionLink.hoverDelay ?? 200, token);
|
|
12202
|
-
set$
|
|
13647
|
+
set$3(editorWithoutDefinitionLink, timeout, x, y, token);
|
|
12203
13648
|
return editorWithoutDefinitionLink;
|
|
12204
13649
|
};
|
|
12205
13650
|
|
|
@@ -12406,20 +13851,20 @@ const advanceSelectionAutoScroll = async editor => {
|
|
|
12406
13851
|
return editorMoveSelection(scrolledEditor, position, false);
|
|
12407
13852
|
};
|
|
12408
13853
|
const continueScrollingAndMovingSelection = async editorUid => {
|
|
12409
|
-
const editor = get$
|
|
13854
|
+
const editor = get$9(editorUid)?.newState;
|
|
12410
13855
|
if (!editor?.isSelecting || !editor.hasListener) {
|
|
12411
13856
|
return;
|
|
12412
13857
|
}
|
|
12413
13858
|
const nextEditor = await advanceSelectionAutoScroll(editor);
|
|
12414
13859
|
const derivedEditor = await updateDerivedState(editor, nextEditor);
|
|
12415
|
-
const currentEditor = get$
|
|
13860
|
+
const currentEditor = get$9(editorUid)?.newState;
|
|
12416
13861
|
if (currentEditor !== editor) {
|
|
12417
13862
|
if (currentEditor?.isSelecting && currentEditor.hasListener) {
|
|
12418
13863
|
requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
|
|
12419
13864
|
}
|
|
12420
13865
|
return;
|
|
12421
13866
|
}
|
|
12422
|
-
set$
|
|
13867
|
+
set$b(editor.uid, editor, derivedEditor);
|
|
12423
13868
|
await invoke$e('Editor.renderPending', editor.uid);
|
|
12424
13869
|
if (derivedEditor.hasListener) {
|
|
12425
13870
|
requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
|
|
@@ -12698,7 +14143,7 @@ const handleTouchEnd = (editor, touchEvent) => {
|
|
|
12698
14143
|
// }
|
|
12699
14144
|
};
|
|
12700
14145
|
|
|
12701
|
-
const state$
|
|
14146
|
+
const state$3 = {
|
|
12702
14147
|
deltaY: 0,
|
|
12703
14148
|
touchOffsetY: 0
|
|
12704
14149
|
};
|
|
@@ -12709,8 +14154,8 @@ const handleTouchStart = (editor, touchEvent) => {
|
|
|
12709
14154
|
return;
|
|
12710
14155
|
}
|
|
12711
14156
|
const firstTouch = touchEvent.touches[0];
|
|
12712
|
-
state$
|
|
12713
|
-
state$
|
|
14157
|
+
state$3.touchOffsetY = firstTouch.y;
|
|
14158
|
+
state$3.deltaY = editor.deltaY;
|
|
12714
14159
|
// const position = EditorPosition.at(editor, firstTouch.x, firstTouch.y)
|
|
12715
14160
|
// EditorMoveSelection.state.position = position
|
|
12716
14161
|
// state.date = Date.now()
|
|
@@ -12750,7 +14195,7 @@ const handleTouchMove = (editor, touchEvent) => {
|
|
|
12750
14195
|
return;
|
|
12751
14196
|
}
|
|
12752
14197
|
const firstTouch = touchEvent.touches[0];
|
|
12753
|
-
const offsetY = state$
|
|
14198
|
+
const offsetY = state$3.deltaY + (state$3.touchOffsetY - firstTouch.y);
|
|
12754
14199
|
setDeltaYFixedValue(editor, offsetY);
|
|
12755
14200
|
};
|
|
12756
14201
|
|
|
@@ -13132,7 +14577,7 @@ const updateEditor = async (editorUid, editor, newEditor) => {
|
|
|
13132
14577
|
return;
|
|
13133
14578
|
}
|
|
13134
14579
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
13135
|
-
set$
|
|
14580
|
+
set$b(editorUid, editor, newEditorWithDerivedState);
|
|
13136
14581
|
};
|
|
13137
14582
|
const applyDocumentEdits = async (editorUid, edits) => {
|
|
13138
14583
|
const editor = getEditor$1(editorUid);
|
|
@@ -13178,18 +14623,18 @@ const launchFindWidgetWorker = async () => {
|
|
|
13178
14623
|
const rpcId = 9002;
|
|
13179
14624
|
const launch = async () => {
|
|
13180
14625
|
// TODO race condition
|
|
13181
|
-
if (get$
|
|
14626
|
+
if (get$a(rpcId)) {
|
|
13182
14627
|
return;
|
|
13183
14628
|
}
|
|
13184
14629
|
const rpc = await launchFindWidgetWorker();
|
|
13185
|
-
set$
|
|
14630
|
+
set$l(rpcId, rpc);
|
|
13186
14631
|
};
|
|
13187
|
-
const invoke$
|
|
13188
|
-
const rpc = get$
|
|
14632
|
+
const invoke$3 = async (method, ...params) => {
|
|
14633
|
+
const rpc = get$a(rpcId);
|
|
13189
14634
|
return await rpc.invoke(method, ...params);
|
|
13190
14635
|
};
|
|
13191
14636
|
const dispose = async () => {
|
|
13192
|
-
const rpc = get$
|
|
14637
|
+
const rpc = get$a(rpcId);
|
|
13193
14638
|
remove$8(rpcId);
|
|
13194
14639
|
if (rpc) {
|
|
13195
14640
|
await rpc.dispose();
|
|
@@ -13208,14 +14653,14 @@ const launchHoverWorker = async () => {
|
|
|
13208
14653
|
return rpc;
|
|
13209
14654
|
};
|
|
13210
14655
|
|
|
13211
|
-
const state$
|
|
14656
|
+
const state$2 = {};
|
|
13212
14657
|
const getOrCreate$1 = () => {
|
|
13213
|
-
if (!state$
|
|
13214
|
-
state$
|
|
14658
|
+
if (!state$2.workerPromise) {
|
|
14659
|
+
state$2.workerPromise = launchHoverWorker();
|
|
13215
14660
|
}
|
|
13216
|
-
return state$
|
|
14661
|
+
return state$2.workerPromise;
|
|
13217
14662
|
};
|
|
13218
|
-
const invoke$
|
|
14663
|
+
const invoke$2 = async (method, ...params) => {
|
|
13219
14664
|
const worker = await getOrCreate$1();
|
|
13220
14665
|
return await worker.invoke(method, ...params);
|
|
13221
14666
|
};
|
|
@@ -13228,14 +14673,14 @@ const launchSourceActionWorker = async () => {
|
|
|
13228
14673
|
return rpc;
|
|
13229
14674
|
};
|
|
13230
14675
|
|
|
13231
|
-
const state$
|
|
14676
|
+
const state$1 = {};
|
|
13232
14677
|
const getOrCreate = () => {
|
|
13233
|
-
if (!state$
|
|
13234
|
-
state$
|
|
14678
|
+
if (!state$1.workerPromise) {
|
|
14679
|
+
state$1.workerPromise = launchSourceActionWorker();
|
|
13235
14680
|
}
|
|
13236
|
-
return state$
|
|
14681
|
+
return state$1.workerPromise;
|
|
13237
14682
|
};
|
|
13238
|
-
const invoke$
|
|
14683
|
+
const invoke$1 = async (method, ...params) => {
|
|
13239
14684
|
const worker = await getOrCreate();
|
|
13240
14685
|
return await worker.invoke(method, ...params);
|
|
13241
14686
|
};
|
|
@@ -13243,17 +14688,17 @@ const invoke$2 = async (method, ...params) => {
|
|
|
13243
14688
|
const getWidgetInvoke = widgetId => {
|
|
13244
14689
|
switch (widgetId) {
|
|
13245
14690
|
case ColorPicker$2:
|
|
13246
|
-
return invoke$
|
|
14691
|
+
return invoke$6;
|
|
13247
14692
|
case Completion:
|
|
13248
|
-
return invoke$5;
|
|
13249
|
-
case Find:
|
|
13250
14693
|
return invoke$4;
|
|
13251
|
-
case
|
|
14694
|
+
case Find:
|
|
13252
14695
|
return invoke$3;
|
|
14696
|
+
case Hover:
|
|
14697
|
+
return invoke$2;
|
|
13253
14698
|
case Rename$1:
|
|
13254
|
-
return invoke$
|
|
14699
|
+
return invoke$5;
|
|
13255
14700
|
case SourceAction$1:
|
|
13256
|
-
return invoke$
|
|
14701
|
+
return invoke$1;
|
|
13257
14702
|
default:
|
|
13258
14703
|
return undefined;
|
|
13259
14704
|
}
|
|
@@ -13264,7 +14709,7 @@ const Close = 'Close';
|
|
|
13264
14709
|
|
|
13265
14710
|
const getEditorByWidgetUid = (widgetUid, widgetId) => {
|
|
13266
14711
|
for (const key of getKeys$2()) {
|
|
13267
|
-
const editor = get$
|
|
14712
|
+
const editor = get$9(Number(key)).newState;
|
|
13268
14713
|
const widgets = editor.widgets || [];
|
|
13269
14714
|
for (const widget of widgets) {
|
|
13270
14715
|
if (widget.id === widgetId && widget.newState.uid === widgetUid) {
|
|
@@ -13278,7 +14723,7 @@ const getEditor = (editorOrUid, widgetId) => {
|
|
|
13278
14723
|
if (editorOrUid && editorOrUid.widgets) {
|
|
13279
14724
|
return editorOrUid;
|
|
13280
14725
|
}
|
|
13281
|
-
const instance = get$
|
|
14726
|
+
const instance = get$9(editorOrUid);
|
|
13282
14727
|
if (instance && instance.newState && instance.newState.widgets) {
|
|
13283
14728
|
return instance.newState;
|
|
13284
14729
|
}
|
|
@@ -13310,16 +14755,16 @@ const createFn = (key, name, widgetId) => {
|
|
|
13310
14755
|
} = state;
|
|
13311
14756
|
const invoke = getWidgetInvoke(widgetId);
|
|
13312
14757
|
await invoke(`${name}.${key}`, uid, ...args);
|
|
13313
|
-
const latestAfterInvoke = get$
|
|
14758
|
+
const latestAfterInvoke = get$9(editor.uid).newState;
|
|
13314
14759
|
const latestChildIndex = latestAfterInvoke.widgets.findIndex(isWidget);
|
|
13315
14760
|
if (latestChildIndex === -1) {
|
|
13316
|
-
set$
|
|
14761
|
+
set$b(editor.uid, editor, latestAfterInvoke);
|
|
13317
14762
|
await dispose$3();
|
|
13318
14763
|
return latestAfterInvoke;
|
|
13319
14764
|
}
|
|
13320
14765
|
const diff = await invoke(`${name}.diff2`, uid);
|
|
13321
14766
|
const commands = await invoke(`${name}.render2`, uid, diff);
|
|
13322
|
-
const latest = get$
|
|
14767
|
+
const latest = get$9(editor.uid).newState;
|
|
13323
14768
|
if (shouldClose) {
|
|
13324
14769
|
const newEditor = {
|
|
13325
14770
|
...latest,
|
|
@@ -13327,7 +14772,7 @@ const createFn = (key, name, widgetId) => {
|
|
|
13327
14772
|
widgetRevision,
|
|
13328
14773
|
widgets: removeEditorWidget(latest.widgets, widgetId)
|
|
13329
14774
|
};
|
|
13330
|
-
set$
|
|
14775
|
+
set$b(editor.uid, latest, newEditor);
|
|
13331
14776
|
return newEditor;
|
|
13332
14777
|
}
|
|
13333
14778
|
const newState = {
|
|
@@ -13335,7 +14780,7 @@ const createFn = (key, name, widgetId) => {
|
|
|
13335
14780
|
commands
|
|
13336
14781
|
};
|
|
13337
14782
|
const newEditor = updateWidget(latest, widgetId, newState);
|
|
13338
|
-
set$
|
|
14783
|
+
set$b(editor.uid, editor, newEditor);
|
|
13339
14784
|
return newEditor;
|
|
13340
14785
|
};
|
|
13341
14786
|
return fn;
|
|
@@ -13402,9 +14847,14 @@ const focusFindInput = editor => {
|
|
|
13402
14847
|
} = widget.newState;
|
|
13403
14848
|
const newState = {
|
|
13404
14849
|
...widget.newState,
|
|
13405
|
-
commands: [[FocusSelector, uid, `[name="${SearchValue}"]`]]
|
|
14850
|
+
commands: [[SetFocusContext, FindWidget], [FocusSelector, uid, `[name="${SearchValue}"]`]]
|
|
13406
14851
|
};
|
|
13407
|
-
return updateWidget(
|
|
14852
|
+
return updateWidget({
|
|
14853
|
+
...editor,
|
|
14854
|
+
additionalFocus: 0,
|
|
14855
|
+
focus: FindWidget,
|
|
14856
|
+
focused: false
|
|
14857
|
+
}, Find, newState);
|
|
13408
14858
|
};
|
|
13409
14859
|
const {
|
|
13410
14860
|
close: close$4,
|
|
@@ -13513,10 +14963,10 @@ const loadContent$2 = async (state, parentUid, savedState) => {
|
|
|
13513
14963
|
y
|
|
13514
14964
|
} = editor;
|
|
13515
14965
|
await launch();
|
|
13516
|
-
await invoke$
|
|
13517
|
-
await invoke$
|
|
13518
|
-
const diff = await invoke$
|
|
13519
|
-
const commands = await invoke$
|
|
14966
|
+
await invoke$3('FindWidget.create', uid, x, y, width, height, parentUid);
|
|
14967
|
+
await invoke$3('FindWidget.loadContent', uid, savedState);
|
|
14968
|
+
const diff = await invoke$3('FindWidget.diff2', uid);
|
|
14969
|
+
const commands = await invoke$3('FindWidget.render2', uid, diff);
|
|
13520
14970
|
return {
|
|
13521
14971
|
...state,
|
|
13522
14972
|
commands
|
|
@@ -13591,15 +15041,15 @@ const newStateGenerator$1 = async (state, parentUid) => {
|
|
|
13591
15041
|
} = state;
|
|
13592
15042
|
const {
|
|
13593
15043
|
newState
|
|
13594
|
-
} = get$
|
|
15044
|
+
} = get$9(parentUid);
|
|
13595
15045
|
const {
|
|
13596
15046
|
applicationId,
|
|
13597
15047
|
languageId
|
|
13598
15048
|
} = newState;
|
|
13599
|
-
await invoke$
|
|
13600
|
-
await invoke$
|
|
13601
|
-
const diff = await invoke$
|
|
13602
|
-
const commands = await invoke$
|
|
15049
|
+
await invoke$5('Rename.create', uid, x, y, width, height, parentUid, languageId, applicationId);
|
|
15050
|
+
await invoke$5('Rename.loadContent', uid);
|
|
15051
|
+
const diff = await invoke$5('Rename.diff2', uid);
|
|
15052
|
+
const commands = await invoke$5('Rename.render2', uid, diff);
|
|
13603
15053
|
return {
|
|
13604
15054
|
...state,
|
|
13605
15055
|
commands
|
|
@@ -13616,7 +15066,7 @@ const openRename = async editor => {
|
|
|
13616
15066
|
if (!word) {
|
|
13617
15067
|
return editor;
|
|
13618
15068
|
}
|
|
13619
|
-
const editorState = get$
|
|
15069
|
+
const editorState = get$9(editor.uid);
|
|
13620
15070
|
if (!editorState) {
|
|
13621
15071
|
return editor;
|
|
13622
15072
|
}
|
|
@@ -13630,7 +15080,7 @@ const openRename = async editor => {
|
|
|
13630
15080
|
if (!prepareRenameResult || typeof prepareRenameResult !== 'object') {
|
|
13631
15081
|
return editor;
|
|
13632
15082
|
}
|
|
13633
|
-
const latestEditor = get$
|
|
15083
|
+
const latestEditor = get$9(editor.uid)?.newState;
|
|
13634
15084
|
if (latestEditor !== editor) {
|
|
13635
15085
|
return latestEditor || editor;
|
|
13636
15086
|
}
|
|
@@ -13767,7 +15217,7 @@ const paste = async (editor, pastedText) => {
|
|
|
13767
15217
|
cause: error
|
|
13768
15218
|
});
|
|
13769
15219
|
}
|
|
13770
|
-
const currentEditor = get$
|
|
15220
|
+
const currentEditor = get$9(editor.uid)?.newState;
|
|
13771
15221
|
if (!currentEditor || currentEditor.uri !== editor.uri || currentEditor.languageId !== 'markdown') {
|
|
13772
15222
|
try {
|
|
13773
15223
|
await invoke$a(editor.applicationId, 'FileSystem.remove', savedImage.uri);
|
|
@@ -13983,10 +15433,18 @@ const editorSelectAllRight = editor => {
|
|
|
13983
15433
|
|
|
13984
15434
|
// @ts-ignore
|
|
13985
15435
|
const selectCharacterLeft = editor => {
|
|
15436
|
+
const bidi = moveBidiCharacter(editor, -1, true);
|
|
15437
|
+
if (bidi) {
|
|
15438
|
+
return bidi;
|
|
15439
|
+
}
|
|
13986
15440
|
return editorSelectHorizontalLeft(editor, characterLeft);
|
|
13987
15441
|
};
|
|
13988
15442
|
|
|
13989
15443
|
const selectCharacterRight = editor => {
|
|
15444
|
+
const bidi = moveBidiCharacter(editor, 1, true);
|
|
15445
|
+
if (bidi) {
|
|
15446
|
+
return bidi;
|
|
15447
|
+
}
|
|
13990
15448
|
return editorSelectHorizontalRight(editor, characterRight);
|
|
13991
15449
|
};
|
|
13992
15450
|
|
|
@@ -14523,7 +15981,7 @@ const paddingLeft = 8;
|
|
|
14523
15981
|
const paddingRight = 8;
|
|
14524
15982
|
const getSignatureHelpInfo = async editorUid => {
|
|
14525
15983
|
number(editorUid);
|
|
14526
|
-
const instance = get$
|
|
15984
|
+
const instance = get$9(editorUid);
|
|
14527
15985
|
const editor = instance.newState;
|
|
14528
15986
|
const {
|
|
14529
15987
|
selections
|
|
@@ -14641,14 +16099,14 @@ const newStateGenerator = async (state, parentUid) => {
|
|
|
14641
16099
|
} = state;
|
|
14642
16100
|
const {
|
|
14643
16101
|
newState
|
|
14644
|
-
} = get$
|
|
16102
|
+
} = get$9(parentUid);
|
|
14645
16103
|
const {
|
|
14646
16104
|
languageId
|
|
14647
16105
|
} = newState;
|
|
14648
|
-
await invoke$
|
|
14649
|
-
await invoke$
|
|
14650
|
-
const diff = await invoke$
|
|
14651
|
-
const commands = await invoke$
|
|
16106
|
+
await invoke$1('SourceActions.create', uid, x, y, width, height, parentUid, languageId);
|
|
16107
|
+
await invoke$1('SourceActions.loadContent', uid);
|
|
16108
|
+
const diff = await invoke$1('SourceActions.diff2', uid);
|
|
16109
|
+
const commands = await invoke$1('SourceActions.render2', uid, diff);
|
|
14652
16110
|
return {
|
|
14653
16111
|
...state,
|
|
14654
16112
|
commands
|
|
@@ -16382,7 +17840,7 @@ const getEditorSourceActions = async editorId => {
|
|
|
16382
17840
|
}
|
|
16383
17841
|
const {
|
|
16384
17842
|
newState
|
|
16385
|
-
} = get$
|
|
17843
|
+
} = get$9(editorId);
|
|
16386
17844
|
const extensions = await invoke$9(newState.applicationId, 'Extensions.getAllExtensions', newState.assetDir, newState.platform);
|
|
16387
17845
|
return extensions.filter(extension => !extension.disabled).flatMap(extension => extension.codeActions || []).filter(action => action.languageId === newState.languageId);
|
|
16388
17846
|
};
|
|
@@ -16476,13 +17934,13 @@ const getSelections2 = editorUid => {
|
|
|
16476
17934
|
return selections;
|
|
16477
17935
|
};
|
|
16478
17936
|
const setSelections2 = async (editorUid, selections) => {
|
|
16479
|
-
const requested = get$
|
|
17937
|
+
const requested = get$9(editorUid);
|
|
16480
17938
|
if (!requested || requested.newState.lifecycle?.disposed) {
|
|
16481
17939
|
return;
|
|
16482
17940
|
}
|
|
16483
17941
|
const requestedLifecycle = requested.newState.lifecycle;
|
|
16484
17942
|
await enqueue(editorUid, async () => {
|
|
16485
|
-
const instance = get$
|
|
17943
|
+
const instance = get$9(editorUid);
|
|
16486
17944
|
if (!instance || instance.newState.lifecycle?.disposed || instance.newState.lifecycle !== requestedLifecycle) {
|
|
16487
17945
|
return;
|
|
16488
17946
|
}
|
|
@@ -16492,11 +17950,11 @@ const setSelections2 = async (editorUid, selections) => {
|
|
|
16492
17950
|
} = editor;
|
|
16493
17951
|
const newEditor = setSelections$2(editor, selections);
|
|
16494
17952
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
16495
|
-
const current = get$
|
|
17953
|
+
const current = get$9(editorUid);
|
|
16496
17954
|
if (!current || lifecycle?.disposed || current.newState.lifecycle !== lifecycle) {
|
|
16497
17955
|
return;
|
|
16498
17956
|
}
|
|
16499
|
-
set$
|
|
17957
|
+
set$b(editorUid, current.oldState, newEditorWithDerivedState);
|
|
16500
17958
|
});
|
|
16501
17959
|
};
|
|
16502
17960
|
const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
|
|
@@ -16521,7 +17979,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
|
|
|
16521
17979
|
widgets: newWidgets
|
|
16522
17980
|
};
|
|
16523
17981
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
16524
|
-
set$
|
|
17982
|
+
set$b(editorUid, editor, newEditorWithDerivedState);
|
|
16525
17983
|
await setFocus(FocusEditorText);
|
|
16526
17984
|
if (unsetAdditionalFocus$1) {
|
|
16527
17985
|
await unsetAdditionalFocus(unsetAdditionalFocus$1);
|
|
@@ -16552,7 +18010,7 @@ const ensure = async (fontName, fontUrl) => {
|
|
|
16552
18010
|
const getComponentState = uid => {
|
|
16553
18011
|
const {
|
|
16554
18012
|
newState
|
|
16555
|
-
} = get$
|
|
18013
|
+
} = get$9(uid);
|
|
16556
18014
|
return {
|
|
16557
18015
|
...newState,
|
|
16558
18016
|
cursorUndoStack: newState.cursorUndoStack?.map(selection => [...selection]),
|
|
@@ -17056,7 +18514,7 @@ const getProblems = async () => {
|
|
|
17056
18514
|
const keys = getKeys$2();
|
|
17057
18515
|
const diagnostics = keys.flatMap(key => {
|
|
17058
18516
|
const numericKey = Number(key);
|
|
17059
|
-
const editor = get$
|
|
18517
|
+
const editor = get$9(numericKey);
|
|
17060
18518
|
if (!editor?.newState) {
|
|
17061
18519
|
return [];
|
|
17062
18520
|
}
|
|
@@ -17228,10 +18686,10 @@ const createCommandMap = commands => ({
|
|
|
17228
18686
|
if (typeof fn !== 'function') {
|
|
17229
18687
|
throw new TypeError(`Editor event command not found: ${command}`);
|
|
17230
18688
|
}
|
|
17231
|
-
const editor = get$
|
|
18689
|
+
const editor = get$9(uid)?.newState;
|
|
17232
18690
|
if (!editor) return;
|
|
17233
18691
|
await fn(uid, ...args);
|
|
17234
|
-
const current = get$
|
|
18692
|
+
const current = get$9(uid)?.newState;
|
|
17235
18693
|
if (!current || editor.lifecycle?.disposed || current.lifecycle !== editor.lifecycle) return;
|
|
17236
18694
|
// The wrapped command has released the document queue before requesting a
|
|
17237
18695
|
// render; a diff can now run without waiting on its own command.
|
|
@@ -17241,35 +18699,13 @@ const createCommandMap = commands => ({
|
|
|
17241
18699
|
}
|
|
17242
18700
|
});
|
|
17243
18701
|
|
|
17244
|
-
const state$1 = {
|
|
17245
|
-
rpc: undefined
|
|
17246
|
-
};
|
|
17247
|
-
const isConnected = () => {
|
|
17248
|
-
const {
|
|
17249
|
-
rpc
|
|
17250
|
-
} = state$1;
|
|
17251
|
-
return rpc !== undefined;
|
|
17252
|
-
};
|
|
17253
|
-
const set = value => {
|
|
17254
|
-
state$1.rpc = value;
|
|
17255
|
-
};
|
|
17256
|
-
const invoke$1 = (method, ...params) => {
|
|
17257
|
-
const {
|
|
17258
|
-
rpc
|
|
17259
|
-
} = state$1;
|
|
17260
|
-
if (!rpc) {
|
|
17261
|
-
throw new Error('Editor renderer process is not connected');
|
|
17262
|
-
}
|
|
17263
|
-
return rpc.invoke(method, ...params);
|
|
17264
|
-
};
|
|
17265
|
-
|
|
17266
18702
|
const handleMessagePort = async (port, rpcId) => {
|
|
17267
18703
|
const rpc = await create$e({
|
|
17268
18704
|
commandMap: {},
|
|
17269
18705
|
messagePort: port
|
|
17270
18706
|
});
|
|
17271
18707
|
if (rpcId) {
|
|
17272
|
-
set$
|
|
18708
|
+
set$l(rpcId, rpc);
|
|
17273
18709
|
await initializeListener(rpcId);
|
|
17274
18710
|
}
|
|
17275
18711
|
};
|
|
@@ -17278,7 +18714,7 @@ const handleDirectMessagePort = async (port, commands) => {
|
|
|
17278
18714
|
commandMap: createCommandMap(commands),
|
|
17279
18715
|
messagePort: port
|
|
17280
18716
|
});
|
|
17281
|
-
set(rpc);
|
|
18717
|
+
set$6(rpc);
|
|
17282
18718
|
};
|
|
17283
18719
|
|
|
17284
18720
|
const getBreadcrumbFileIcon = async (uri, applicationId) => {
|
|
@@ -17427,7 +18863,7 @@ const getHorizontalVirtualizationThreshold = value => {
|
|
|
17427
18863
|
return Math.floor(threshold);
|
|
17428
18864
|
};
|
|
17429
18865
|
const getEditorPreferences = async applicationId => {
|
|
17430
|
-
const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, formatActions, hoverEnabled, hoverDelay, horizontalVirtualizationThreshold, messageDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens, selectedTextOccurrenceMatching] = await Promise.all([get$3('editor.diagnostics', applicationId), getFontFamily(applicationId), getFontSize(applicationId), getFontWeight(applicationId), get$3('editor.formatOnSave', applicationId), get$3('editor.formatActions', applicationId), get$3('editor.hover', applicationId), get$3('editor.hoverDelay', applicationId), get$3('editor.horizontalVirtualizationThreshold', applicationId), get$3('editor.messageDelay', applicationId), isAutoClosingBracketsEnabled(applicationId), isAutoClosingQuotesEnabled(applicationId), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(applicationId), getLineNumbers(applicationId), getHighlightActiveLineNumber(applicationId), getRowHeight(applicationId), getTabSize(applicationId), getLetterSpacing(applicationId), getCompletionTriggerCharacters(), getMinimapEnabled(applicationId), getMergeConflictActionsEnabled(applicationId), get$3('breadcrumbs.enabled', applicationId), get$3('editor.insertSpaces', applicationId), get$3('editor.dragAndDrop', applicationId), get$3('editor.roundedSelection', applicationId), get$3('editor.combineWhitespaceTokens', applicationId), get$3('editor.selectedTextOccurrenceMatching', applicationId)]);
|
|
18866
|
+
const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, formatActions, hoverEnabled, hoverDelay, horizontalVirtualizationThreshold, messageDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, rtl, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens, selectedTextOccurrenceMatching] = await Promise.all([get$3('editor.diagnostics', applicationId), getFontFamily(applicationId), getFontSize(applicationId), getFontWeight(applicationId), get$3('editor.formatOnSave', applicationId), get$3('editor.formatActions', applicationId), get$3('editor.hover', applicationId), get$3('editor.hoverDelay', applicationId), get$3('editor.horizontalVirtualizationThreshold', applicationId), get$3('editor.messageDelay', applicationId), isAutoClosingBracketsEnabled(applicationId), isAutoClosingQuotesEnabled(applicationId), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(applicationId), getLineNumbers(applicationId), getHighlightActiveLineNumber(applicationId), getRowHeight(applicationId), getTabSize(applicationId), getLetterSpacing(applicationId), getCompletionTriggerCharacters(), getMinimapEnabled(applicationId), getMergeConflictActionsEnabled(applicationId), get$3('editor.rtl', applicationId), get$3('breadcrumbs.enabled', applicationId), get$3('editor.insertSpaces', applicationId), get$3('editor.dragAndDrop', applicationId), get$3('editor.roundedSelection', applicationId), get$3('editor.combineWhitespaceTokens', applicationId), get$3('editor.selectedTextOccurrenceMatching', applicationId)]);
|
|
17431
18867
|
return {
|
|
17432
18868
|
breadcrumbsEnabled: breadcrumbsEnabled ?? false,
|
|
17433
18869
|
combineWhitespaceTokens: combineWhitespaceTokens ?? true,
|
|
@@ -17455,6 +18891,7 @@ const getEditorPreferences = async applicationId => {
|
|
|
17455
18891
|
minimapEnabled,
|
|
17456
18892
|
roundedSelection: roundedSelection === true,
|
|
17457
18893
|
rowHeight,
|
|
18894
|
+
rtl: rtl === true,
|
|
17458
18895
|
selectedTextOccurrenceMatching: getSelectedTextOccurrenceMatching(selectedTextOccurrenceMatching),
|
|
17459
18896
|
tabSize
|
|
17460
18897
|
};
|
|
@@ -17490,9 +18927,9 @@ const updateFindWidget = async state => {
|
|
|
17490
18927
|
const {
|
|
17491
18928
|
uid
|
|
17492
18929
|
} = widget.newState;
|
|
17493
|
-
await invoke$
|
|
17494
|
-
const diff = await invoke$
|
|
17495
|
-
const commands = await invoke$
|
|
18930
|
+
await invoke$3('FindWidget.handleSettingsChanged', uid);
|
|
18931
|
+
const diff = await invoke$3('FindWidget.diff2', uid);
|
|
18932
|
+
const commands = await invoke$3('FindWidget.render2', uid, diff);
|
|
17496
18933
|
return updateWidget(state, Find, {
|
|
17497
18934
|
...widget.newState,
|
|
17498
18935
|
commands
|
|
@@ -17616,7 +19053,7 @@ const getWidgetHotReloadDescriptor = widgetId => {
|
|
|
17616
19053
|
switch (widgetId) {
|
|
17617
19054
|
case Find:
|
|
17618
19055
|
return {
|
|
17619
|
-
invoke: invoke$
|
|
19056
|
+
invoke: invoke$3,
|
|
17620
19057
|
name: 'FindWidget'
|
|
17621
19058
|
};
|
|
17622
19059
|
default:
|
|
@@ -17659,7 +19096,7 @@ const restoreWidgetState = async (keys, savedStates) => {
|
|
|
17659
19096
|
const newEditors = [];
|
|
17660
19097
|
for (const key of keys) {
|
|
17661
19098
|
const editorUid = parseInt(key);
|
|
17662
|
-
const editor = get$
|
|
19099
|
+
const editor = get$9(editorUid);
|
|
17663
19100
|
if (!editor?.newState || !Array.isArray(editor.newState.widgets)) {
|
|
17664
19101
|
continue;
|
|
17665
19102
|
}
|
|
@@ -17712,7 +19149,7 @@ const saveSingleWidgetState = async (savedStates, key, widget) => {
|
|
|
17712
19149
|
const saveWidgetState = async keys => {
|
|
17713
19150
|
const savedStates = Object.create(null);
|
|
17714
19151
|
for (const key of keys) {
|
|
17715
|
-
const editor = get$
|
|
19152
|
+
const editor = get$9(parseInt(key));
|
|
17716
19153
|
if (!editor?.newState || !Array.isArray(editor.newState.widgets)) {
|
|
17717
19154
|
continue;
|
|
17718
19155
|
}
|
|
@@ -17741,7 +19178,7 @@ const hotReload = async () => {
|
|
|
17741
19178
|
await relaunchWorkers();
|
|
17742
19179
|
const newEditors = await restoreWidgetState(keys, savedStates);
|
|
17743
19180
|
for (const editor of newEditors) {
|
|
17744
|
-
set$
|
|
19181
|
+
set$b(editor.newState.uid, editor.oldState, editor.newState);
|
|
17745
19182
|
}
|
|
17746
19183
|
|
|
17747
19184
|
// TODO ask renderer worker to rerender all editors
|
|
@@ -17779,7 +19216,7 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
|
|
|
17779
19216
|
if (syntaxHighlightingEnabled) {
|
|
17780
19217
|
setEnabled$1(true);
|
|
17781
19218
|
const syntaxRpc = await createSyntaxHighlightingWorkerRpc();
|
|
17782
|
-
set$
|
|
19219
|
+
set$9(syntaxRpc);
|
|
17783
19220
|
}
|
|
17784
19221
|
if (syncIncremental) {
|
|
17785
19222
|
setEnabled(true);
|
|
@@ -18000,6 +19437,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
18000
19437
|
minimapEnabled,
|
|
18001
19438
|
roundedSelection,
|
|
18002
19439
|
rowHeight,
|
|
19440
|
+
rtl,
|
|
18003
19441
|
selectedTextOccurrenceMatching,
|
|
18004
19442
|
tabSize
|
|
18005
19443
|
} = await getEditorPreferences(state.applicationId);
|
|
@@ -18042,6 +19480,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
18042
19480
|
minimapEnabled,
|
|
18043
19481
|
roundedSelection,
|
|
18044
19482
|
rowHeight,
|
|
19483
|
+
rtl,
|
|
18045
19484
|
selectedTextOccurrenceMatching,
|
|
18046
19485
|
tabSize,
|
|
18047
19486
|
tokenizerId: state.tokenizerId
|
|
@@ -18051,7 +19490,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
18051
19490
|
let existingEditor;
|
|
18052
19491
|
if (!forceReload) {
|
|
18053
19492
|
for (const key of getKeys$2()) {
|
|
18054
|
-
const editor = get$
|
|
19493
|
+
const editor = get$9(Number(key))?.newState;
|
|
18055
19494
|
if (editor && editor.id !== id && !editor.initial && editor.uri === uri && editor.applicationId === state.applicationId) {
|
|
18056
19495
|
existingEditor = editor;
|
|
18057
19496
|
break;
|
|
@@ -18107,11 +19546,13 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
18107
19546
|
}, x, y, width, height, 9);
|
|
18108
19547
|
const newEditor2 = setText$1(newEditor1, content);
|
|
18109
19548
|
const newEditor3 = await updateHorizontalLayout(newEditor2);
|
|
19549
|
+
const savedDeltaY = savedState?.deltaY;
|
|
19550
|
+
const newEditor3WithScroll = typeof savedDeltaY === 'number' && Number.isFinite(savedDeltaY) && savedDeltaY >= 0 ? await setDeltaYFixedValue(newEditor3, savedDeltaY) : newEditor3;
|
|
18110
19551
|
|
|
18111
19552
|
// Detect links and initialize decorations
|
|
18112
|
-
const linkDecorations = detectAllLinksAsDecorations(
|
|
19553
|
+
const linkDecorations = detectAllLinksAsDecorations(newEditor3WithScroll);
|
|
18113
19554
|
const newEditor3WithLinks = {
|
|
18114
|
-
...
|
|
19555
|
+
...newEditor3WithScroll,
|
|
18115
19556
|
decorations: linkDecorations
|
|
18116
19557
|
};
|
|
18117
19558
|
let documentSymbols = state.documentSymbols || [];
|
|
@@ -18234,14 +19675,14 @@ const refreshGutterDecorations = async editor => {
|
|
|
18234
19675
|
};
|
|
18235
19676
|
const refreshGutterDecorationsAll = async () => {
|
|
18236
19677
|
for (const key of getKeys$2()) {
|
|
18237
|
-
const editor = get$
|
|
19678
|
+
const editor = get$9(Number(key))?.newState;
|
|
18238
19679
|
if (editor) {
|
|
18239
19680
|
const refreshedEditor = await refreshGutterDecorations(editor);
|
|
18240
|
-
const latest = get$
|
|
19681
|
+
const latest = get$9(editor.id);
|
|
18241
19682
|
if (!latest) {
|
|
18242
19683
|
continue;
|
|
18243
19684
|
}
|
|
18244
|
-
set$
|
|
19685
|
+
set$b(editor.id, latest.oldState, {
|
|
18245
19686
|
...latest.newState,
|
|
18246
19687
|
gutterDecorations: refreshedEditor.gutterDecorations
|
|
18247
19688
|
});
|
|
@@ -18281,6 +19722,8 @@ const getCss = (uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, s
|
|
|
18281
19722
|
--ScrollBarWidth: ${scrollBarWidth}px;
|
|
18282
19723
|
--ScrollBarLeft: ${scrollBarLeft}px;
|
|
18283
19724
|
}
|
|
19725
|
+
.EditorBidiRun { display: inline-block; direction: ltr; unicode-bidi: bidi-override; }
|
|
19726
|
+
.EditorBidiRunRtl { direction: rtl; }
|
|
18284
19727
|
.EditorRow { contain: var(--EditorRowContain, strict); }
|
|
18285
19728
|
${editorSelector} .SelectionTopLeft { border-top-left-radius: 3px; }
|
|
18286
19729
|
${editorSelector} .SelectionTopRight { border-top-right-radius: 3px; }
|
|
@@ -18764,7 +20207,7 @@ const addMergeConflictActions = (dom, rowIndex) => {
|
|
|
18764
20207
|
}, text(label));
|
|
18765
20208
|
}
|
|
18766
20209
|
};
|
|
18767
|
-
const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, diagnostics = [], deltaX = 0, width = Infinity, charWidth = 1, tabSize = 2, lines = [], horizontalVirtualizationThreshold = 500, horizontalVisibleRanges = []) => {
|
|
20210
|
+
const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, diagnostics = [], deltaX = 0, width = Infinity, charWidth = 1, tabSize = 2, lines = [], horizontalVirtualizationThreshold = 500, horizontalVisibleRanges = [], rtl = false) => {
|
|
18768
20211
|
const dom = [];
|
|
18769
20212
|
const actualViewRows = visibleViewLineIndices.length === 0 ? Array.from({
|
|
18770
20213
|
length: textInfos.length
|
|
@@ -18793,13 +20236,43 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
|
|
|
18793
20236
|
if (rowIndex === problemsHighlightedRow) {
|
|
18794
20237
|
className = mergeClassNames(className, 'EditorProblemsHighlightedRow');
|
|
18795
20238
|
}
|
|
20239
|
+
const bidiText = rtl && isBidi(line || tokenParts.map(part => part.text).join(''), rtl) ? tokenParts.map(part => part.text).join('') : '';
|
|
20240
|
+
const runs = bidiText ? getRuns(bidiText) : undefined;
|
|
18796
20241
|
dom.push({
|
|
18797
|
-
childCount: tokenParts.length + rowDecorations.length,
|
|
20242
|
+
childCount: (runs?.length ?? tokenParts.length) + rowDecorations.length,
|
|
18798
20243
|
className,
|
|
18799
20244
|
translate: difference === 0 ? '' : px(difference),
|
|
18800
20245
|
type: Div
|
|
18801
20246
|
});
|
|
18802
|
-
|
|
20247
|
+
if (runs) {
|
|
20248
|
+
for (const run of runs) {
|
|
20249
|
+
let offset = 0;
|
|
20250
|
+
const parts = [];
|
|
20251
|
+
for (const part of tokenParts) {
|
|
20252
|
+
const start = Math.max(run.start, offset);
|
|
20253
|
+
const end = Math.min(run.end, offset + part.text.length);
|
|
20254
|
+
if (start < end) {
|
|
20255
|
+
parts.push({
|
|
20256
|
+
className: part.className,
|
|
20257
|
+
text: part.text.slice(start - offset, end - offset)
|
|
20258
|
+
});
|
|
20259
|
+
}
|
|
20260
|
+
offset += part.text.length;
|
|
20261
|
+
}
|
|
20262
|
+
dom.push({
|
|
20263
|
+
childCount: parts.length,
|
|
20264
|
+
className: run.level % 2 ? 'EditorBidiRun EditorBidiRunRtl' : 'EditorBidiRun',
|
|
20265
|
+
type: Span
|
|
20266
|
+
});
|
|
20267
|
+
for (const part of parts) {
|
|
20268
|
+
dom.push({
|
|
20269
|
+
childCount: 1,
|
|
20270
|
+
className: part.className,
|
|
20271
|
+
type: Span
|
|
20272
|
+
}, text(part.text));
|
|
20273
|
+
}
|
|
20274
|
+
}
|
|
20275
|
+
} else for (const {
|
|
18803
20276
|
className,
|
|
18804
20277
|
text: tokenText
|
|
18805
20278
|
} of tokenParts) {
|
|
@@ -18817,8 +20290,8 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
|
|
|
18817
20290
|
return dom;
|
|
18818
20291
|
};
|
|
18819
20292
|
|
|
18820
|
-
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, unnecessaryDiagnostics = [], horizontalVisibleRanges = [], lines = [], tabSize = 2) => {
|
|
18821
|
-
const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics, 0, Infinity, 1, tabSize, lines, 500, horizontalVisibleRanges);
|
|
20293
|
+
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, unnecessaryDiagnostics = [], horizontalVisibleRanges = [], lines = [], tabSize = 2, rtl = false) => {
|
|
20294
|
+
const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics, 0, Infinity, 1, tabSize, lines, 500, horizontalVisibleRanges, rtl);
|
|
18822
20295
|
return [{
|
|
18823
20296
|
childCount: visibleViewLineIndices.length || textInfos.length,
|
|
18824
20297
|
className: 'EditorRows',
|
|
@@ -18915,8 +20388,8 @@ const editorLayersNode = {
|
|
|
18915
20388
|
className: 'EditorLayers',
|
|
18916
20389
|
type: Div
|
|
18917
20390
|
};
|
|
18918
|
-
const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1, roundedSelection = false, unnecessaryDiagnostics = [], horizontalVisibleRanges = [], lines = [], tabSize = 2, textDecorationDom = []) => {
|
|
18919
|
-
return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused, roundedSelection), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize), ...getEditorCursorsVirtualDom(cursorInfos, focused), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos, textDecorationDom)];
|
|
20391
|
+
const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1, roundedSelection = false, unnecessaryDiagnostics = [], horizontalVisibleRanges = [], lines = [], tabSize = 2, textDecorationDom = [], rtl = false) => {
|
|
20392
|
+
return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused, roundedSelection), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, rtl), ...getEditorCursorsVirtualDom(cursorInfos, focused), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos, textDecorationDom)];
|
|
18920
20393
|
};
|
|
18921
20394
|
|
|
18922
20395
|
const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
|
|
@@ -18994,6 +20467,7 @@ const getEditorContentVirtualDom = ({
|
|
|
18994
20467
|
lines = [],
|
|
18995
20468
|
problemsHighlightedRow = -1,
|
|
18996
20469
|
roundedSelection = false,
|
|
20470
|
+
rtl = false,
|
|
18997
20471
|
scrollBarDiagnostics = [],
|
|
18998
20472
|
scrollBarHeight = 0,
|
|
18999
20473
|
scrollBarWidth = 0,
|
|
@@ -19008,7 +20482,7 @@ const getEditorContentVirtualDom = ({
|
|
|
19008
20482
|
return [{
|
|
19009
20483
|
...editorContentNode,
|
|
19010
20484
|
className: breadcrumbsEnabled ? 'EditorContent EditorBreadcrumbsOffset' : 'EditorContent'
|
|
19011
|
-
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, textDecorationDom), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
|
|
20485
|
+
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, textDecorationDom, rtl), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
|
|
19012
20486
|
};
|
|
19013
20487
|
|
|
19014
20488
|
const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
|
|
@@ -19174,6 +20648,7 @@ const getEditorVirtualDom = ({
|
|
|
19174
20648
|
primarySelectionIndex = 0,
|
|
19175
20649
|
problemsHighlightedRow = -1,
|
|
19176
20650
|
roundedSelection = false,
|
|
20651
|
+
rtl = false,
|
|
19177
20652
|
scrollBarDiagnostics = [],
|
|
19178
20653
|
scrollBarHeight = 0,
|
|
19179
20654
|
scrollBarWidth = 0,
|
|
@@ -19238,6 +20713,7 @@ const getEditorVirtualDom = ({
|
|
|
19238
20713
|
lines,
|
|
19239
20714
|
problemsHighlightedRow,
|
|
19240
20715
|
roundedSelection,
|
|
20716
|
+
rtl,
|
|
19241
20717
|
scrollBarDiagnostics,
|
|
19242
20718
|
scrollBarHeight,
|
|
19243
20719
|
scrollBarWidth,
|
|
@@ -19342,6 +20818,9 @@ const canRenderPlainTextAppend = (oldState, newState) => {
|
|
|
19342
20818
|
}
|
|
19343
20819
|
const oldLine = oldLines[0];
|
|
19344
20820
|
const newLine = newLines[0];
|
|
20821
|
+
if (oldState.rtl !== newState.rtl || isBidi(oldLine, oldState.rtl) || isBidi(newLine, newState.rtl)) {
|
|
20822
|
+
return false;
|
|
20823
|
+
}
|
|
19345
20824
|
if (newLine.length <= oldLine.length || !newLine.startsWith(oldLine) || /[\r\n]/.test(newLine.slice(oldLine.length))) {
|
|
19346
20825
|
return false;
|
|
19347
20826
|
}
|
|
@@ -19440,7 +20919,7 @@ const renderIncremental = (oldState, newState) => {
|
|
|
19440
20919
|
const textAppendPaths = getTextAppendPaths$1(newState.uid);
|
|
19441
20920
|
if (renderedDom && textAppendPaths && canRenderPlainTextAppend(oldState, newState)) {
|
|
19442
20921
|
const newDom = updateTextAppendDom(renderedDom, newState, textAppendPaths);
|
|
19443
|
-
set$
|
|
20922
|
+
set$1(newState.uid, newDom, textAppendPaths);
|
|
19444
20923
|
const patches = getTextAppendPatches(newState, textAppendPaths);
|
|
19445
20924
|
return [SetPatches, newState.uid, patches];
|
|
19446
20925
|
}
|
|
@@ -19448,7 +20927,7 @@ const renderIncremental = (oldState, newState) => {
|
|
|
19448
20927
|
const newDom = getDom(newState);
|
|
19449
20928
|
const patches = diffTree(oldDom, newDom);
|
|
19450
20929
|
const newTextAppendPaths = newState.languageId === 'plaintext' && newState.lines.length === 1 ? getTextAppendPaths(newDom) : undefined;
|
|
19451
|
-
set$
|
|
20930
|
+
set$1(newState.uid, newDom, newTextAppendPaths);
|
|
19452
20931
|
if (patches.length === 0) {
|
|
19453
20932
|
return [];
|
|
19454
20933
|
}
|
|
@@ -19565,7 +21044,7 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
19565
21044
|
};
|
|
19566
21045
|
|
|
19567
21046
|
const render2 = (uid, _diffResult) => {
|
|
19568
|
-
const editor = get$
|
|
21047
|
+
const editor = get$9(uid);
|
|
19569
21048
|
if (!editor) {
|
|
19570
21049
|
return [];
|
|
19571
21050
|
}
|
|
@@ -19575,7 +21054,7 @@ const render2 = (uid, _diffResult) => {
|
|
|
19575
21054
|
} = editor;
|
|
19576
21055
|
// Diagnostics can change after the caller calculated its diff in a separate RPC.
|
|
19577
21056
|
const diffResult = diff(oldState, newState);
|
|
19578
|
-
set$
|
|
21057
|
+
set$b(uid, newState, newState);
|
|
19579
21058
|
const commands = applyRender(oldState, newState, diffResult);
|
|
19580
21059
|
return commands;
|
|
19581
21060
|
};
|
|
@@ -19583,7 +21062,7 @@ const render2 = (uid, _diffResult) => {
|
|
|
19583
21062
|
const queues = new Map();
|
|
19584
21063
|
const focusCommands = new Set(['Viewlet.focus', 'Viewlet.focusSelector', 'Viewlet.setFocusContext', 'Viewlet.setAdditionalFocus', 'Viewlet.unsetAdditionalFocus']);
|
|
19585
21064
|
const renderDirect = async (uid, preserveFocus) => {
|
|
19586
|
-
const instance = get$
|
|
21065
|
+
const instance = get$9(uid);
|
|
19587
21066
|
if (!instance) return [];
|
|
19588
21067
|
const {
|
|
19589
21068
|
newState,
|
|
@@ -19599,7 +21078,7 @@ const renderDirect = async (uid, preserveFocus) => {
|
|
|
19599
21078
|
// Widget creation/declarations and focus contexts must still pass through
|
|
19600
21079
|
// renderer-worker. Replace only DOM patches, preserving command order.
|
|
19601
21080
|
if (isConnected() && command[0] === 'Viewlet.setPatches' && command[1] === uid) {
|
|
19602
|
-
const transactionId = await invoke$
|
|
21081
|
+
const transactionId = await invoke$8('Viewlet.queueCommands', uid, [command]);
|
|
19603
21082
|
result.push(['Viewlet.commitPending', uid, transactionId]);
|
|
19604
21083
|
} else {
|
|
19605
21084
|
result.push(command);
|
|
@@ -19607,17 +21086,17 @@ const renderDirect = async (uid, preserveFocus) => {
|
|
|
19607
21086
|
}
|
|
19608
21087
|
return result;
|
|
19609
21088
|
} catch (error) {
|
|
19610
|
-
const latest = get$
|
|
21089
|
+
const latest = get$9(uid);
|
|
19611
21090
|
if (latest?.newState.lifecycle === newState.lifecycle && latest.oldState === newState) {
|
|
19612
21091
|
// A rejected queue RPC must not acknowledge patches that never arrived.
|
|
19613
|
-
set$
|
|
19614
|
-
if (oldDom) set$
|
|
21092
|
+
set$b(uid, oldState, latest.newState);
|
|
21093
|
+
if (oldDom) set$1(uid, oldDom, oldPaths);else dispose$2(uid);
|
|
19615
21094
|
}
|
|
19616
21095
|
throw error;
|
|
19617
21096
|
}
|
|
19618
21097
|
};
|
|
19619
21098
|
const renderDirect2 = async (uid, preserveFocus = false) => {
|
|
19620
|
-
const lifecycle = get$
|
|
21099
|
+
const lifecycle = get$9(uid)?.newState.lifecycle;
|
|
19621
21100
|
const previous = queues.get(uid);
|
|
19622
21101
|
const {
|
|
19623
21102
|
promise,
|
|
@@ -19626,7 +21105,7 @@ const renderDirect2 = async (uid, preserveFocus = false) => {
|
|
|
19626
21105
|
queues.set(uid, promise);
|
|
19627
21106
|
if (previous) await previous;
|
|
19628
21107
|
try {
|
|
19629
|
-
if (get$
|
|
21108
|
+
if (get$9(uid)?.newState.lifecycle !== lifecycle) return [];
|
|
19630
21109
|
return await renderDirect(uid, preserveFocus);
|
|
19631
21110
|
} finally {
|
|
19632
21111
|
resolve();
|
|
@@ -19654,10 +21133,10 @@ const renderLines = {
|
|
|
19654
21133
|
visibleLineIndices,
|
|
19655
21134
|
visibleViewLineIndices
|
|
19656
21135
|
} = newState;
|
|
19657
|
-
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow, diagnostics || [], newState.deltaX, newState.width, newState.charWidth, newState.tabSize, newState.lines, newState.horizontalVirtualizationThreshold, newState.horizontalVisibleRanges);
|
|
21136
|
+
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow, diagnostics || [], newState.deltaX, newState.width, newState.charWidth, newState.tabSize, newState.lines, newState.horizontalVirtualizationThreshold, newState.horizontalVisibleRanges, newState.rtl);
|
|
19658
21137
|
return [/* method */'setText', dom];
|
|
19659
21138
|
},
|
|
19660
|
-
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.diagnostics === newState.diagnostics && oldState.deltaX === newState.deltaX && oldState.charWidth === newState.charWidth && oldState.tabSize === newState.tabSize && oldState.gutterWidth === newState.gutterWidth && oldState.horizontalVirtualizationThreshold === newState.horizontalVirtualizationThreshold && oldState.fontFamily === newState.fontFamily && oldState.fontSize === newState.fontSize && oldState.fontWeight === newState.fontWeight && oldState.letterSpacing === newState.letterSpacing && oldState.isMonospaceFont === newState.isMonospaceFont && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
|
|
21139
|
+
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.diagnostics === newState.diagnostics && oldState.deltaX === newState.deltaX && oldState.charWidth === newState.charWidth && oldState.tabSize === newState.tabSize && oldState.rtl === newState.rtl && oldState.gutterWidth === newState.gutterWidth && oldState.horizontalVirtualizationThreshold === newState.horizontalVirtualizationThreshold && oldState.fontFamily === newState.fontFamily && oldState.fontSize === newState.fontSize && oldState.fontWeight === newState.fontWeight && oldState.letterSpacing === newState.letterSpacing && oldState.isMonospaceFont === newState.isMonospaceFont && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
|
|
19661
21140
|
};
|
|
19662
21141
|
const renderSelections = {
|
|
19663
21142
|
apply: (oldState, newState) => {
|
|
@@ -19731,7 +21210,7 @@ const renderWidgets = {
|
|
|
19731
21210
|
};
|
|
19732
21211
|
const render$7 = [renderLines, renderSelections, renderCss, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
|
|
19733
21212
|
const renderEditor = async id => {
|
|
19734
|
-
const instance = get$
|
|
21213
|
+
const instance = get$9(id);
|
|
19735
21214
|
if (!instance) {
|
|
19736
21215
|
return [];
|
|
19737
21216
|
}
|
|
@@ -19740,7 +21219,7 @@ const renderEditor = async id => {
|
|
|
19740
21219
|
oldState
|
|
19741
21220
|
} = instance;
|
|
19742
21221
|
const commands = [];
|
|
19743
|
-
set$
|
|
21222
|
+
set$b(id, newState, newState);
|
|
19744
21223
|
for (const item of render$7) {
|
|
19745
21224
|
if (item.isEqual(oldState, newState)) {
|
|
19746
21225
|
continue;
|
|
@@ -19943,6 +21422,7 @@ const saveState = async (state, hotReload) => {
|
|
|
19943
21422
|
...(largeFile && {
|
|
19944
21423
|
largeFile: true
|
|
19945
21424
|
}),
|
|
21425
|
+
deltaY,
|
|
19946
21426
|
...(widgets.length > 0 && {
|
|
19947
21427
|
widgets
|
|
19948
21428
|
}),
|
|
@@ -20054,7 +21534,7 @@ const unregisterListener = (listenerType, rpcId) => {
|
|
|
20054
21534
|
};
|
|
20055
21535
|
|
|
20056
21536
|
const invoke = async (method, ...params) => {
|
|
20057
|
-
const worker = get$
|
|
21537
|
+
const worker = get$a(DebugWorker);
|
|
20058
21538
|
return worker.invoke(method, ...params);
|
|
20059
21539
|
};
|
|
20060
21540
|
|
|
@@ -20070,7 +21550,7 @@ const getKey = () => {
|
|
|
20070
21550
|
const updateDebugInfo = async debugId => {
|
|
20071
21551
|
const newInfo = await getDebugHighlight(debugId);
|
|
20072
21552
|
const key = getKey();
|
|
20073
|
-
const instance = get$
|
|
21553
|
+
const instance = get$9(key);
|
|
20074
21554
|
if (!instance) {
|
|
20075
21555
|
return;
|
|
20076
21556
|
}
|
|
@@ -20082,7 +21562,7 @@ const updateDebugInfo = async debugId => {
|
|
|
20082
21562
|
...newState,
|
|
20083
21563
|
highlightedLine: newInfo.rowIndex
|
|
20084
21564
|
};
|
|
20085
|
-
set$
|
|
21565
|
+
set$b(key, oldState, newEditor);
|
|
20086
21566
|
// @ts-ignore
|
|
20087
21567
|
await invoke$e('Editor.rerender', key);
|
|
20088
21568
|
};
|
|
@@ -20136,7 +21616,7 @@ const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preserv
|
|
|
20136
21616
|
clear$3(uid);
|
|
20137
21617
|
}
|
|
20138
21618
|
await command(uid, ...args);
|
|
20139
|
-
const editor = get$
|
|
21619
|
+
const editor = get$9(uid)?.newState;
|
|
20140
21620
|
if (editor && (shouldOpenCompletion(...args) && shouldOpenAutomaticCompletion(editor) || editor.widgets?.some(widget => widget.id === Completion && widget.newState.automatic))) {
|
|
20141
21621
|
void updateAutomaticCompletionDeferred(uid).then(() => invoke$e('Editor.renderPending', uid)).catch(error => handleError$1(error, 'Failed to open completion widget: '));
|
|
20142
21622
|
}
|
|
@@ -20470,12 +21950,31 @@ for (const [key, value] of Object.entries(commandMap)) {
|
|
|
20470
21950
|
}
|
|
20471
21951
|
}
|
|
20472
21952
|
|
|
21953
|
+
const registerCacheWorker = async () => {
|
|
21954
|
+
const lazyRpc = await create$f({
|
|
21955
|
+
commandMap: {},
|
|
21956
|
+
async send(port) {
|
|
21957
|
+
try {
|
|
21958
|
+
await sendMessagePortToCacheWorker(port);
|
|
21959
|
+
} catch (error) {
|
|
21960
|
+
// Retry registration after a failed connection; the lazy RPC retains rejected connection promises.
|
|
21961
|
+
await registerCacheWorker();
|
|
21962
|
+
throw error;
|
|
21963
|
+
}
|
|
21964
|
+
}
|
|
21965
|
+
});
|
|
21966
|
+
set$k(lazyRpc);
|
|
21967
|
+
};
|
|
21968
|
+
const initializeCacheWorker = async () => {
|
|
21969
|
+
await registerCacheWorker();
|
|
21970
|
+
};
|
|
21971
|
+
|
|
20473
21972
|
const initializeDragAndDropWorker = async () => {
|
|
20474
21973
|
const rpc = await create$f({
|
|
20475
21974
|
commandMap: {},
|
|
20476
21975
|
send: sendMessagePortToDragAndDropWorker
|
|
20477
21976
|
});
|
|
20478
|
-
set$
|
|
21977
|
+
set$i(rpc);
|
|
20479
21978
|
};
|
|
20480
21979
|
|
|
20481
21980
|
const initializeErrorWorker = async () => {
|
|
@@ -20485,7 +21984,7 @@ const initializeErrorWorker = async () => {
|
|
|
20485
21984
|
return sendMessagePortToErrorWorker(port, EditorWorker);
|
|
20486
21985
|
}
|
|
20487
21986
|
});
|
|
20488
|
-
set$
|
|
21987
|
+
set$h(rpc);
|
|
20489
21988
|
};
|
|
20490
21989
|
|
|
20491
21990
|
const createExtensionManagementWorkerRpc = async () => {
|
|
@@ -20501,7 +22000,7 @@ const createExtensionManagementWorkerRpc = async () => {
|
|
|
20501
22000
|
const initializeExtensionManagementWorker = async () => {
|
|
20502
22001
|
try {
|
|
20503
22002
|
const rpc = await createExtensionManagementWorkerRpc();
|
|
20504
|
-
set$
|
|
22003
|
+
set$g(rpc);
|
|
20505
22004
|
} catch {
|
|
20506
22005
|
// ignore
|
|
20507
22006
|
}
|
|
@@ -20516,14 +22015,14 @@ const initializeOpenerWorker = async () => {
|
|
|
20516
22015
|
commandMap: {},
|
|
20517
22016
|
send: send$1
|
|
20518
22017
|
});
|
|
20519
|
-
set$
|
|
22018
|
+
set$f(rpc);
|
|
20520
22019
|
};
|
|
20521
22020
|
|
|
20522
22021
|
const initializeRendererWorker = async () => {
|
|
20523
22022
|
const rpc = await create$d({
|
|
20524
22023
|
commandMap: commandMap
|
|
20525
22024
|
});
|
|
20526
|
-
set$
|
|
22025
|
+
set$d(rpc);
|
|
20527
22026
|
};
|
|
20528
22027
|
|
|
20529
22028
|
const send = port => {
|
|
@@ -20534,17 +22033,17 @@ const initializeTextMeasurementWorker = async () => {
|
|
|
20534
22033
|
commandMap: {},
|
|
20535
22034
|
send
|
|
20536
22035
|
});
|
|
20537
|
-
set$
|
|
22036
|
+
set$e(rpc);
|
|
20538
22037
|
};
|
|
20539
22038
|
|
|
20540
22039
|
const listen = async () => {
|
|
20541
22040
|
registerCommands(commandMap);
|
|
20542
|
-
await Promise.all([initializeRendererWorker(), initializeDragAndDropWorker(), initializeErrorWorker(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
|
|
22041
|
+
await Promise.all([initializeRendererWorker(), initializeDragAndDropWorker(), initializeErrorWorker(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeCacheWorker(), initializeOpenerWorker()]);
|
|
20543
22042
|
const dialogRpc = await create$f({
|
|
20544
22043
|
commandMap: {},
|
|
20545
22044
|
send: sendMessagePortToDialogWorker
|
|
20546
22045
|
});
|
|
20547
|
-
set$
|
|
22046
|
+
set$j(dialogRpc);
|
|
20548
22047
|
};
|
|
20549
22048
|
|
|
20550
22049
|
const CodeGeneratorInput = 'CodeGeneratorInput';
|
|
@@ -20866,15 +22365,15 @@ const EditorMessageWidget = {
|
|
|
20866
22365
|
};
|
|
20867
22366
|
|
|
20868
22367
|
const registerWidgets = () => {
|
|
20869
|
-
set$
|
|
20870
|
-
set$
|
|
20871
|
-
set$
|
|
20872
|
-
set$
|
|
20873
|
-
set$
|
|
20874
|
-
set$
|
|
20875
|
-
set$
|
|
20876
|
-
set$
|
|
20877
|
-
set$
|
|
22368
|
+
set$a(ColorPicker$2, EditorColorPickerWidget);
|
|
22369
|
+
set$a(Completion, EditorCompletionWidget);
|
|
22370
|
+
set$a(CompletionDetail, EditorCompletionDetailWidget);
|
|
22371
|
+
set$a(Find, EditorFindWidget);
|
|
22372
|
+
set$a(Hover, EditorHoverWidget);
|
|
22373
|
+
set$a(Message, EditorMessageWidget);
|
|
22374
|
+
set$a(Rename$1, EditorRenameWidget);
|
|
22375
|
+
set$a(SourceAction$1, EditorSourceActionWidget);
|
|
22376
|
+
set$a(CodeGenerator, EditorCodeGeneratorWidget);
|
|
20878
22377
|
};
|
|
20879
22378
|
|
|
20880
22379
|
const handleUnhandledRejection = event => {
|