@lvce-editor/quick-pick-worker 4.32.0 → 4.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/quickPickWorkerMain.js +1214 -818
- package/package.json +1 -1
|
@@ -67,7 +67,7 @@ const String$1 = 4;
|
|
|
67
67
|
const Boolean$1 = 5;
|
|
68
68
|
const Function = 6;
|
|
69
69
|
const Null = 7;
|
|
70
|
-
const Unknown = 8;
|
|
70
|
+
const Unknown$1 = 8;
|
|
71
71
|
const getType = value => {
|
|
72
72
|
switch (typeof value) {
|
|
73
73
|
case 'number':
|
|
@@ -87,7 +87,7 @@ const getType = value => {
|
|
|
87
87
|
case 'boolean':
|
|
88
88
|
return Boolean$1;
|
|
89
89
|
default:
|
|
90
|
-
return Unknown;
|
|
90
|
+
return Unknown$1;
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
const object = value => {
|
|
@@ -1229,6 +1229,279 @@ const Text = 12;
|
|
|
1229
1229
|
const Img = 17;
|
|
1230
1230
|
const Reference = 100;
|
|
1231
1231
|
|
|
1232
|
+
const Unknown = 0;
|
|
1233
|
+
const Backspace = 1;
|
|
1234
|
+
const Tab = 2;
|
|
1235
|
+
const Enter$1 = 3;
|
|
1236
|
+
const Ctrl = 4;
|
|
1237
|
+
const Alt = 5;
|
|
1238
|
+
const PauseBreak = 6;
|
|
1239
|
+
const CapsLock = 7;
|
|
1240
|
+
const Escape$1 = 8;
|
|
1241
|
+
const Space$1 = 9;
|
|
1242
|
+
const PageUp$1 = 10;
|
|
1243
|
+
const PageDown$1 = 11;
|
|
1244
|
+
const End = 255;
|
|
1245
|
+
const Home = 12;
|
|
1246
|
+
const LeftArrow = 13;
|
|
1247
|
+
const UpArrow$1 = 14;
|
|
1248
|
+
const RightArrow = 15;
|
|
1249
|
+
const DownArrow$1 = 16;
|
|
1250
|
+
const Insert = 17;
|
|
1251
|
+
const Delete = 18;
|
|
1252
|
+
const Digit0 = 19;
|
|
1253
|
+
const Digit1 = 20;
|
|
1254
|
+
const Digit2 = 21;
|
|
1255
|
+
const Digit3 = 22;
|
|
1256
|
+
const Digit4 = 23;
|
|
1257
|
+
const Digit5 = 24;
|
|
1258
|
+
const Digit6 = 25;
|
|
1259
|
+
const Digit7 = 26;
|
|
1260
|
+
const Digit8 = 27;
|
|
1261
|
+
const Digit9 = 28;
|
|
1262
|
+
const KeyA = 29;
|
|
1263
|
+
const KeyB = 30;
|
|
1264
|
+
const KeyC = 31;
|
|
1265
|
+
const KeyD = 32;
|
|
1266
|
+
const KeyE = 33;
|
|
1267
|
+
const KeyF = 34;
|
|
1268
|
+
const KeyG = 35;
|
|
1269
|
+
const KeyH = 36;
|
|
1270
|
+
const KeyI = 37;
|
|
1271
|
+
const KeyJ = 38;
|
|
1272
|
+
const KeyK = 39;
|
|
1273
|
+
const KeyL = 40;
|
|
1274
|
+
const KeyM = 41;
|
|
1275
|
+
const KeyN = 42;
|
|
1276
|
+
const KeyO = 43;
|
|
1277
|
+
const KeyP = 44;
|
|
1278
|
+
const KeyQ = 45;
|
|
1279
|
+
const KeyR = 46;
|
|
1280
|
+
const KeyS = 47;
|
|
1281
|
+
const KeyT = 48;
|
|
1282
|
+
const KeyU = 49;
|
|
1283
|
+
const KeyV = 50;
|
|
1284
|
+
const KeyW = 51;
|
|
1285
|
+
const KeyX = 52;
|
|
1286
|
+
const KeyY = 53;
|
|
1287
|
+
const KeyZ = 54;
|
|
1288
|
+
const Meta = 55;
|
|
1289
|
+
const ContextMenu = 56;
|
|
1290
|
+
const F1 = 57;
|
|
1291
|
+
const F2 = 58;
|
|
1292
|
+
const F3 = 59;
|
|
1293
|
+
const F4 = 60;
|
|
1294
|
+
const F5 = 61;
|
|
1295
|
+
const F6 = 62;
|
|
1296
|
+
const F7 = 63;
|
|
1297
|
+
const F8 = 64;
|
|
1298
|
+
const F9 = 65;
|
|
1299
|
+
const F10 = 66;
|
|
1300
|
+
const F11 = 67;
|
|
1301
|
+
const F12 = 68;
|
|
1302
|
+
const F13 = 69;
|
|
1303
|
+
const F14 = 70;
|
|
1304
|
+
const F15 = 71;
|
|
1305
|
+
const F16 = 72;
|
|
1306
|
+
const F17 = 72;
|
|
1307
|
+
const F18 = 74;
|
|
1308
|
+
const F19 = 75;
|
|
1309
|
+
const F20 = 76;
|
|
1310
|
+
const F21 = 77;
|
|
1311
|
+
const F22 = 78;
|
|
1312
|
+
const F23 = 79;
|
|
1313
|
+
const F24 = 80;
|
|
1314
|
+
const NumLock = 81;
|
|
1315
|
+
const ScrollLock = 82;
|
|
1316
|
+
const SemiColon = 83;
|
|
1317
|
+
const Equal = 84;
|
|
1318
|
+
const Comma = 85;
|
|
1319
|
+
const Minus = 86;
|
|
1320
|
+
const Period = 87;
|
|
1321
|
+
const Slash$1 = 88;
|
|
1322
|
+
const Backquote = 89;
|
|
1323
|
+
const BracketLeft = 90;
|
|
1324
|
+
const Backslash = 91;
|
|
1325
|
+
const BracketRight = 92;
|
|
1326
|
+
const Quote = 93;
|
|
1327
|
+
const OEM_8 = 94;
|
|
1328
|
+
const IntlBackslash = 95;
|
|
1329
|
+
const Numpad0 = 96;
|
|
1330
|
+
const Numpad1 = 97;
|
|
1331
|
+
const Numpad2 = 98;
|
|
1332
|
+
const Numpad3 = 99;
|
|
1333
|
+
const Numpad4 = 100;
|
|
1334
|
+
const Numpad5 = 101;
|
|
1335
|
+
const Numpad6 = 102;
|
|
1336
|
+
const Numpad7 = 103;
|
|
1337
|
+
const Numpad8 = 104;
|
|
1338
|
+
const Numpad9 = 105;
|
|
1339
|
+
const NumpadMultiply = 106;
|
|
1340
|
+
const NumpadAdd = 107;
|
|
1341
|
+
const NumpadSeparator = 108;
|
|
1342
|
+
const NumpadSubtract = 109;
|
|
1343
|
+
const NumpadDecimal = 110;
|
|
1344
|
+
const NumpadDivide = 111;
|
|
1345
|
+
const KeyInComposition = 112;
|
|
1346
|
+
const ABNT_C1 = 113;
|
|
1347
|
+
const ABNT_C2 = 114;
|
|
1348
|
+
const AudioVolumeMute = 115;
|
|
1349
|
+
const AudioVolumeUp = 116;
|
|
1350
|
+
const AudioVolumeDown = 117;
|
|
1351
|
+
const BrowserSearch = 118;
|
|
1352
|
+
const BrowserHome = 119;
|
|
1353
|
+
const BrowserBack = 120;
|
|
1354
|
+
const BrowserForward = 121;
|
|
1355
|
+
const MediaTrackNext = 122;
|
|
1356
|
+
const MediaTrackPrevious = 123;
|
|
1357
|
+
const MediaStop = 124;
|
|
1358
|
+
const MediaPlayPause = 125;
|
|
1359
|
+
const LaunchMediaPlayer = 126;
|
|
1360
|
+
const LaunchMail = 127;
|
|
1361
|
+
const LaunchApp2 = 128;
|
|
1362
|
+
const Clear = 129;
|
|
1363
|
+
const MaxValue = 130;
|
|
1364
|
+
const Star = 131;
|
|
1365
|
+
const Plus = 132;
|
|
1366
|
+
|
|
1367
|
+
const KeyCode = {
|
|
1368
|
+
__proto__: null,
|
|
1369
|
+
ABNT_C1,
|
|
1370
|
+
ABNT_C2,
|
|
1371
|
+
Alt,
|
|
1372
|
+
AudioVolumeDown,
|
|
1373
|
+
AudioVolumeMute,
|
|
1374
|
+
AudioVolumeUp,
|
|
1375
|
+
Backquote,
|
|
1376
|
+
Backslash,
|
|
1377
|
+
Backspace,
|
|
1378
|
+
BracketLeft,
|
|
1379
|
+
BracketRight,
|
|
1380
|
+
BrowserBack,
|
|
1381
|
+
BrowserForward,
|
|
1382
|
+
BrowserHome,
|
|
1383
|
+
BrowserSearch,
|
|
1384
|
+
CapsLock,
|
|
1385
|
+
Clear,
|
|
1386
|
+
Comma,
|
|
1387
|
+
ContextMenu,
|
|
1388
|
+
Ctrl,
|
|
1389
|
+
Delete,
|
|
1390
|
+
Digit0,
|
|
1391
|
+
Digit1,
|
|
1392
|
+
Digit2,
|
|
1393
|
+
Digit3,
|
|
1394
|
+
Digit4,
|
|
1395
|
+
Digit5,
|
|
1396
|
+
Digit6,
|
|
1397
|
+
Digit7,
|
|
1398
|
+
Digit8,
|
|
1399
|
+
Digit9,
|
|
1400
|
+
DownArrow: DownArrow$1,
|
|
1401
|
+
End,
|
|
1402
|
+
Enter: Enter$1,
|
|
1403
|
+
Equal,
|
|
1404
|
+
Escape: Escape$1,
|
|
1405
|
+
F1,
|
|
1406
|
+
F10,
|
|
1407
|
+
F11,
|
|
1408
|
+
F12,
|
|
1409
|
+
F13,
|
|
1410
|
+
F14,
|
|
1411
|
+
F15,
|
|
1412
|
+
F16,
|
|
1413
|
+
F17,
|
|
1414
|
+
F18,
|
|
1415
|
+
F19,
|
|
1416
|
+
F2,
|
|
1417
|
+
F20,
|
|
1418
|
+
F21,
|
|
1419
|
+
F22,
|
|
1420
|
+
F23,
|
|
1421
|
+
F24,
|
|
1422
|
+
F3,
|
|
1423
|
+
F4,
|
|
1424
|
+
F5,
|
|
1425
|
+
F6,
|
|
1426
|
+
F7,
|
|
1427
|
+
F8,
|
|
1428
|
+
F9,
|
|
1429
|
+
Home,
|
|
1430
|
+
Insert,
|
|
1431
|
+
IntlBackslash,
|
|
1432
|
+
KeyA,
|
|
1433
|
+
KeyB,
|
|
1434
|
+
KeyC,
|
|
1435
|
+
KeyD,
|
|
1436
|
+
KeyE,
|
|
1437
|
+
KeyF,
|
|
1438
|
+
KeyG,
|
|
1439
|
+
KeyH,
|
|
1440
|
+
KeyI,
|
|
1441
|
+
KeyInComposition,
|
|
1442
|
+
KeyJ,
|
|
1443
|
+
KeyK,
|
|
1444
|
+
KeyL,
|
|
1445
|
+
KeyM,
|
|
1446
|
+
KeyN,
|
|
1447
|
+
KeyO,
|
|
1448
|
+
KeyP,
|
|
1449
|
+
KeyQ,
|
|
1450
|
+
KeyR,
|
|
1451
|
+
KeyS,
|
|
1452
|
+
KeyT,
|
|
1453
|
+
KeyU,
|
|
1454
|
+
KeyV,
|
|
1455
|
+
KeyW,
|
|
1456
|
+
KeyX,
|
|
1457
|
+
KeyY,
|
|
1458
|
+
KeyZ,
|
|
1459
|
+
LaunchApp2,
|
|
1460
|
+
LaunchMail,
|
|
1461
|
+
LaunchMediaPlayer,
|
|
1462
|
+
LeftArrow,
|
|
1463
|
+
MaxValue,
|
|
1464
|
+
MediaPlayPause,
|
|
1465
|
+
MediaStop,
|
|
1466
|
+
MediaTrackNext,
|
|
1467
|
+
MediaTrackPrevious,
|
|
1468
|
+
Meta,
|
|
1469
|
+
Minus,
|
|
1470
|
+
NumLock,
|
|
1471
|
+
Numpad0,
|
|
1472
|
+
Numpad1,
|
|
1473
|
+
Numpad2,
|
|
1474
|
+
Numpad3,
|
|
1475
|
+
Numpad4,
|
|
1476
|
+
Numpad5,
|
|
1477
|
+
Numpad6,
|
|
1478
|
+
Numpad7,
|
|
1479
|
+
Numpad8,
|
|
1480
|
+
Numpad9,
|
|
1481
|
+
NumpadAdd,
|
|
1482
|
+
NumpadDecimal,
|
|
1483
|
+
NumpadDivide,
|
|
1484
|
+
NumpadMultiply,
|
|
1485
|
+
NumpadSeparator,
|
|
1486
|
+
NumpadSubtract,
|
|
1487
|
+
OEM_8,
|
|
1488
|
+
PageDown: PageDown$1,
|
|
1489
|
+
PageUp: PageUp$1,
|
|
1490
|
+
PauseBreak,
|
|
1491
|
+
Period,
|
|
1492
|
+
Plus,
|
|
1493
|
+
Quote,
|
|
1494
|
+
RightArrow,
|
|
1495
|
+
ScrollLock,
|
|
1496
|
+
SemiColon,
|
|
1497
|
+
Slash: Slash$1,
|
|
1498
|
+
Space: Space$1,
|
|
1499
|
+
Star,
|
|
1500
|
+
Tab,
|
|
1501
|
+
Unknown,
|
|
1502
|
+
UpArrow: UpArrow$1
|
|
1503
|
+
};
|
|
1504
|
+
|
|
1232
1505
|
const EditorWorker = 99;
|
|
1233
1506
|
const ExtensionManagementWorker = 9006;
|
|
1234
1507
|
const RendererProcess = 1670;
|
|
@@ -1393,6 +1666,47 @@ const close = async state => {
|
|
|
1393
1666
|
return state;
|
|
1394
1667
|
};
|
|
1395
1668
|
|
|
1669
|
+
const Commands = 'quickPick://commands';
|
|
1670
|
+
const EveryThing = 'quickPick://everything';
|
|
1671
|
+
const Recent = 'quickPick://recent';
|
|
1672
|
+
const ColorTheme = 'quickPick://color-theme';
|
|
1673
|
+
const LanguageMode = 'quickPick://language-mode';
|
|
1674
|
+
const Symbol$2 = 'quickPick://symbol';
|
|
1675
|
+
const View$2 = 'quickPick://view';
|
|
1676
|
+
const Help$1 = 'quickPick://help';
|
|
1677
|
+
const WorkspaceSymbol$1 = 'quickPick://workspace-symbol';
|
|
1678
|
+
const Custom = 'quickPick://custom';
|
|
1679
|
+
const GoToLine$1 = 'quickPick://go-to-line';
|
|
1680
|
+
const EndOfLine = 'quickPick://end-of-line';
|
|
1681
|
+
const Indentation = 'quickPick://indentation';
|
|
1682
|
+
|
|
1683
|
+
const getQuickPickProviderId = prefix => {
|
|
1684
|
+
switch (prefix) {
|
|
1685
|
+
case ColorTheme:
|
|
1686
|
+
return ColorTheme$1;
|
|
1687
|
+
case Commands:
|
|
1688
|
+
case EveryThing:
|
|
1689
|
+
case GoToLine$1:
|
|
1690
|
+
case Help$1:
|
|
1691
|
+
case Symbol$2:
|
|
1692
|
+
case View$2:
|
|
1693
|
+
case WorkspaceSymbol$1:
|
|
1694
|
+
return EveryThing$1;
|
|
1695
|
+
case Custom:
|
|
1696
|
+
return Custom$1;
|
|
1697
|
+
case EndOfLine:
|
|
1698
|
+
return EndOfLine$1;
|
|
1699
|
+
case Indentation:
|
|
1700
|
+
return Indentation$1;
|
|
1701
|
+
case LanguageMode:
|
|
1702
|
+
return LanguageMode$1;
|
|
1703
|
+
case Recent:
|
|
1704
|
+
return Recent$1;
|
|
1705
|
+
default:
|
|
1706
|
+
return File$1;
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1396
1710
|
const User = 1;
|
|
1397
1711
|
const Script = 2;
|
|
1398
1712
|
|
|
@@ -1929,6 +2243,7 @@ const handleScrollBarPointerUp = (state, pointerId) => {
|
|
|
1929
2243
|
};
|
|
1930
2244
|
|
|
1931
2245
|
const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, _renderAllItems, workspaceUri, assetDir, applicationId) => {
|
|
2246
|
+
const providerId = getQuickPickProviderId(uri);
|
|
1932
2247
|
const state = {
|
|
1933
2248
|
allowEmptyResult: false,
|
|
1934
2249
|
applicationId,
|
|
@@ -1960,6 +2275,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, _
|
|
|
1960
2275
|
inputSource: User,
|
|
1961
2276
|
placeholder: '',
|
|
1962
2277
|
platform,
|
|
2278
|
+
providerId,
|
|
1963
2279
|
value: ''
|
|
1964
2280
|
};
|
|
1965
2281
|
set$5(uid, state, state);
|
|
@@ -2336,32 +2652,32 @@ const getNewValue = (value, inputType, data, selectionStart, selectionEnd) => {
|
|
|
2336
2652
|
};
|
|
2337
2653
|
|
|
2338
2654
|
const Command = '>';
|
|
2339
|
-
const Symbol$
|
|
2340
|
-
const WorkspaceSymbol
|
|
2341
|
-
const GoToLine
|
|
2342
|
-
const View$
|
|
2655
|
+
const Symbol$1 = '@';
|
|
2656
|
+
const WorkspaceSymbol = '#';
|
|
2657
|
+
const GoToLine = ':';
|
|
2658
|
+
const View$1 = 'view ';
|
|
2343
2659
|
const None$1 = '';
|
|
2344
|
-
const Help
|
|
2660
|
+
const Help = '?';
|
|
2345
2661
|
const GoToColumn = '::';
|
|
2346
2662
|
|
|
2347
2663
|
const getQuickPickPrefix = value => {
|
|
2348
2664
|
if (value.startsWith(Command)) {
|
|
2349
2665
|
return Command;
|
|
2350
2666
|
}
|
|
2351
|
-
if (value.startsWith(Symbol$
|
|
2352
|
-
return Symbol$
|
|
2667
|
+
if (value.startsWith(Symbol$1)) {
|
|
2668
|
+
return Symbol$1;
|
|
2353
2669
|
}
|
|
2354
|
-
if (value.startsWith(WorkspaceSymbol
|
|
2355
|
-
return WorkspaceSymbol
|
|
2670
|
+
if (value.startsWith(WorkspaceSymbol)) {
|
|
2671
|
+
return WorkspaceSymbol;
|
|
2356
2672
|
}
|
|
2357
2673
|
if (value.startsWith(GoToColumn)) {
|
|
2358
2674
|
return GoToColumn;
|
|
2359
2675
|
}
|
|
2360
|
-
if (value.startsWith(GoToLine
|
|
2361
|
-
return GoToLine
|
|
2676
|
+
if (value.startsWith(GoToLine)) {
|
|
2677
|
+
return GoToLine;
|
|
2362
2678
|
}
|
|
2363
|
-
if (value.startsWith(View$
|
|
2364
|
-
return View$
|
|
2679
|
+
if (value.startsWith(View$1)) {
|
|
2680
|
+
return View$1;
|
|
2365
2681
|
}
|
|
2366
2682
|
return None$1;
|
|
2367
2683
|
};
|
|
@@ -2378,15 +2694,15 @@ const getQuickPickSubProviderId = (id, prefix) => {
|
|
|
2378
2694
|
return Commands$1;
|
|
2379
2695
|
case GoToColumn:
|
|
2380
2696
|
return GoToColumn$1;
|
|
2381
|
-
case GoToLine
|
|
2697
|
+
case GoToLine:
|
|
2382
2698
|
return GoToLine$2;
|
|
2383
|
-
case Help
|
|
2699
|
+
case Help:
|
|
2384
2700
|
return Help$2;
|
|
2385
|
-
case Symbol$
|
|
2701
|
+
case Symbol$1:
|
|
2386
2702
|
return Symbol$3;
|
|
2387
|
-
case View$
|
|
2703
|
+
case View$1:
|
|
2388
2704
|
return View$3;
|
|
2389
|
-
case WorkspaceSymbol
|
|
2705
|
+
case WorkspaceSymbol:
|
|
2390
2706
|
return WorkspaceSymbol$2;
|
|
2391
2707
|
default:
|
|
2392
2708
|
return File$1;
|
|
@@ -3233,20 +3549,23 @@ const getWorkspaceDisplayPath = workspace => {
|
|
|
3233
3549
|
};
|
|
3234
3550
|
}
|
|
3235
3551
|
const url = new URL(workspace);
|
|
3552
|
+
const uriPrefix = url.search || url.hash || !url.pathname.startsWith('/') ? undefined : `${url.protocol}//${url.host}${trimTrailingSeparators(url.pathname)}/`;
|
|
3236
3553
|
return {
|
|
3237
3554
|
host: url.host,
|
|
3238
3555
|
path: decodeURIComponent(url.pathname),
|
|
3239
|
-
scheme: url.protocol
|
|
3556
|
+
scheme: url.protocol,
|
|
3557
|
+
uriPrefix,
|
|
3558
|
+
url
|
|
3240
3559
|
};
|
|
3241
3560
|
};
|
|
3242
|
-
const
|
|
3243
|
-
|
|
3244
|
-
if (hasUriScheme(uri)) {
|
|
3561
|
+
const isSafeRelativePath = path => /^[a-z\d._~/-]+$/i.test(path) && path.split('/').every(segment => segment !== '.' && segment !== '..');
|
|
3562
|
+
const getRelativeDirectory = (workspacePath, uri, dirName, isWorkspaceRelative) => {
|
|
3563
|
+
if (!isWorkspaceRelative && hasUriScheme(uri)) {
|
|
3245
3564
|
const url = new URL(uri);
|
|
3246
3565
|
if (workspacePath.scheme !== url.protocol || workspacePath.host !== url.host) {
|
|
3247
3566
|
return dirName;
|
|
3248
3567
|
}
|
|
3249
|
-
} else if (workspacePath.scheme) {
|
|
3568
|
+
} else if (!isWorkspaceRelative && workspacePath.scheme) {
|
|
3250
3569
|
return dirName;
|
|
3251
3570
|
}
|
|
3252
3571
|
const normalizedWorkspace = trimTrailingSeparators(workspacePath.path);
|
|
@@ -3260,15 +3579,18 @@ const getRelativeDirectory = (workspace, uri, dirName) => {
|
|
|
3260
3579
|
}
|
|
3261
3580
|
return normalizedDirectory.slice(prefix.length);
|
|
3262
3581
|
};
|
|
3263
|
-
const resolveFileUri = (workspace, path) => {
|
|
3582
|
+
const resolveFileUri = (workspace, path, workspacePath) => {
|
|
3264
3583
|
if (hasUriScheme(path)) {
|
|
3265
3584
|
return path;
|
|
3266
3585
|
}
|
|
3267
|
-
if (
|
|
3268
|
-
|
|
3586
|
+
if (workspacePath.url) {
|
|
3587
|
+
if (workspacePath.uriPrefix && !isAbsolutePath(path) && isSafeRelativePath(path)) {
|
|
3588
|
+
return `${workspacePath.uriPrefix}${path}`;
|
|
3589
|
+
}
|
|
3590
|
+
const workspaceUrl = new URL(workspacePath.url);
|
|
3269
3591
|
const normalizedPath = path.replaceAll('\\', '/').replaceAll('%', '%25');
|
|
3270
|
-
const
|
|
3271
|
-
workspaceUrl.pathname = normalizedPath.startsWith('/') ? normalizedPath : `${
|
|
3592
|
+
const workspaceUrlPath = trimTrailingSeparators(workspaceUrl.pathname);
|
|
3593
|
+
workspaceUrl.pathname = normalizedPath.startsWith('/') ? normalizedPath : `${workspaceUrlPath}/${normalizedPath}`;
|
|
3272
3594
|
return workspaceUrl.href;
|
|
3273
3595
|
}
|
|
3274
3596
|
if (isAbsolutePath(path)) {
|
|
@@ -3276,11 +3598,17 @@ const resolveFileUri = (workspace, path) => {
|
|
|
3276
3598
|
}
|
|
3277
3599
|
return `${trimTrailingSeparators(workspace)}/${path}`;
|
|
3278
3600
|
};
|
|
3279
|
-
const convertToPick = (
|
|
3280
|
-
const
|
|
3601
|
+
const convertToPick = (workspacePath, uri, path) => {
|
|
3602
|
+
const isWorkspaceRelative = Boolean(workspacePath.uriPrefix && !isAbsolutePath(path) && !hasUriScheme(path) && isSafeRelativePath(path));
|
|
3603
|
+
let displayPath = uri.replaceAll('\\', '/');
|
|
3604
|
+
if (isWorkspaceRelative) {
|
|
3605
|
+
displayPath = `${trimTrailingSeparators(workspacePath.path)}/${path}`;
|
|
3606
|
+
} else if (hasUriScheme(uri)) {
|
|
3607
|
+
displayPath = decodeURIComponent(new URL(uri).pathname);
|
|
3608
|
+
}
|
|
3281
3609
|
const baseName = pathBaseName(displayPath);
|
|
3282
3610
|
const dirName = pathDirName(displayPath);
|
|
3283
|
-
const description = getRelativeDirectory(
|
|
3611
|
+
const description = getRelativeDirectory(workspacePath, uri, dirName, isWorkspaceRelative);
|
|
3284
3612
|
return {
|
|
3285
3613
|
description,
|
|
3286
3614
|
direntType: File,
|
|
@@ -3331,7 +3659,11 @@ const getPicks$b = async searchValue => {
|
|
|
3331
3659
|
});
|
|
3332
3660
|
}
|
|
3333
3661
|
}
|
|
3334
|
-
|
|
3662
|
+
if (files.length === 0) {
|
|
3663
|
+
return [];
|
|
3664
|
+
}
|
|
3665
|
+
const workspacePath = getWorkspaceDisplayPath(workspace);
|
|
3666
|
+
const picks = files.map(path => convertToPick(workspacePath, resolveFileUri(workspace, path, workspacePath), path));
|
|
3335
3667
|
return picks;
|
|
3336
3668
|
};
|
|
3337
3669
|
|
|
@@ -3493,7 +3825,7 @@ const getPicksGoToLineBase = async () => {
|
|
|
3493
3825
|
};
|
|
3494
3826
|
|
|
3495
3827
|
const parseGoToLinePosition = value => {
|
|
3496
|
-
const [lineString, columnString = '1'] = value.slice(GoToLine
|
|
3828
|
+
const [lineString, columnString = '1'] = value.slice(GoToLine.length).split(':');
|
|
3497
3829
|
const line = Number(lineString);
|
|
3498
3830
|
const column = Number(columnString);
|
|
3499
3831
|
if (!Number.isSafeInteger(line) || !Number.isSafeInteger(column) || line < 1 || column < 1) {
|
|
@@ -3506,10 +3838,10 @@ const parseGoToLinePosition = value => {
|
|
|
3506
3838
|
};
|
|
3507
3839
|
|
|
3508
3840
|
const getPicks$a = async value => {
|
|
3509
|
-
if (value === GoToLine
|
|
3841
|
+
if (value === GoToLine) {
|
|
3510
3842
|
return getPicksGoToLineBase();
|
|
3511
3843
|
}
|
|
3512
|
-
if (value.startsWith(GoToLine
|
|
3844
|
+
if (value.startsWith(GoToLine)) {
|
|
3513
3845
|
const position = parseGoToLinePosition(value);
|
|
3514
3846
|
if (!position) {
|
|
3515
3847
|
return getPicksGoToLineBase();
|
|
@@ -3531,7 +3863,7 @@ const DotDotDot = '...';
|
|
|
3531
3863
|
const Colon = ':';
|
|
3532
3864
|
const Percent = '%';
|
|
3533
3865
|
const AngleBracket = '>';
|
|
3534
|
-
const View
|
|
3866
|
+
const View = 'view';
|
|
3535
3867
|
|
|
3536
3868
|
const getPicks$9 = async () => {
|
|
3537
3869
|
return [{
|
|
@@ -3579,7 +3911,7 @@ const getPicks$9 = async () => {
|
|
|
3579
3911
|
direntType: None$2,
|
|
3580
3912
|
fileIcon: '',
|
|
3581
3913
|
icon: '',
|
|
3582
|
-
label: View
|
|
3914
|
+
label: View,
|
|
3583
3915
|
matches: [],
|
|
3584
3916
|
uri: ''
|
|
3585
3917
|
}];
|
|
@@ -3951,7 +4283,7 @@ const selectPickGoToColumn = async (item, value) => {
|
|
|
3951
4283
|
};
|
|
3952
4284
|
|
|
3953
4285
|
const selectPick$7 = async (item, value) => {
|
|
3954
|
-
if (value.startsWith(GoToLine
|
|
4286
|
+
if (value.startsWith(GoToLine)) {
|
|
3955
4287
|
const position = parseGoToLinePosition(value);
|
|
3956
4288
|
if (position) {
|
|
3957
4289
|
await goToPositionAndFocus(position.rowIndex, position.columnIndex);
|
|
@@ -4051,291 +4383,405 @@ const getPicks = (id, searchValue, args, {
|
|
|
4051
4383
|
});
|
|
4052
4384
|
};
|
|
4053
4385
|
|
|
4054
|
-
const
|
|
4055
|
-
|
|
4056
|
-
value: 0
|
|
4386
|
+
const mergeClassNames = (...classNames) => {
|
|
4387
|
+
return classNames.filter(Boolean).join(' ');
|
|
4057
4388
|
};
|
|
4058
|
-
|
|
4059
|
-
|
|
4389
|
+
|
|
4390
|
+
const text = data => {
|
|
4391
|
+
return {
|
|
4392
|
+
childCount: 0,
|
|
4393
|
+
text: data,
|
|
4394
|
+
type: Text
|
|
4395
|
+
};
|
|
4060
4396
|
};
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4397
|
+
|
|
4398
|
+
const SetText = 1;
|
|
4399
|
+
const Replace = 2;
|
|
4400
|
+
const SetAttribute = 3;
|
|
4401
|
+
const RemoveAttribute = 4;
|
|
4402
|
+
const Add = 6;
|
|
4403
|
+
const NavigateChild = 7;
|
|
4404
|
+
const NavigateParent = 8;
|
|
4405
|
+
const RemoveChild = 9;
|
|
4406
|
+
const NavigateSibling = 10;
|
|
4407
|
+
const SetReferenceNodeUid = 11;
|
|
4408
|
+
const MultiNavigation = 18;
|
|
4409
|
+
|
|
4410
|
+
const isKey = key => {
|
|
4411
|
+
return key !== 'type' && key !== 'childCount';
|
|
4064
4412
|
};
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4413
|
+
|
|
4414
|
+
const getKeys = node => {
|
|
4415
|
+
const keys = Object.keys(node).filter(isKey);
|
|
4416
|
+
return keys;
|
|
4068
4417
|
};
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4418
|
+
|
|
4419
|
+
const arrayToTree = nodes => {
|
|
4420
|
+
const result = [];
|
|
4421
|
+
let i = 0;
|
|
4422
|
+
while (i < nodes.length) {
|
|
4423
|
+
const node = nodes[i];
|
|
4424
|
+
const {
|
|
4425
|
+
children,
|
|
4426
|
+
nodesConsumed
|
|
4427
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
4428
|
+
result.push({
|
|
4429
|
+
node,
|
|
4430
|
+
children
|
|
4431
|
+
});
|
|
4432
|
+
i += 1 + nodesConsumed;
|
|
4084
4433
|
}
|
|
4085
|
-
|
|
4434
|
+
return result;
|
|
4435
|
+
};
|
|
4436
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
4437
|
+
if (childCount === 0) {
|
|
4086
4438
|
return {
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
value: newValue
|
|
4439
|
+
children: [],
|
|
4440
|
+
nodesConsumed: 0
|
|
4090
4441
|
};
|
|
4091
4442
|
}
|
|
4092
|
-
const
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4443
|
+
const children = [];
|
|
4444
|
+
let i = startIndex;
|
|
4445
|
+
let remaining = childCount;
|
|
4446
|
+
let totalConsumed = 0;
|
|
4447
|
+
while (remaining > 0 && i < nodes.length) {
|
|
4448
|
+
const node = nodes[i];
|
|
4449
|
+
const nodeChildCount = node.childCount || 0;
|
|
4450
|
+
const {
|
|
4451
|
+
children: nodeChildren,
|
|
4452
|
+
nodesConsumed
|
|
4453
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
4454
|
+
children.push({
|
|
4455
|
+
node,
|
|
4456
|
+
children: nodeChildren
|
|
4457
|
+
});
|
|
4458
|
+
const nodeSize = 1 + nodesConsumed;
|
|
4459
|
+
i += nodeSize;
|
|
4460
|
+
totalConsumed += nodeSize;
|
|
4461
|
+
remaining--;
|
|
4462
|
+
}
|
|
4111
4463
|
return {
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
finalDeltaY,
|
|
4115
|
-
focusedIndex,
|
|
4116
|
-
icons,
|
|
4117
|
-
inputSource: Script,
|
|
4118
|
-
items,
|
|
4119
|
-
picks: newPicks,
|
|
4120
|
-
value: newValue
|
|
4464
|
+
children,
|
|
4465
|
+
nodesConsumed: totalConsumed
|
|
4121
4466
|
};
|
|
4122
4467
|
};
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4468
|
+
|
|
4469
|
+
const isNavigationPatch = patch => {
|
|
4470
|
+
switch (patch.type) {
|
|
4471
|
+
case NavigateChild:
|
|
4472
|
+
case NavigateParent:
|
|
4473
|
+
case NavigateSibling:
|
|
4474
|
+
return true;
|
|
4475
|
+
default:
|
|
4476
|
+
return false;
|
|
4477
|
+
}
|
|
4478
|
+
};
|
|
4479
|
+
const getNavigationIndex = patch => {
|
|
4480
|
+
switch (patch.type) {
|
|
4481
|
+
case NavigateChild:
|
|
4482
|
+
case NavigateSibling:
|
|
4483
|
+
return patch.index;
|
|
4484
|
+
default:
|
|
4485
|
+
return 0;
|
|
4486
|
+
}
|
|
4487
|
+
};
|
|
4488
|
+
const appendNavigationPatch = (patches, type, index) => {
|
|
4489
|
+
const previousPatch = patches.at(-1);
|
|
4490
|
+
if (!previousPatch) {
|
|
4491
|
+
patches.push(type === NavigateParent ? {
|
|
4492
|
+
type
|
|
4493
|
+
} : {
|
|
4494
|
+
index,
|
|
4495
|
+
type
|
|
4496
|
+
});
|
|
4126
4497
|
return;
|
|
4127
4498
|
}
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
...latestState,
|
|
4137
|
-
fileIconCache: result.fileIconCache,
|
|
4138
|
-
finalDeltaY: result.finalDeltaY,
|
|
4139
|
-
focusedIndex: result.focusedIndex,
|
|
4140
|
-
icons: result.icons,
|
|
4141
|
-
inputSource: result.inputSource,
|
|
4142
|
-
items: result.items,
|
|
4143
|
-
picks: result.picks,
|
|
4144
|
-
value: result.value
|
|
4499
|
+
if (previousPatch.type === MultiNavigation) {
|
|
4500
|
+
previousPatch.navigations.push(type, index);
|
|
4501
|
+
return;
|
|
4502
|
+
}
|
|
4503
|
+
if (isNavigationPatch(previousPatch)) {
|
|
4504
|
+
patches[patches.length - 1] = {
|
|
4505
|
+
navigations: [previousPatch.type, getNavigationIndex(previousPatch), type, index],
|
|
4506
|
+
type: MultiNavigation
|
|
4145
4507
|
};
|
|
4146
|
-
|
|
4147
|
-
if (requestVersions.get(state.uid) === requestVersion) {
|
|
4148
|
-
requestVersions.delete(state.uid);
|
|
4508
|
+
return;
|
|
4149
4509
|
}
|
|
4510
|
+
patches.push(type === NavigateParent ? {
|
|
4511
|
+
type
|
|
4512
|
+
} : {
|
|
4513
|
+
index,
|
|
4514
|
+
type
|
|
4515
|
+
});
|
|
4150
4516
|
};
|
|
4151
4517
|
|
|
4152
|
-
const
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4518
|
+
const compareNodes = (oldNode, newNode) => {
|
|
4519
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
4520
|
+
// (caller should handle this with a Replace operation)
|
|
4521
|
+
if (oldNode.type !== newNode.type) {
|
|
4522
|
+
return null;
|
|
4523
|
+
}
|
|
4524
|
+
const patches = [];
|
|
4525
|
+
// Handle reference nodes - special handling for uid changes
|
|
4526
|
+
if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
|
|
4527
|
+
patches.push({
|
|
4528
|
+
type: SetReferenceNodeUid,
|
|
4529
|
+
uid: newNode.uid
|
|
4530
|
+
});
|
|
4531
|
+
}
|
|
4532
|
+
// Handle text nodes
|
|
4533
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
4534
|
+
if (oldNode.text !== newNode.text) {
|
|
4535
|
+
patches.push({
|
|
4536
|
+
type: SetText,
|
|
4537
|
+
value: newNode.text
|
|
4538
|
+
});
|
|
4160
4539
|
}
|
|
4161
|
-
return
|
|
4162
|
-
...latestState,
|
|
4163
|
-
cursorOffset,
|
|
4164
|
-
inputSource
|
|
4165
|
-
};
|
|
4166
|
-
});
|
|
4167
|
-
};
|
|
4168
|
-
|
|
4169
|
-
// TODO when user types letters -> no need to query provider again -> just filter existing results
|
|
4170
|
-
const handleInput = async (state, newValue, cursorOffset, inputSource = Script) => {
|
|
4171
|
-
if (state.value === newValue) {
|
|
4172
|
-
return {
|
|
4173
|
-
...state,
|
|
4174
|
-
cursorOffset,
|
|
4175
|
-
inputSource
|
|
4176
|
-
};
|
|
4540
|
+
return patches;
|
|
4177
4541
|
}
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
const {
|
|
4191
|
-
value
|
|
4192
|
-
} = state;
|
|
4193
|
-
const {
|
|
4194
|
-
cursorOffset,
|
|
4195
|
-
newValue
|
|
4196
|
-
} = getNewValue(value, inputType, data, selectionStart, selectionEnd);
|
|
4197
|
-
return handleInput(state, newValue, cursorOffset, User);
|
|
4198
|
-
};
|
|
4199
|
-
|
|
4200
|
-
const getCancelResult = args => {
|
|
4201
|
-
const last = args.at(-1);
|
|
4202
|
-
if (last && typeof last === 'object' &&
|
|
4203
|
-
// @ts-ignore
|
|
4204
|
-
last.mode === 'quickPick') {
|
|
4205
|
-
return undefined;
|
|
4542
|
+
// Compare attributes
|
|
4543
|
+
const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
|
|
4544
|
+
const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
|
|
4545
|
+
// Check for attribute changes
|
|
4546
|
+
for (const key of newKeys) {
|
|
4547
|
+
if (oldNode[key] !== newNode[key]) {
|
|
4548
|
+
patches.push({
|
|
4549
|
+
type: SetAttribute,
|
|
4550
|
+
key,
|
|
4551
|
+
value: newNode[key]
|
|
4552
|
+
});
|
|
4553
|
+
}
|
|
4206
4554
|
}
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
args,
|
|
4215
|
-
providerId
|
|
4216
|
-
} = state;
|
|
4217
|
-
if (providerId === Custom$1) {
|
|
4218
|
-
const options = args.at(-1);
|
|
4219
|
-
if (!options?.executeItemCommand) {
|
|
4220
|
-
const resolveId = args[2];
|
|
4221
|
-
await invoke$4('QuickPick.executeCallback', resolveId, getCancelResult(args));
|
|
4555
|
+
// Check for removed attributes
|
|
4556
|
+
for (const key of oldKeys) {
|
|
4557
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
4558
|
+
patches.push({
|
|
4559
|
+
type: RemoveAttribute,
|
|
4560
|
+
key
|
|
4561
|
+
});
|
|
4222
4562
|
}
|
|
4223
4563
|
}
|
|
4224
|
-
|
|
4225
|
-
return state;
|
|
4564
|
+
return patches;
|
|
4226
4565
|
};
|
|
4227
4566
|
|
|
4228
|
-
const
|
|
4229
|
-
const
|
|
4230
|
-
const
|
|
4231
|
-
|
|
4567
|
+
const treeToArray = node => {
|
|
4568
|
+
const result = [];
|
|
4569
|
+
const stack = [node];
|
|
4570
|
+
while (stack.length > 0) {
|
|
4571
|
+
const current = stack.pop();
|
|
4572
|
+
result.push(current.node);
|
|
4573
|
+
for (let i = current.children.length - 1; i >= 0; i--) {
|
|
4574
|
+
stack.push(current.children[i]);
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
return result;
|
|
4232
4578
|
};
|
|
4233
4579
|
|
|
4234
|
-
const
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
const LanguageMode = 'quickPick://language-mode';
|
|
4239
|
-
const Symbol$1 = 'quickPick://symbol';
|
|
4240
|
-
const View = 'quickPick://view';
|
|
4241
|
-
const Help = 'quickPick://help';
|
|
4242
|
-
const WorkspaceSymbol = 'quickPick://workspace-symbol';
|
|
4243
|
-
const Custom = 'quickPick://custom';
|
|
4244
|
-
const GoToLine = 'quickPick://go-to-line';
|
|
4245
|
-
const EndOfLine = 'quickPick://end-of-line';
|
|
4246
|
-
const Indentation = 'quickPick://indentation';
|
|
4247
|
-
|
|
4248
|
-
const getDefaultValue = (id, uri = '', args = []) => {
|
|
4249
|
-
if (uri === GoToLine) {
|
|
4250
|
-
const line = Number(args[1]);
|
|
4251
|
-
const column = Number(args[2]);
|
|
4252
|
-
if (Number.isSafeInteger(line) && Number.isSafeInteger(column) && line >= 1 && column >= 1) {
|
|
4253
|
-
return `${GoToLine$1}${line}:${column}`;
|
|
4254
|
-
}
|
|
4255
|
-
return GoToLine$1;
|
|
4580
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
4581
|
+
if (currentChildIndex === -1) {
|
|
4582
|
+
appendNavigationPatch(patches, NavigateChild, index);
|
|
4583
|
+
return index;
|
|
4256
4584
|
}
|
|
4257
|
-
if (
|
|
4258
|
-
|
|
4585
|
+
if (currentChildIndex !== index) {
|
|
4586
|
+
appendNavigationPatch(patches, NavigateSibling, index);
|
|
4259
4587
|
}
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4588
|
+
return index;
|
|
4589
|
+
};
|
|
4590
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
4591
|
+
if (currentChildIndex >= 0) {
|
|
4592
|
+
appendNavigationPatch(patches, NavigateParent, 0);
|
|
4265
4593
|
}
|
|
4594
|
+
return -1;
|
|
4266
4595
|
};
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
return
|
|
4286
|
-
case
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
return
|
|
4596
|
+
const addTree = (newNode, patches) => {
|
|
4597
|
+
patches.push({
|
|
4598
|
+
type: Add,
|
|
4599
|
+
nodes: treeToArray(newNode)
|
|
4600
|
+
});
|
|
4601
|
+
};
|
|
4602
|
+
const replaceTree = (newNode, patches) => {
|
|
4603
|
+
patches.push({
|
|
4604
|
+
type: Replace,
|
|
4605
|
+
nodes: treeToArray(newNode)
|
|
4606
|
+
});
|
|
4607
|
+
};
|
|
4608
|
+
const appendPatch = (patches, patch) => {
|
|
4609
|
+
switch (patch.type) {
|
|
4610
|
+
case MultiNavigation:
|
|
4611
|
+
for (let i = 0; i < patch.navigations.length; i += 2) {
|
|
4612
|
+
appendNavigationPatch(patches, patch.navigations[i], patch.navigations[i + 1]);
|
|
4613
|
+
}
|
|
4614
|
+
return;
|
|
4615
|
+
case NavigateChild:
|
|
4616
|
+
case NavigateSibling:
|
|
4617
|
+
appendNavigationPatch(patches, patch.type, patch.index);
|
|
4618
|
+
return;
|
|
4619
|
+
case NavigateParent:
|
|
4620
|
+
appendNavigationPatch(patches, patch.type, 0);
|
|
4621
|
+
return;
|
|
4290
4622
|
default:
|
|
4291
|
-
|
|
4623
|
+
patches.push(patch);
|
|
4292
4624
|
}
|
|
4293
4625
|
};
|
|
4294
|
-
|
|
4295
|
-
const
|
|
4296
|
-
|
|
4297
|
-
const {
|
|
4298
|
-
promise,
|
|
4299
|
-
resolve
|
|
4300
|
-
} = Promise.withResolvers();
|
|
4301
|
-
callbacks.push(resolve);
|
|
4302
|
-
return promise;
|
|
4303
|
-
};
|
|
4304
|
-
const notifyVisible = () => {
|
|
4305
|
-
const pendingCallbacks = [...callbacks];
|
|
4306
|
-
callbacks.length = 0;
|
|
4307
|
-
for (const callback of pendingCallbacks) {
|
|
4308
|
-
callback();
|
|
4626
|
+
const appendPatches = (patches, newPatches) => {
|
|
4627
|
+
for (const patch of newPatches) {
|
|
4628
|
+
appendPatch(patches, patch);
|
|
4309
4629
|
}
|
|
4310
4630
|
};
|
|
4311
|
-
|
|
4312
|
-
const
|
|
4313
|
-
if (
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
placeholder: ''
|
|
4318
|
-
};
|
|
4631
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
4632
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
4633
|
+
if (nodePatches === null) {
|
|
4634
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
4635
|
+
replaceTree(newNode, patches);
|
|
4636
|
+
return nextChildIndex;
|
|
4319
4637
|
}
|
|
4320
|
-
const
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
initialValue: '',
|
|
4325
|
-
placeholder: ''
|
|
4326
|
-
};
|
|
4638
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
4639
|
+
const childPatches = [];
|
|
4640
|
+
if (hasChildrenToCompare) {
|
|
4641
|
+
diffChildren(oldNode.children, newNode.children, childPatches);
|
|
4327
4642
|
}
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
const
|
|
4338
|
-
|
|
4643
|
+
if (nodePatches.length === 0 && childPatches.length === 0) {
|
|
4644
|
+
return currentChildIndex;
|
|
4645
|
+
}
|
|
4646
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
4647
|
+
patches.push(...nodePatches);
|
|
4648
|
+
appendPatches(patches, childPatches);
|
|
4649
|
+
return nextChildIndex;
|
|
4650
|
+
};
|
|
4651
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
4652
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
4653
|
+
if (nodePatches === null) {
|
|
4654
|
+
replaceTree(newNode, patches);
|
|
4655
|
+
return;
|
|
4656
|
+
}
|
|
4657
|
+
if (nodePatches.length > 0) {
|
|
4658
|
+
patches.push(...nodePatches);
|
|
4659
|
+
}
|
|
4660
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
4661
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
4662
|
+
}
|
|
4663
|
+
};
|
|
4664
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
4665
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
4666
|
+
let currentChildIndex = -1;
|
|
4667
|
+
const indicesToRemove = [];
|
|
4668
|
+
for (let i = 0; i < maxLength; i++) {
|
|
4669
|
+
const oldNode = oldChildren[i];
|
|
4670
|
+
const newNode = newChildren[i];
|
|
4671
|
+
if (!oldNode && !newNode) {
|
|
4672
|
+
continue;
|
|
4673
|
+
}
|
|
4674
|
+
if (!oldNode) {
|
|
4675
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
4676
|
+
addTree(newNode, patches);
|
|
4677
|
+
continue;
|
|
4678
|
+
}
|
|
4679
|
+
if (!newNode) {
|
|
4680
|
+
indicesToRemove.push(i);
|
|
4681
|
+
continue;
|
|
4682
|
+
}
|
|
4683
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
4684
|
+
}
|
|
4685
|
+
navigateToParent(patches, currentChildIndex);
|
|
4686
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
4687
|
+
patches.push({
|
|
4688
|
+
type: RemoveChild,
|
|
4689
|
+
index: indicesToRemove[j]
|
|
4690
|
+
});
|
|
4691
|
+
}
|
|
4692
|
+
};
|
|
4693
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
4694
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
4695
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
4696
|
+
return;
|
|
4697
|
+
}
|
|
4698
|
+
diffChildren(oldTree, newTree, patches);
|
|
4699
|
+
};
|
|
4700
|
+
|
|
4701
|
+
const removeTrailingNavigationPatches = patches => {
|
|
4702
|
+
while (patches.length > 0) {
|
|
4703
|
+
const patch = patches.at(-1);
|
|
4704
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
|
|
4705
|
+
break;
|
|
4706
|
+
}
|
|
4707
|
+
patches.pop();
|
|
4708
|
+
}
|
|
4709
|
+
return patches;
|
|
4710
|
+
};
|
|
4711
|
+
|
|
4712
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
4713
|
+
// Step 1: Convert flat arrays to tree structures
|
|
4714
|
+
const oldTree = arrayToTree(oldNodes);
|
|
4715
|
+
const newTree = arrayToTree(newNodes);
|
|
4716
|
+
// Step 3: Compare the trees
|
|
4717
|
+
const patches = [];
|
|
4718
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
4719
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
4720
|
+
return removeTrailingNavigationPatches(patches);
|
|
4721
|
+
};
|
|
4722
|
+
|
|
4723
|
+
const keyNames = new Map(Object.entries(KeyCode).map(([name, code]) => [code, name.replace(/^(Key|Digit)/, '')]));
|
|
4724
|
+
const getKeyLabel = key => {
|
|
4725
|
+
if (typeof key === 'string') {
|
|
4726
|
+
return key;
|
|
4727
|
+
}
|
|
4728
|
+
if (typeof key !== 'number' || !Number.isSafeInteger(key) || key <= 0) {
|
|
4729
|
+
return '';
|
|
4730
|
+
}
|
|
4731
|
+
const name = keyNames.get(key & 0xff);
|
|
4732
|
+
if (!name || name === 'Unknown') {
|
|
4733
|
+
return '';
|
|
4734
|
+
}
|
|
4735
|
+
return [...(key & 2048 ? ['Ctrl'] : []), ...(key & 1024 ? ['Shift'] : []), ...(key & 512 ? ['Alt'] : []), ...(key & 256 ? ['Meta'] : []), name].join('+');
|
|
4736
|
+
};
|
|
4737
|
+
const loadUserKeyBindings = async invoke => {
|
|
4738
|
+
try {
|
|
4739
|
+
const content = await invoke('FileSystem.readFile', 'app://keybindings.json');
|
|
4740
|
+
const parsed = JSON.parse(content);
|
|
4741
|
+
return Array.isArray(parsed) ? parsed.filter(entry => entry && (entry.source === 'User' || typeof entry.key === 'string' && !entry.source)) : [];
|
|
4742
|
+
} catch {
|
|
4743
|
+
return [];
|
|
4744
|
+
}
|
|
4745
|
+
};
|
|
4746
|
+
const loadCommandKeyBindings = async applicationId => {
|
|
4747
|
+
const invoke = (method, ...args) => applicationId === undefined ? invoke$4(method, ...args) : invoke$4('Application.execute', applicationId, method, ...args);
|
|
4748
|
+
try {
|
|
4749
|
+
if ((await invoke('Preferences.get', 'quickPick.showKeyBindings')) !== true) {
|
|
4750
|
+
return {};
|
|
4751
|
+
}
|
|
4752
|
+
const defaults = await invoke('KeyBindingsInitial.getKeyBindings');
|
|
4753
|
+
const user = await loadUserKeyBindings(invoke);
|
|
4754
|
+
const bindings = Object.create(null);
|
|
4755
|
+
for (const entry of [...user, ...defaults]) {
|
|
4756
|
+
const command = entry.command === 'ExtensionHost.executeCommand' ? `ext.${entry.args?.[0]}` : entry.command;
|
|
4757
|
+
const label = getKeyLabel(entry.key);
|
|
4758
|
+
if (typeof command === 'string' && label && !Object.hasOwn(bindings, command)) {
|
|
4759
|
+
bindings[command] = label;
|
|
4760
|
+
}
|
|
4761
|
+
}
|
|
4762
|
+
return bindings;
|
|
4763
|
+
} catch {
|
|
4764
|
+
return {};
|
|
4765
|
+
}
|
|
4766
|
+
};
|
|
4767
|
+
|
|
4768
|
+
const requestVersions = new Map();
|
|
4769
|
+
const requestVersionGenerator = {
|
|
4770
|
+
value: 0
|
|
4771
|
+
};
|
|
4772
|
+
const isSamePicker = (state, latestState) => {
|
|
4773
|
+
return latestState.uri === state.uri && latestState.args === state.args;
|
|
4774
|
+
};
|
|
4775
|
+
const isQuickInput = args => {
|
|
4776
|
+
const options = args.at(-1);
|
|
4777
|
+
return options?.mode === 'quickInput';
|
|
4778
|
+
};
|
|
4779
|
+
const isStaticQuickInput = args => {
|
|
4780
|
+
const options = args.at(-1);
|
|
4781
|
+
return options?.mode === 'quickInput' && options.quickInputId === undefined;
|
|
4782
|
+
};
|
|
4783
|
+
const setValue = async (state, newValue) => {
|
|
4784
|
+
const {
|
|
4339
4785
|
args,
|
|
4340
4786
|
assetDir,
|
|
4341
4787
|
fileIconCache,
|
|
@@ -4343,31 +4789,35 @@ const getLoadedState = async state => {
|
|
|
4343
4789
|
itemHeight,
|
|
4344
4790
|
maxVisibleItems,
|
|
4345
4791
|
platform,
|
|
4346
|
-
|
|
4792
|
+
providerId,
|
|
4793
|
+
value
|
|
4347
4794
|
} = state;
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4795
|
+
if (value === newValue) {
|
|
4796
|
+
return state;
|
|
4797
|
+
}
|
|
4798
|
+
if (isTextInput(args)) {
|
|
4799
|
+
return {
|
|
4800
|
+
...state,
|
|
4801
|
+
inputSource: Script,
|
|
4802
|
+
value: newValue
|
|
4803
|
+
};
|
|
4804
|
+
}
|
|
4805
|
+
const prefix = getQuickPickPrefix(newValue);
|
|
4806
|
+
const subId = getQuickPickSubProviderId(providerId, prefix);
|
|
4807
|
+
const previousSubId = getQuickPickSubProviderId(providerId, getQuickPickPrefix(value));
|
|
4808
|
+
const commandKeyBindings = subId === Commands$1 && previousSubId !== subId ? await loadCommandKeyBindings(state.applicationId) : state.commandKeyBindings;
|
|
4809
|
+
const quickInput = isQuickInput(args);
|
|
4810
|
+
const reuseFilePicks = !state.initial && canReuseFilePicks(providerId, value, newValue, state.picks.length);
|
|
4811
|
+
const newPicks = isStaticQuickInput(args) || subId === LanguageMode$1 || reuseFilePicks ? state.picks : await getPicks(subId, newValue, args, {
|
|
4353
4812
|
applicationId: state.applicationId,
|
|
4354
4813
|
assetDir,
|
|
4355
4814
|
platform
|
|
4356
4815
|
});
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
} catch {
|
|
4363
|
-
// The worker can be released before the renderer endpoint.
|
|
4364
|
-
}
|
|
4365
|
-
}
|
|
4366
|
-
const filterValue = getFilterValue(id, subId, value);
|
|
4367
|
-
const items = isTextInput(args) ? newPicks : filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
|
|
4368
|
-
const focusedIndex = subId === ColorTheme$1 ? Math.max(items.findIndex(item => item.label === colorTheme), 0) : 0;
|
|
4369
|
-
const minLineY = Math.max(Math.min(focusedIndex - maxVisibleItems + 1, items.length - maxVisibleItems), 0);
|
|
4370
|
-
const maxLineY = Math.min(minLineY + maxVisibleItems, items.length);
|
|
4816
|
+
const filterValue = quickInput ? '' : getFilterValue(providerId, subId, newValue);
|
|
4817
|
+
const items = filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
|
|
4818
|
+
const focusedIndex = items.length === 0 ? -1 : 0;
|
|
4819
|
+
const minLineY = 0;
|
|
4820
|
+
const maxLineY = Math.min(maxVisibleItems, items.length);
|
|
4371
4821
|
const sliced = items.slice(minLineY, maxLineY);
|
|
4372
4822
|
const {
|
|
4373
4823
|
icons,
|
|
@@ -4375,90 +4825,336 @@ const getLoadedState = async state => {
|
|
|
4375
4825
|
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
4376
4826
|
const listHeight = getListHeight$1(items.length, itemHeight, height);
|
|
4377
4827
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
4378
|
-
const parsedArgs = parseArgs(subId, args);
|
|
4379
|
-
const finalValue = parsedArgs.initialValue || value;
|
|
4380
4828
|
return {
|
|
4381
4829
|
...state,
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
deltaY: minLineY * itemHeight,
|
|
4830
|
+
commandKeyBindings,
|
|
4831
|
+
deltaY: 0,
|
|
4385
4832
|
fileIconCache: newFileIconCache,
|
|
4386
4833
|
finalDeltaY,
|
|
4387
|
-
focused: true,
|
|
4388
4834
|
focusedIndex,
|
|
4389
4835
|
icons,
|
|
4390
|
-
initial: false,
|
|
4391
4836
|
inputSource: Script,
|
|
4392
4837
|
items,
|
|
4393
4838
|
maxLineY,
|
|
4394
4839
|
minLineY,
|
|
4395
4840
|
picks: newPicks,
|
|
4396
|
-
|
|
4397
|
-
providerId: id,
|
|
4398
|
-
state: Finished,
|
|
4399
|
-
value: finalValue
|
|
4841
|
+
value: newValue
|
|
4400
4842
|
};
|
|
4401
4843
|
};
|
|
4402
|
-
const
|
|
4403
|
-
const newState = await getLoadedState(state);
|
|
4404
|
-
notifyVisible();
|
|
4405
|
-
return newState;
|
|
4406
|
-
};
|
|
4407
|
-
const loadContentWithContext = async context => {
|
|
4844
|
+
const setValueWithContext = async (context, newValue) => {
|
|
4408
4845
|
const state = context.getState();
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4846
|
+
if (state.value === newValue) {
|
|
4847
|
+
return;
|
|
4848
|
+
}
|
|
4849
|
+
const requestVersion = ++requestVersionGenerator.value;
|
|
4850
|
+
requestVersions.set(state.uid, requestVersion);
|
|
4851
|
+
const result = await setValue(state, newValue);
|
|
4852
|
+
await context.updateState(latestState => {
|
|
4853
|
+
if (requestVersions.get(latestState.uid) !== requestVersion || !isSamePicker(state, latestState)) {
|
|
4854
|
+
return latestState;
|
|
4855
|
+
}
|
|
4856
|
+
return {
|
|
4857
|
+
...latestState,
|
|
4858
|
+
commandKeyBindings: result.commandKeyBindings,
|
|
4859
|
+
deltaY: result.deltaY,
|
|
4860
|
+
fileIconCache: result.fileIconCache,
|
|
4861
|
+
finalDeltaY: result.finalDeltaY,
|
|
4862
|
+
focusedIndex: result.focusedIndex,
|
|
4863
|
+
icons: result.icons,
|
|
4864
|
+
inputSource: result.inputSource,
|
|
4865
|
+
items: result.items,
|
|
4866
|
+
maxLineY: result.maxLineY,
|
|
4867
|
+
minLineY: result.minLineY,
|
|
4868
|
+
picks: result.picks,
|
|
4869
|
+
value: result.value
|
|
4870
|
+
};
|
|
4871
|
+
});
|
|
4872
|
+
if (requestVersions.get(state.uid) === requestVersion) {
|
|
4873
|
+
requestVersions.delete(state.uid);
|
|
4874
|
+
}
|
|
4431
4875
|
};
|
|
4432
4876
|
|
|
4433
|
-
const
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
// return state.recentPicks[index]
|
|
4438
|
-
// }
|
|
4439
|
-
// index -= state.recentPicks.length
|
|
4440
|
-
if (index < items.length) {
|
|
4441
|
-
return items[index];
|
|
4877
|
+
const handleInputWithContext = async (context, newValue, cursorOffset, inputSource = Script) => {
|
|
4878
|
+
const state = context.getState();
|
|
4879
|
+
if (state.value !== newValue) {
|
|
4880
|
+
await setValueWithContext(context, newValue);
|
|
4442
4881
|
}
|
|
4443
|
-
|
|
4444
|
-
|
|
4882
|
+
await context.updateState(latestState => {
|
|
4883
|
+
if (latestState.value !== newValue) {
|
|
4884
|
+
return latestState;
|
|
4885
|
+
}
|
|
4886
|
+
return {
|
|
4887
|
+
...latestState,
|
|
4888
|
+
cursorOffset,
|
|
4889
|
+
inputSource
|
|
4890
|
+
};
|
|
4891
|
+
});
|
|
4445
4892
|
};
|
|
4446
4893
|
|
|
4447
|
-
|
|
4894
|
+
// TODO when user types letters -> no need to query provider again -> just filter existing results
|
|
4895
|
+
const handleInput = async (state, newValue, cursorOffset, inputSource = Script) => {
|
|
4896
|
+
if (state.value === newValue) {
|
|
4897
|
+
return {
|
|
4898
|
+
...state,
|
|
4899
|
+
cursorOffset,
|
|
4900
|
+
inputSource
|
|
4901
|
+
};
|
|
4902
|
+
}
|
|
4903
|
+
const newState = await setValue(state, newValue);
|
|
4448
4904
|
return {
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
icon: '',
|
|
4453
|
-
label: value,
|
|
4454
|
-
matches: [],
|
|
4455
|
-
uri: ''
|
|
4905
|
+
...newState,
|
|
4906
|
+
cursorOffset,
|
|
4907
|
+
inputSource
|
|
4456
4908
|
};
|
|
4457
4909
|
};
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4910
|
+
|
|
4911
|
+
const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd) => {
|
|
4912
|
+
string(inputType);
|
|
4913
|
+
number(selectionStart);
|
|
4914
|
+
number(selectionEnd);
|
|
4915
|
+
const {
|
|
4916
|
+
value
|
|
4917
|
+
} = state;
|
|
4918
|
+
const {
|
|
4919
|
+
cursorOffset,
|
|
4920
|
+
newValue
|
|
4921
|
+
} = getNewValue(value, inputType, data, selectionStart, selectionEnd);
|
|
4922
|
+
return handleInput(state, newValue, cursorOffset, User);
|
|
4923
|
+
};
|
|
4924
|
+
|
|
4925
|
+
const getCancelResult = args => {
|
|
4926
|
+
const last = args.at(-1);
|
|
4927
|
+
if (last && typeof last === 'object' &&
|
|
4928
|
+
// @ts-ignore
|
|
4929
|
+
last.mode === 'quickPick') {
|
|
4930
|
+
return undefined;
|
|
4931
|
+
}
|
|
4932
|
+
return {
|
|
4933
|
+
canceled: true,
|
|
4934
|
+
inputValue: ''
|
|
4935
|
+
};
|
|
4936
|
+
};
|
|
4937
|
+
const handleBlur = async state => {
|
|
4938
|
+
const {
|
|
4939
|
+
args,
|
|
4940
|
+
providerId
|
|
4941
|
+
} = state;
|
|
4942
|
+
if (providerId === Custom$1) {
|
|
4943
|
+
const options = args.at(-1);
|
|
4944
|
+
if (!options?.executeItemCommand) {
|
|
4945
|
+
const resolveId = args[2];
|
|
4946
|
+
await invoke$4('QuickPick.executeCallback', resolveId, getCancelResult(args));
|
|
4947
|
+
}
|
|
4948
|
+
}
|
|
4949
|
+
await closeWidget(state.uid);
|
|
4950
|
+
return state;
|
|
4951
|
+
};
|
|
4952
|
+
|
|
4953
|
+
const getIndex = (top, headerHeight, itemHeight, y) => {
|
|
4954
|
+
const relativeY = y - top - headerHeight;
|
|
4955
|
+
const index = Math.floor(relativeY / itemHeight);
|
|
4956
|
+
return index;
|
|
4957
|
+
};
|
|
4958
|
+
|
|
4959
|
+
const getDefaultValue = (id, uri = '', args = []) => {
|
|
4960
|
+
if (uri === GoToLine$1) {
|
|
4961
|
+
const line = Number(args[1]);
|
|
4962
|
+
const column = Number(args[2]);
|
|
4963
|
+
if (Number.isSafeInteger(line) && Number.isSafeInteger(column) && line >= 1 && column >= 1) {
|
|
4964
|
+
return `${GoToLine}${line}:${column}`;
|
|
4965
|
+
}
|
|
4966
|
+
return GoToLine;
|
|
4967
|
+
}
|
|
4968
|
+
if (uri === WorkspaceSymbol$1) {
|
|
4969
|
+
return WorkspaceSymbol;
|
|
4970
|
+
}
|
|
4971
|
+
switch (id) {
|
|
4972
|
+
case EveryThing$1:
|
|
4973
|
+
return Command;
|
|
4974
|
+
default:
|
|
4975
|
+
return '';
|
|
4976
|
+
}
|
|
4977
|
+
};
|
|
4978
|
+
|
|
4979
|
+
const callbacks = [];
|
|
4980
|
+
const waitUntilVisible = () => {
|
|
4981
|
+
const {
|
|
4982
|
+
promise,
|
|
4983
|
+
resolve
|
|
4984
|
+
} = Promise.withResolvers();
|
|
4985
|
+
callbacks.push(resolve);
|
|
4986
|
+
return promise;
|
|
4987
|
+
};
|
|
4988
|
+
const notifyVisible = () => {
|
|
4989
|
+
const pendingCallbacks = [...callbacks];
|
|
4990
|
+
callbacks.length = 0;
|
|
4991
|
+
for (const callback of pendingCallbacks) {
|
|
4992
|
+
callback();
|
|
4993
|
+
}
|
|
4994
|
+
};
|
|
4995
|
+
|
|
4996
|
+
const parseArgs = (subId, args) => {
|
|
4997
|
+
if (subId !== Custom$1) {
|
|
4998
|
+
return {
|
|
4999
|
+
ignoreFocusOut: false,
|
|
5000
|
+
initialValue: '',
|
|
5001
|
+
placeholder: ''
|
|
5002
|
+
};
|
|
5003
|
+
}
|
|
5004
|
+
const last = args.at(-1);
|
|
5005
|
+
if (!last || typeof last !== 'object') {
|
|
5006
|
+
return {
|
|
5007
|
+
ignoreFocusOut: false,
|
|
5008
|
+
initialValue: '',
|
|
5009
|
+
placeholder: ''
|
|
5010
|
+
};
|
|
5011
|
+
}
|
|
5012
|
+
return {
|
|
5013
|
+
// @ts-ignore
|
|
5014
|
+
ignoreFocusOut: Boolean(last.ignoreFocusOut),
|
|
5015
|
+
// @ts-ignore
|
|
5016
|
+
initialValue: last.initialValue ? String(last.initialValue) : '',
|
|
5017
|
+
// @ts-ignore
|
|
5018
|
+
placeholder: last.placeholder ? String(last.placeholder) : ''
|
|
5019
|
+
};
|
|
5020
|
+
};
|
|
5021
|
+
const getLoadedState = async state => {
|
|
5022
|
+
const {
|
|
5023
|
+
args,
|
|
5024
|
+
assetDir,
|
|
5025
|
+
fileIconCache,
|
|
5026
|
+
height,
|
|
5027
|
+
itemHeight,
|
|
5028
|
+
maxVisibleItems,
|
|
5029
|
+
platform,
|
|
5030
|
+
uri
|
|
5031
|
+
} = state;
|
|
5032
|
+
const id = getQuickPickProviderId(uri);
|
|
5033
|
+
const value = getDefaultValue(id, uri, args);
|
|
5034
|
+
const prefix = getQuickPickPrefix(value);
|
|
5035
|
+
const subId = getQuickPickSubProviderId(id, prefix);
|
|
5036
|
+
const commandKeyBindings = subId === Commands$1 ? await loadCommandKeyBindings(state.applicationId) : {};
|
|
5037
|
+
const newPicks = await getPicks(subId, value, args, {
|
|
5038
|
+
applicationId: state.applicationId,
|
|
5039
|
+
assetDir,
|
|
5040
|
+
platform
|
|
5041
|
+
});
|
|
5042
|
+
array(newPicks);
|
|
5043
|
+
let colorTheme = '';
|
|
5044
|
+
if (subId === ColorTheme$1) {
|
|
5045
|
+
try {
|
|
5046
|
+
colorTheme = await invoke$4('ColorTheme.getColorTheme');
|
|
5047
|
+
} catch {
|
|
5048
|
+
// The worker can be released before the renderer endpoint.
|
|
5049
|
+
}
|
|
5050
|
+
}
|
|
5051
|
+
const filterValue = getFilterValue(id, subId, value);
|
|
5052
|
+
const items = isTextInput(args) ? newPicks : filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
|
|
5053
|
+
const focusedIndex = subId === ColorTheme$1 ? Math.max(items.findIndex(item => item.label === colorTheme), 0) : 0;
|
|
5054
|
+
const minLineY = Math.max(Math.min(focusedIndex - maxVisibleItems + 1, items.length - maxVisibleItems), 0);
|
|
5055
|
+
const maxLineY = Math.min(minLineY + maxVisibleItems, items.length);
|
|
5056
|
+
const sliced = items.slice(minLineY, maxLineY);
|
|
5057
|
+
const {
|
|
5058
|
+
icons,
|
|
5059
|
+
newFileIconCache
|
|
5060
|
+
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
5061
|
+
const listHeight = getListHeight$1(items.length, itemHeight, height);
|
|
5062
|
+
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
5063
|
+
const parsedArgs = parseArgs(subId, args);
|
|
5064
|
+
const finalValue = parsedArgs.initialValue || value;
|
|
5065
|
+
const latest = get$3(state.uid);
|
|
5066
|
+
if (latest && latest.newState.uri === state.uri && latest.newState.args === state.args && latest.newState.value !== state.value) {
|
|
5067
|
+
return state;
|
|
5068
|
+
}
|
|
5069
|
+
return {
|
|
5070
|
+
...state,
|
|
5071
|
+
args,
|
|
5072
|
+
commandKeyBindings,
|
|
5073
|
+
cursorOffset: value.length,
|
|
5074
|
+
deltaY: minLineY * itemHeight,
|
|
5075
|
+
fileIconCache: newFileIconCache,
|
|
5076
|
+
finalDeltaY,
|
|
5077
|
+
focused: true,
|
|
5078
|
+
focusedIndex,
|
|
5079
|
+
icons,
|
|
5080
|
+
initial: false,
|
|
5081
|
+
inputSource: Script,
|
|
5082
|
+
items,
|
|
5083
|
+
maxLineY,
|
|
5084
|
+
minLineY,
|
|
5085
|
+
picks: newPicks,
|
|
5086
|
+
placeholder: parsedArgs.placeholder,
|
|
5087
|
+
providerId: id,
|
|
5088
|
+
state: Finished,
|
|
5089
|
+
value: finalValue
|
|
5090
|
+
};
|
|
5091
|
+
};
|
|
5092
|
+
const loadContent = async state => {
|
|
5093
|
+
const newState = await getLoadedState(state);
|
|
5094
|
+
notifyVisible();
|
|
5095
|
+
return newState;
|
|
5096
|
+
};
|
|
5097
|
+
const loadContentWithContext = async context => {
|
|
5098
|
+
const state = context.getState();
|
|
5099
|
+
const loadedState = await getLoadedState(state);
|
|
5100
|
+
await context.updateState(latestState => {
|
|
5101
|
+
if (latestState.value !== state.value || latestState.uri !== state.uri || latestState.args !== state.args) {
|
|
5102
|
+
return latestState;
|
|
5103
|
+
}
|
|
5104
|
+
return {
|
|
5105
|
+
...latestState,
|
|
5106
|
+
commandKeyBindings: loadedState.commandKeyBindings,
|
|
5107
|
+
cursorOffset: loadedState.cursorOffset,
|
|
5108
|
+
deltaY: loadedState.deltaY,
|
|
5109
|
+
fileIconCache: loadedState.fileIconCache,
|
|
5110
|
+
finalDeltaY: loadedState.finalDeltaY,
|
|
5111
|
+
focused: loadedState.focused,
|
|
5112
|
+
focusedIndex: loadedState.focusedIndex,
|
|
5113
|
+
icons: loadedState.icons,
|
|
5114
|
+
initial: loadedState.initial,
|
|
5115
|
+
inputSource: loadedState.inputSource,
|
|
5116
|
+
items: loadedState.items,
|
|
5117
|
+
maxLineY: loadedState.maxLineY,
|
|
5118
|
+
minLineY: loadedState.minLineY,
|
|
5119
|
+
picks: loadedState.picks,
|
|
5120
|
+
placeholder: loadedState.placeholder,
|
|
5121
|
+
providerId: loadedState.providerId,
|
|
5122
|
+
state: loadedState.state,
|
|
5123
|
+
value: loadedState.value
|
|
5124
|
+
};
|
|
5125
|
+
});
|
|
5126
|
+
notifyVisible();
|
|
5127
|
+
};
|
|
5128
|
+
|
|
5129
|
+
const getPick = (items, index) => {
|
|
5130
|
+
array(items);
|
|
5131
|
+
number(index);
|
|
5132
|
+
// if (index < state.recentPicks.length) {
|
|
5133
|
+
// return state.recentPicks[index]
|
|
5134
|
+
// }
|
|
5135
|
+
// index -= state.recentPicks.length
|
|
5136
|
+
if (index < items.length) {
|
|
5137
|
+
return items[index];
|
|
5138
|
+
}
|
|
5139
|
+
console.warn('no pick matching index', index);
|
|
5140
|
+
return undefined;
|
|
5141
|
+
};
|
|
5142
|
+
|
|
5143
|
+
const createCustomPick = value => {
|
|
5144
|
+
return {
|
|
5145
|
+
description: '',
|
|
5146
|
+
direntType: 0,
|
|
5147
|
+
fileIcon: '',
|
|
5148
|
+
icon: '',
|
|
5149
|
+
label: value,
|
|
5150
|
+
matches: [],
|
|
5151
|
+
uri: ''
|
|
5152
|
+
};
|
|
5153
|
+
};
|
|
5154
|
+
const shouldCloseBeforeSelect = (subId, pick) => {
|
|
5155
|
+
if (subId === Recent$1) {
|
|
5156
|
+
return true;
|
|
5157
|
+
}
|
|
4462
5158
|
if (subId !== Commands$1) {
|
|
4463
5159
|
return false;
|
|
4464
5160
|
}
|
|
@@ -4578,471 +5274,148 @@ const handleMessagePort = async port => {
|
|
|
4578
5274
|
};
|
|
4579
5275
|
|
|
4580
5276
|
const state = {
|
|
4581
|
-
connected: false
|
|
4582
|
-
};
|
|
4583
|
-
const isConnected = () => {
|
|
4584
|
-
const {
|
|
4585
|
-
connected
|
|
4586
|
-
} = state;
|
|
4587
|
-
return connected;
|
|
4588
|
-
};
|
|
4589
|
-
const invoke$1 = (method, ...params) => {
|
|
4590
|
-
return invoke$5(method, ...params);
|
|
4591
|
-
};
|
|
4592
|
-
const set = rpc => {
|
|
4593
|
-
set$7(rpc);
|
|
4594
|
-
state.connected = true;
|
|
4595
|
-
};
|
|
4596
|
-
|
|
4597
|
-
const handleRendererProcessMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
|
|
4598
|
-
const executeViewletCommand = async (uid, command, ...args) => {
|
|
4599
|
-
const fn = viewletCommandMap[`QuickPick.${command}`];
|
|
4600
|
-
if (typeof fn !== 'function') {
|
|
4601
|
-
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
4602
|
-
}
|
|
4603
|
-
await fn(uid, ...args);
|
|
4604
|
-
await invoke$4('Viewlet.requestRender', uid);
|
|
4605
|
-
};
|
|
4606
|
-
const rpc = await create$8({
|
|
4607
|
-
commandMap: {
|
|
4608
|
-
'Viewlet.executeViewletCommand': executeViewletCommand
|
|
4609
|
-
},
|
|
4610
|
-
messagePort: port
|
|
4611
|
-
});
|
|
4612
|
-
if (setAsRendererProcess) {
|
|
4613
|
-
set(rpc);
|
|
4614
|
-
}
|
|
4615
|
-
};
|
|
4616
|
-
|
|
4617
|
-
const handleStatusBarMessagePort = async port => {
|
|
4618
|
-
await create$8({
|
|
4619
|
-
commandMap: commandMapRef,
|
|
4620
|
-
isMessagePortOpen: true,
|
|
4621
|
-
messagePort: port
|
|
4622
|
-
});
|
|
4623
|
-
};
|
|
4624
|
-
|
|
4625
|
-
const initialize = async () => {
|
|
4626
|
-
// not needed anymore
|
|
4627
|
-
};
|
|
4628
|
-
|
|
4629
|
-
const invoke = async (applicationId, method, ...args) => {
|
|
4630
|
-
return applicationId === undefined ? invoke$4(method, ...args) : invoke$4('Application.execute', applicationId, method, ...args);
|
|
4631
|
-
};
|
|
4632
|
-
|
|
4633
|
-
const QuickPick$2 = 'QuickPick';
|
|
4634
|
-
|
|
4635
|
-
const openStatusBarPicker = async (picker, ...args) => {
|
|
4636
|
-
await invoke(undefined, 'Viewlet.openWidget', QuickPick$2, picker, ...args);
|
|
4637
|
-
};
|
|
4638
|
-
|
|
4639
|
-
const getCss = (scrollBarHeight, scrollBarTop, quickPickItemsHeight) => {
|
|
4640
|
-
return `.QuickPick {
|
|
4641
|
-
--QuickPickItemsHeight: ${quickPickItemsHeight}px;
|
|
4642
|
-
--ScrollBarThumbHeight: ${scrollBarHeight}px;
|
|
4643
|
-
--ScrollBarThumbTop: ${scrollBarTop}px;
|
|
4644
|
-
}
|
|
4645
|
-
.QuickPick .QuickPickItems {
|
|
4646
|
-
height: var(--QuickPickItemsHeight);
|
|
4647
|
-
}
|
|
4648
|
-
.QuickPick .ScrollBarThumb {
|
|
4649
|
-
height: var(--ScrollBarThumbHeight);
|
|
4650
|
-
translate: 0px var(--ScrollBarThumbTop);
|
|
4651
|
-
}`;
|
|
4652
|
-
};
|
|
4653
|
-
|
|
4654
|
-
const getQuickPickItemsHeight = height => {
|
|
4655
|
-
if (height === 0) {
|
|
4656
|
-
return 20;
|
|
4657
|
-
}
|
|
4658
|
-
return height;
|
|
4659
|
-
};
|
|
4660
|
-
const renderCss = (_oldState, newState) => {
|
|
4661
|
-
const {
|
|
4662
|
-
deltaY,
|
|
4663
|
-
finalDeltaY,
|
|
4664
|
-
headerHeight,
|
|
4665
|
-
height,
|
|
4666
|
-
itemHeight,
|
|
4667
|
-
items,
|
|
4668
|
-
minimumSliderSize,
|
|
4669
|
-
uid
|
|
4670
|
-
} = newState;
|
|
4671
|
-
const quickPickItemsHeight = getQuickPickItemsHeight(height);
|
|
4672
|
-
const listHeight = getListHeight$1(items.length, itemHeight, quickPickItemsHeight);
|
|
4673
|
-
const contentHeight = items.length * itemHeight;
|
|
4674
|
-
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
4675
|
-
const scrollBarTop = Math.round(getScrollBarY(deltaY, finalDeltaY, quickPickItemsHeight - headerHeight, scrollBarHeight));
|
|
4676
|
-
const css = getCss(scrollBarHeight, scrollBarTop, quickPickItemsHeight);
|
|
4677
|
-
return [SetCss, uid, css];
|
|
4678
|
-
};
|
|
4679
|
-
|
|
4680
|
-
const SetCursorOffset = 'setCursorOffset';
|
|
4681
|
-
const SetFocusedIndex = 'setFocusedIndex';
|
|
4682
|
-
const SetItemsHeight = 'setItemsHeight';
|
|
4683
|
-
|
|
4684
|
-
const renderCursorOffset = (_oldState, newState) => {
|
|
4685
|
-
return ['Viewlet.send', newState.uid, /* method */SetCursorOffset, /* cursorOffset */newState.cursorOffset];
|
|
4686
|
-
};
|
|
4687
|
-
|
|
4688
|
-
const QuickPickInput = 'QuickPickInput';
|
|
4689
|
-
|
|
4690
|
-
const renderFocus = (_oldState, newState) => {
|
|
4691
|
-
return ['Viewlet.focusElementByName', newState.uid, QuickPickInput];
|
|
4692
|
-
};
|
|
4693
|
-
|
|
4694
|
-
const renderFocusedIndex = (oldState, newState) => {
|
|
4695
|
-
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
4696
|
-
const newFocusedIndex = newState.focusedIndex - newState.minLineY;
|
|
4697
|
-
return ['Viewlet.send', newState.uid, /* method */SetFocusedIndex, /* oldFocusedIndex */oldFocusedIndex, /* newFocusedIndex */newFocusedIndex];
|
|
4698
|
-
};
|
|
4699
|
-
|
|
4700
|
-
const renderHeight = (_oldState, newState) => {
|
|
4701
|
-
const {
|
|
4702
|
-
height,
|
|
4703
|
-
uid
|
|
4704
|
-
} = newState;
|
|
4705
|
-
if (height === 0) {
|
|
4706
|
-
return ['Viewlet.send', uid, /* method */SetItemsHeight, /* height */20];
|
|
4707
|
-
}
|
|
4708
|
-
return ['Viewlet.send', uid, /* method */SetItemsHeight, /* height */height];
|
|
4709
|
-
};
|
|
4710
|
-
|
|
4711
|
-
const mergeClassNames = (...classNames) => {
|
|
4712
|
-
return classNames.filter(Boolean).join(' ');
|
|
4713
|
-
};
|
|
4714
|
-
|
|
4715
|
-
const text = data => {
|
|
4716
|
-
return {
|
|
4717
|
-
childCount: 0,
|
|
4718
|
-
text: data,
|
|
4719
|
-
type: Text
|
|
4720
|
-
};
|
|
4721
|
-
};
|
|
4722
|
-
|
|
4723
|
-
const SetText = 1;
|
|
4724
|
-
const Replace = 2;
|
|
4725
|
-
const SetAttribute = 3;
|
|
4726
|
-
const RemoveAttribute = 4;
|
|
4727
|
-
const Add = 6;
|
|
4728
|
-
const NavigateChild = 7;
|
|
4729
|
-
const NavigateParent = 8;
|
|
4730
|
-
const RemoveChild = 9;
|
|
4731
|
-
const NavigateSibling = 10;
|
|
4732
|
-
const SetReferenceNodeUid = 11;
|
|
4733
|
-
const MultiNavigation = 18;
|
|
4734
|
-
|
|
4735
|
-
const isKey = key => {
|
|
4736
|
-
return key !== 'type' && key !== 'childCount';
|
|
4737
|
-
};
|
|
4738
|
-
|
|
4739
|
-
const getKeys = node => {
|
|
4740
|
-
const keys = Object.keys(node).filter(isKey);
|
|
4741
|
-
return keys;
|
|
4742
|
-
};
|
|
4743
|
-
|
|
4744
|
-
const arrayToTree = nodes => {
|
|
4745
|
-
const result = [];
|
|
4746
|
-
let i = 0;
|
|
4747
|
-
while (i < nodes.length) {
|
|
4748
|
-
const node = nodes[i];
|
|
4749
|
-
const {
|
|
4750
|
-
children,
|
|
4751
|
-
nodesConsumed
|
|
4752
|
-
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
4753
|
-
result.push({
|
|
4754
|
-
node,
|
|
4755
|
-
children
|
|
4756
|
-
});
|
|
4757
|
-
i += 1 + nodesConsumed;
|
|
4758
|
-
}
|
|
4759
|
-
return result;
|
|
4760
|
-
};
|
|
4761
|
-
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
4762
|
-
if (childCount === 0) {
|
|
4763
|
-
return {
|
|
4764
|
-
children: [],
|
|
4765
|
-
nodesConsumed: 0
|
|
4766
|
-
};
|
|
4767
|
-
}
|
|
4768
|
-
const children = [];
|
|
4769
|
-
let i = startIndex;
|
|
4770
|
-
let remaining = childCount;
|
|
4771
|
-
let totalConsumed = 0;
|
|
4772
|
-
while (remaining > 0 && i < nodes.length) {
|
|
4773
|
-
const node = nodes[i];
|
|
4774
|
-
const nodeChildCount = node.childCount || 0;
|
|
4775
|
-
const {
|
|
4776
|
-
children: nodeChildren,
|
|
4777
|
-
nodesConsumed
|
|
4778
|
-
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
4779
|
-
children.push({
|
|
4780
|
-
node,
|
|
4781
|
-
children: nodeChildren
|
|
4782
|
-
});
|
|
4783
|
-
const nodeSize = 1 + nodesConsumed;
|
|
4784
|
-
i += nodeSize;
|
|
4785
|
-
totalConsumed += nodeSize;
|
|
4786
|
-
remaining--;
|
|
4787
|
-
}
|
|
4788
|
-
return {
|
|
4789
|
-
children,
|
|
4790
|
-
nodesConsumed: totalConsumed
|
|
4791
|
-
};
|
|
4792
|
-
};
|
|
4793
|
-
|
|
4794
|
-
const isNavigationPatch = patch => {
|
|
4795
|
-
switch (patch.type) {
|
|
4796
|
-
case NavigateChild:
|
|
4797
|
-
case NavigateParent:
|
|
4798
|
-
case NavigateSibling:
|
|
4799
|
-
return true;
|
|
4800
|
-
default:
|
|
4801
|
-
return false;
|
|
4802
|
-
}
|
|
4803
|
-
};
|
|
4804
|
-
const getNavigationIndex = patch => {
|
|
4805
|
-
switch (patch.type) {
|
|
4806
|
-
case NavigateChild:
|
|
4807
|
-
case NavigateSibling:
|
|
4808
|
-
return patch.index;
|
|
4809
|
-
default:
|
|
4810
|
-
return 0;
|
|
4811
|
-
}
|
|
4812
|
-
};
|
|
4813
|
-
const appendNavigationPatch = (patches, type, index) => {
|
|
4814
|
-
const previousPatch = patches.at(-1);
|
|
4815
|
-
if (!previousPatch) {
|
|
4816
|
-
patches.push(type === NavigateParent ? {
|
|
4817
|
-
type
|
|
4818
|
-
} : {
|
|
4819
|
-
index,
|
|
4820
|
-
type
|
|
4821
|
-
});
|
|
4822
|
-
return;
|
|
4823
|
-
}
|
|
4824
|
-
if (previousPatch.type === MultiNavigation) {
|
|
4825
|
-
previousPatch.navigations.push(type, index);
|
|
4826
|
-
return;
|
|
4827
|
-
}
|
|
4828
|
-
if (isNavigationPatch(previousPatch)) {
|
|
4829
|
-
patches[patches.length - 1] = {
|
|
4830
|
-
navigations: [previousPatch.type, getNavigationIndex(previousPatch), type, index],
|
|
4831
|
-
type: MultiNavigation
|
|
4832
|
-
};
|
|
4833
|
-
return;
|
|
4834
|
-
}
|
|
4835
|
-
patches.push(type === NavigateParent ? {
|
|
4836
|
-
type
|
|
4837
|
-
} : {
|
|
4838
|
-
index,
|
|
4839
|
-
type
|
|
4840
|
-
});
|
|
4841
|
-
};
|
|
4842
|
-
|
|
4843
|
-
const compareNodes = (oldNode, newNode) => {
|
|
4844
|
-
// Check if node type changed - return null to signal incompatible nodes
|
|
4845
|
-
// (caller should handle this with a Replace operation)
|
|
4846
|
-
if (oldNode.type !== newNode.type) {
|
|
4847
|
-
return null;
|
|
4848
|
-
}
|
|
4849
|
-
const patches = [];
|
|
4850
|
-
// Handle reference nodes - special handling for uid changes
|
|
4851
|
-
if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
|
|
4852
|
-
patches.push({
|
|
4853
|
-
type: SetReferenceNodeUid,
|
|
4854
|
-
uid: newNode.uid
|
|
4855
|
-
});
|
|
4856
|
-
}
|
|
4857
|
-
// Handle text nodes
|
|
4858
|
-
if (oldNode.type === Text && newNode.type === Text) {
|
|
4859
|
-
if (oldNode.text !== newNode.text) {
|
|
4860
|
-
patches.push({
|
|
4861
|
-
type: SetText,
|
|
4862
|
-
value: newNode.text
|
|
4863
|
-
});
|
|
4864
|
-
}
|
|
4865
|
-
return patches;
|
|
4866
|
-
}
|
|
4867
|
-
// Compare attributes
|
|
4868
|
-
const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
|
|
4869
|
-
const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
|
|
4870
|
-
// Check for attribute changes
|
|
4871
|
-
for (const key of newKeys) {
|
|
4872
|
-
if (oldNode[key] !== newNode[key]) {
|
|
4873
|
-
patches.push({
|
|
4874
|
-
type: SetAttribute,
|
|
4875
|
-
key,
|
|
4876
|
-
value: newNode[key]
|
|
4877
|
-
});
|
|
4878
|
-
}
|
|
4879
|
-
}
|
|
4880
|
-
// Check for removed attributes
|
|
4881
|
-
for (const key of oldKeys) {
|
|
4882
|
-
if (!Object.hasOwn(newNode, key)) {
|
|
4883
|
-
patches.push({
|
|
4884
|
-
type: RemoveAttribute,
|
|
4885
|
-
key
|
|
4886
|
-
});
|
|
4887
|
-
}
|
|
4888
|
-
}
|
|
4889
|
-
return patches;
|
|
5277
|
+
connected: false
|
|
5278
|
+
};
|
|
5279
|
+
const isConnected = () => {
|
|
5280
|
+
const {
|
|
5281
|
+
connected
|
|
5282
|
+
} = state;
|
|
5283
|
+
return connected;
|
|
5284
|
+
};
|
|
5285
|
+
const invoke$1 = (method, ...params) => {
|
|
5286
|
+
return invoke$5(method, ...params);
|
|
5287
|
+
};
|
|
5288
|
+
const set = rpc => {
|
|
5289
|
+
set$7(rpc);
|
|
5290
|
+
state.connected = true;
|
|
4890
5291
|
};
|
|
4891
5292
|
|
|
4892
|
-
const
|
|
4893
|
-
const
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
result.push(current.node);
|
|
4898
|
-
for (let i = current.children.length - 1; i >= 0; i--) {
|
|
4899
|
-
stack.push(current.children[i]);
|
|
5293
|
+
const handleRendererProcessMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
|
|
5294
|
+
const executeViewletCommand = async (uid, command, ...args) => {
|
|
5295
|
+
const fn = viewletCommandMap[`QuickPick.${command}`];
|
|
5296
|
+
if (typeof fn !== 'function') {
|
|
5297
|
+
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
4900
5298
|
}
|
|
5299
|
+
await fn(uid, ...args);
|
|
5300
|
+
await invoke$4('Viewlet.requestRender', uid);
|
|
5301
|
+
};
|
|
5302
|
+
const rpc = await create$8({
|
|
5303
|
+
commandMap: {
|
|
5304
|
+
'Viewlet.executeViewletCommand': executeViewletCommand
|
|
5305
|
+
},
|
|
5306
|
+
messagePort: port
|
|
5307
|
+
});
|
|
5308
|
+
if (setAsRendererProcess) {
|
|
5309
|
+
set(rpc);
|
|
4901
5310
|
}
|
|
4902
|
-
return result;
|
|
4903
5311
|
};
|
|
4904
5312
|
|
|
4905
|
-
const
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
if (currentChildIndex !== index) {
|
|
4911
|
-
appendNavigationPatch(patches, NavigateSibling, index);
|
|
4912
|
-
}
|
|
4913
|
-
return index;
|
|
4914
|
-
};
|
|
4915
|
-
const navigateToParent = (patches, currentChildIndex) => {
|
|
4916
|
-
if (currentChildIndex >= 0) {
|
|
4917
|
-
appendNavigationPatch(patches, NavigateParent, 0);
|
|
4918
|
-
}
|
|
4919
|
-
return -1;
|
|
4920
|
-
};
|
|
4921
|
-
const addTree = (newNode, patches) => {
|
|
4922
|
-
patches.push({
|
|
4923
|
-
type: Add,
|
|
4924
|
-
nodes: treeToArray(newNode)
|
|
5313
|
+
const handleStatusBarMessagePort = async port => {
|
|
5314
|
+
await create$8({
|
|
5315
|
+
commandMap: commandMapRef,
|
|
5316
|
+
isMessagePortOpen: true,
|
|
5317
|
+
messagePort: port
|
|
4925
5318
|
});
|
|
4926
5319
|
};
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
nodes: treeToArray(newNode)
|
|
4931
|
-
});
|
|
5320
|
+
|
|
5321
|
+
const initialize = async () => {
|
|
5322
|
+
// not needed anymore
|
|
4932
5323
|
};
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
for (let i = 0; i < patch.navigations.length; i += 2) {
|
|
4937
|
-
appendNavigationPatch(patches, patch.navigations[i], patch.navigations[i + 1]);
|
|
4938
|
-
}
|
|
4939
|
-
return;
|
|
4940
|
-
case NavigateChild:
|
|
4941
|
-
case NavigateSibling:
|
|
4942
|
-
appendNavigationPatch(patches, patch.type, patch.index);
|
|
4943
|
-
return;
|
|
4944
|
-
case NavigateParent:
|
|
4945
|
-
appendNavigationPatch(patches, patch.type, 0);
|
|
4946
|
-
return;
|
|
4947
|
-
default:
|
|
4948
|
-
patches.push(patch);
|
|
4949
|
-
}
|
|
5324
|
+
|
|
5325
|
+
const invoke = async (applicationId, method, ...args) => {
|
|
5326
|
+
return applicationId === undefined ? invoke$4(method, ...args) : invoke$4('Application.execute', applicationId, method, ...args);
|
|
4950
5327
|
};
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
5328
|
+
|
|
5329
|
+
const QuickPick$2 = 'QuickPick';
|
|
5330
|
+
|
|
5331
|
+
const openStatusBarPicker = async (picker, ...args) => {
|
|
5332
|
+
await invoke(undefined, 'Viewlet.openWidget', QuickPick$2, picker, ...args);
|
|
4955
5333
|
};
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
5334
|
+
|
|
5335
|
+
const getCss = (scrollBarHeight, scrollBarTop, quickPickItemsHeight) => {
|
|
5336
|
+
return `.QuickPick {
|
|
5337
|
+
--QuickPickItemsHeight: ${quickPickItemsHeight}px;
|
|
5338
|
+
--ScrollBarThumbHeight: ${scrollBarHeight}px;
|
|
5339
|
+
--ScrollBarThumbTop: ${scrollBarTop}px;
|
|
5340
|
+
}
|
|
5341
|
+
.QuickPick .QuickPickItems {
|
|
5342
|
+
height: var(--QuickPickItemsHeight);
|
|
5343
|
+
}
|
|
5344
|
+
.QuickPick .ScrollBarThumb {
|
|
5345
|
+
height: var(--ScrollBarThumbHeight);
|
|
5346
|
+
translate: 0px var(--ScrollBarThumbTop);
|
|
5347
|
+
}
|
|
5348
|
+
.QuickPickKeyBinding {
|
|
5349
|
+
margin-left: auto;
|
|
5350
|
+
display: flex;
|
|
5351
|
+
gap: 2px;
|
|
5352
|
+
flex-shrink: 0;
|
|
5353
|
+
pointer-events: none;
|
|
5354
|
+
}
|
|
5355
|
+
.QuickPickKeyBinding .Key {
|
|
5356
|
+
padding: 0 4px;
|
|
5357
|
+
line-height: 16px;
|
|
5358
|
+
}
|
|
5359
|
+
.QuickPickItem:has(.QuickPickKeyBinding) .QuickPickItemLabel {
|
|
5360
|
+
flex-shrink: 1;
|
|
5361
|
+
}`;
|
|
4975
5362
|
};
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
if (
|
|
4979
|
-
|
|
4980
|
-
return;
|
|
4981
|
-
}
|
|
4982
|
-
if (nodePatches.length > 0) {
|
|
4983
|
-
patches.push(...nodePatches);
|
|
4984
|
-
}
|
|
4985
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
4986
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
5363
|
+
|
|
5364
|
+
const getQuickPickItemsHeight = height => {
|
|
5365
|
+
if (height === 0) {
|
|
5366
|
+
return 20;
|
|
4987
5367
|
}
|
|
5368
|
+
return height;
|
|
4988
5369
|
};
|
|
4989
|
-
const
|
|
4990
|
-
const
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
}
|
|
5008
|
-
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
5009
|
-
}
|
|
5010
|
-
navigateToParent(patches, currentChildIndex);
|
|
5011
|
-
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
5012
|
-
patches.push({
|
|
5013
|
-
type: RemoveChild,
|
|
5014
|
-
index: indicesToRemove[j]
|
|
5015
|
-
});
|
|
5016
|
-
}
|
|
5370
|
+
const renderCss = (_oldState, newState) => {
|
|
5371
|
+
const {
|
|
5372
|
+
deltaY,
|
|
5373
|
+
finalDeltaY,
|
|
5374
|
+
headerHeight,
|
|
5375
|
+
height,
|
|
5376
|
+
itemHeight,
|
|
5377
|
+
items,
|
|
5378
|
+
minimumSliderSize,
|
|
5379
|
+
uid
|
|
5380
|
+
} = newState;
|
|
5381
|
+
const quickPickItemsHeight = getQuickPickItemsHeight(height);
|
|
5382
|
+
const listHeight = getListHeight$1(items.length, itemHeight, quickPickItemsHeight);
|
|
5383
|
+
const contentHeight = items.length * itemHeight;
|
|
5384
|
+
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
5385
|
+
const scrollBarTop = Math.round(getScrollBarY(deltaY, finalDeltaY, quickPickItemsHeight - headerHeight, scrollBarHeight));
|
|
5386
|
+
const css = getCss(scrollBarHeight, scrollBarTop, quickPickItemsHeight);
|
|
5387
|
+
return [SetCss, uid, css];
|
|
5017
5388
|
};
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5389
|
+
|
|
5390
|
+
const SetCursorOffset = 'setCursorOffset';
|
|
5391
|
+
const SetFocusedIndex = 'setFocusedIndex';
|
|
5392
|
+
const SetItemsHeight = 'setItemsHeight';
|
|
5393
|
+
|
|
5394
|
+
const renderCursorOffset = (_oldState, newState) => {
|
|
5395
|
+
return ['Viewlet.send', newState.uid, /* method */SetCursorOffset, /* cursorOffset */newState.cursorOffset];
|
|
5024
5396
|
};
|
|
5025
5397
|
|
|
5026
|
-
const
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
break;
|
|
5031
|
-
}
|
|
5032
|
-
patches.pop();
|
|
5033
|
-
}
|
|
5034
|
-
return patches;
|
|
5398
|
+
const QuickPickInput = 'QuickPickInput';
|
|
5399
|
+
|
|
5400
|
+
const renderFocus = (_oldState, newState) => {
|
|
5401
|
+
return ['Viewlet.focusElementByName', newState.uid, QuickPickInput];
|
|
5035
5402
|
};
|
|
5036
5403
|
|
|
5037
|
-
const
|
|
5038
|
-
|
|
5039
|
-
const
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5404
|
+
const renderFocusedIndex = (oldState, newState) => {
|
|
5405
|
+
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
5406
|
+
const newFocusedIndex = newState.focusedIndex - newState.minLineY;
|
|
5407
|
+
return ['Viewlet.send', newState.uid, /* method */SetFocusedIndex, /* oldFocusedIndex */oldFocusedIndex, /* newFocusedIndex */newFocusedIndex];
|
|
5408
|
+
};
|
|
5409
|
+
|
|
5410
|
+
const renderHeight = (_oldState, newState) => {
|
|
5411
|
+
const {
|
|
5412
|
+
height,
|
|
5413
|
+
uid
|
|
5414
|
+
} = newState;
|
|
5415
|
+
if (height === 0) {
|
|
5416
|
+
return ['Viewlet.send', uid, /* method */SetItemsHeight, /* height */20];
|
|
5417
|
+
}
|
|
5418
|
+
return ['Viewlet.send', uid, /* method */SetItemsHeight, /* height */height];
|
|
5046
5419
|
};
|
|
5047
5420
|
|
|
5048
5421
|
const getVisible$1 = (items, minLineY, maxLineY, icons) => {
|
|
@@ -5091,15 +5464,21 @@ const getHighlightSections = (highlights, label) => {
|
|
|
5091
5464
|
return sections;
|
|
5092
5465
|
};
|
|
5093
5466
|
|
|
5094
|
-
const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex) => {
|
|
5467
|
+
const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex, keyBindings = {}) => {
|
|
5095
5468
|
const visibleFocusedIndex = focusedIndex - minLineY;
|
|
5096
5469
|
const visibleItems = protoVisibleItems.map((visibleItem, i) => {
|
|
5470
|
+
const {
|
|
5471
|
+
id
|
|
5472
|
+
} = visibleItem;
|
|
5097
5473
|
const highlights = visibleItem.matches.slice(1);
|
|
5098
5474
|
const sections = getHighlightSections(highlights, visibleItem.label);
|
|
5099
5475
|
return {
|
|
5100
5476
|
...visibleItem,
|
|
5101
5477
|
highlights: sections,
|
|
5102
5478
|
isActive: i === visibleFocusedIndex,
|
|
5479
|
+
...(id && Object.hasOwn(keyBindings, id) && {
|
|
5480
|
+
keyBinding: keyBindings[id]
|
|
5481
|
+
}),
|
|
5103
5482
|
posInSet: minLineY + i + 1,
|
|
5104
5483
|
setSize
|
|
5105
5484
|
};
|
|
@@ -5126,7 +5505,8 @@ const createQuickPickViewModel = (oldState, newState) => {
|
|
|
5126
5505
|
value
|
|
5127
5506
|
} = newState;
|
|
5128
5507
|
const protoVisibleItems = getVisible$1(items, minLineY, maxLineY, icons);
|
|
5129
|
-
const
|
|
5508
|
+
const isCommands = getQuickPickSubProviderId(newState.providerId, getQuickPickPrefix(value)) === Commands$1;
|
|
5509
|
+
const visibleItems = getVisible(items.length, protoVisibleItems, minLineY, focusedIndex, isCommands ? newState.commandKeyBindings : {});
|
|
5130
5510
|
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
5131
5511
|
const newFocusedIndex = focusedIndex - minLineY;
|
|
5132
5512
|
const itemCount = items.length;
|
|
@@ -5340,6 +5720,22 @@ const getQuickPickItemVirtualDom = visibleItem => {
|
|
|
5340
5720
|
type: Div
|
|
5341
5721
|
}, text(description));
|
|
5342
5722
|
}
|
|
5723
|
+
if (visibleItem.keyBinding) {
|
|
5724
|
+
parent.childCount++;
|
|
5725
|
+
const keys = visibleItem.keyBinding.split('+');
|
|
5726
|
+
dom.push({
|
|
5727
|
+
childCount: keys.length,
|
|
5728
|
+
className: 'QuickPickKeyBinding',
|
|
5729
|
+
type: Div
|
|
5730
|
+
});
|
|
5731
|
+
for (const key of keys) {
|
|
5732
|
+
dom.push({
|
|
5733
|
+
childCount: 1,
|
|
5734
|
+
className: 'Key',
|
|
5735
|
+
type: Span
|
|
5736
|
+
}, text(key));
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5343
5739
|
if (removeButton) {
|
|
5344
5740
|
parent.childCount++;
|
|
5345
5741
|
dom.push({
|