@lvce-editor/text-search-view 1.17.3 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1026,6 +1026,34 @@ const listen$1 = async (module, options) => {
1026
1026
  return ipc;
1027
1027
  };
1028
1028
 
1029
+ const createSharedLazyRpc = factory => {
1030
+ let rpcPromise;
1031
+ const getOrCreate = () => {
1032
+ if (!rpcPromise) {
1033
+ rpcPromise = factory();
1034
+ }
1035
+ return rpcPromise;
1036
+ };
1037
+ return {
1038
+ async dispose() {
1039
+ const rpc = await getOrCreate();
1040
+ await rpc.dispose();
1041
+ },
1042
+ async invoke(method, ...params) {
1043
+ const rpc = await getOrCreate();
1044
+ return rpc.invoke(method, ...params);
1045
+ },
1046
+ async invokeAndTransfer(method, ...params) {
1047
+ const rpc = await getOrCreate();
1048
+ return rpc.invokeAndTransfer(method, ...params);
1049
+ },
1050
+ async send(method, ...params) {
1051
+ const rpc = await getOrCreate();
1052
+ rpc.send(method, ...params);
1053
+ }
1054
+ };
1055
+ };
1056
+
1029
1057
  const create$7 = async ({
1030
1058
  commandMap,
1031
1059
  isMessagePortOpen = true,
@@ -1061,34 +1089,6 @@ const create$6 = async ({
1061
1089
  });
1062
1090
  };
1063
1091
 
1064
- const createSharedLazyRpc = factory => {
1065
- let rpcPromise;
1066
- const getOrCreate = () => {
1067
- if (!rpcPromise) {
1068
- rpcPromise = factory();
1069
- }
1070
- return rpcPromise;
1071
- };
1072
- return {
1073
- async dispose() {
1074
- const rpc = await getOrCreate();
1075
- await rpc.dispose();
1076
- },
1077
- async invoke(method, ...params) {
1078
- const rpc = await getOrCreate();
1079
- return rpc.invoke(method, ...params);
1080
- },
1081
- async invokeAndTransfer(method, ...params) {
1082
- const rpc = await getOrCreate();
1083
- return rpc.invokeAndTransfer(method, ...params);
1084
- },
1085
- async send(method, ...params) {
1086
- const rpc = await getOrCreate();
1087
- rpc.send(method, ...params);
1088
- }
1089
- };
1090
- };
1091
-
1092
1092
  const create$5 = async ({
1093
1093
  commandMap,
1094
1094
  isMessagePortOpen,
@@ -1189,7 +1189,7 @@ const None$2 = 'none';
1189
1189
  const ScrollBar$1 = 'scrollbar';
1190
1190
  const Status = 'status';
1191
1191
  const ToolBar = 'toolbar';
1192
- const Tree$1 = 'tree';
1192
+ const Tree$2 = 'tree';
1193
1193
  const TreeItem$1 = 'treeitem';
1194
1194
 
1195
1195
  const Actions = 'Actions';
@@ -1206,7 +1206,7 @@ const HighlightInserted = 'HighlightInserted';
1206
1206
  const IconButton = 'IconButton';
1207
1207
  const IconButtonDisabled = 'IconButtonDisabled';
1208
1208
  const InputBox = 'InputBox';
1209
- const Label$1 = 'Label';
1209
+ const Label = 'Label';
1210
1210
  const List$1 = 'List';
1211
1211
  const MaskIcon = 'MaskIcon';
1212
1212
  const MaskIconBook = 'MaskIconBook';
@@ -1223,7 +1223,7 @@ const MultilineInputBox = 'MultilineInputBox';
1223
1223
  const ScrollBar = 'ScrollBar';
1224
1224
  const ScrollBarThumb = 'ScrollBarThumb';
1225
1225
  const ScrollBarVertical = 'ScrollBarVertical';
1226
- const Search$3 = 'Search';
1226
+ const Search$2 = 'Search';
1227
1227
  const SearchField = 'SearchField';
1228
1228
  const SearchFieldButton = 'SearchFieldButton';
1229
1229
  const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
@@ -1244,7 +1244,7 @@ const SearchToggleButton = 'SearchToggleButton';
1244
1244
  const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1245
1245
  const SourceControlBadge = 'SourceControlBadge';
1246
1246
  const ToggleDetails = 'ToggleDetails';
1247
- const Tree = 'Tree';
1247
+ const Tree$1 = 'Tree';
1248
1248
  const TreeItem = 'TreeItem';
1249
1249
  const TreeItemActive = 'TreeItemActive';
1250
1250
  const TreeItems$1 = 'TreeItems';
@@ -1254,175 +1254,18 @@ const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1254
1254
 
1255
1255
  const File$2 = 7;
1256
1256
 
1257
- const Audio = 0;
1258
1257
  const Button$2 = 1;
1259
- const Col = 2;
1260
- const ColGroup = 3;
1261
1258
  const Div = 4;
1262
- const H1 = 5;
1263
1259
  const Input = 6;
1264
- const Kbd = 7;
1265
1260
  const Span = 8;
1266
- const Table = 9;
1267
- const TBody = 10;
1268
- const Td = 11;
1269
1261
  const Text = 12;
1270
- const Th = 13;
1271
- const THead = 14;
1272
- const Tr = 15;
1273
- const I = 16;
1274
1262
  const Img = 17;
1275
- const Root = 0;
1276
1263
  const Ins = 20;
1277
1264
  const Del = 21;
1278
- const H2 = 22;
1279
- const H3 = 23;
1280
1265
  const H4 = 24;
1281
- const H5 = 25;
1282
- const H6 = 26;
1283
- const Article = 27;
1284
- const Aside = 28;
1285
- const Footer = 29;
1286
- const Header = 30;
1287
- const Nav = 40;
1288
- const Section = 41;
1289
- const Search$2 = 42;
1290
- const Dd = 43;
1291
- const Dl = 44;
1292
- const Figcaption = 45;
1293
- const Figure = 46;
1294
- const Hr = 47;
1295
- const Li = 48;
1296
- const Ol = 49;
1297
- const P = 50;
1298
- const Pre = 51;
1299
- const A = 53;
1300
- const Abbr = 54;
1301
- const Br = 55;
1302
- const Cite = 56;
1303
- const Data = 57;
1304
- const Time = 58;
1305
- const Tfoot = 59;
1306
- const Ul = 60;
1307
- const Video = 61;
1308
1266
  const TextArea = 62;
1309
- const Select = 63;
1310
- const Option = 64;
1311
- const Code = 65;
1312
- const Label = 66;
1313
- const Dt = 67;
1314
- const Iframe = 68;
1315
- const Main = 69;
1316
- const Strong = 70;
1317
- const Em = 71;
1318
- const Style = 72;
1319
- const Html = 73;
1320
- const Head = 74;
1321
- const Title = 75;
1322
- const Meta = 76;
1323
- const Canvas = 77;
1324
- const Form = 78;
1325
- const BlockQuote = 79;
1326
- const Quote = 80;
1327
- const Circle = 81;
1328
- const Defs = 82;
1329
- const Ellipse = 83;
1330
- const G = 84;
1331
- const Line = 85;
1332
- const Path = 86;
1333
- const Polygon = 87;
1334
- const Polyline = 88;
1335
- const Rect = 89;
1336
- const Svg = 90;
1337
- const Use = 91;
1338
1267
  const Reference = 100;
1339
1268
 
1340
- const VirtualDomElements = {
1341
- __proto__: null,
1342
- A,
1343
- Abbr,
1344
- Article,
1345
- Aside,
1346
- Audio,
1347
- BlockQuote,
1348
- Br,
1349
- Button: Button$2,
1350
- Canvas,
1351
- Circle,
1352
- Cite,
1353
- Code,
1354
- Col,
1355
- ColGroup,
1356
- Data,
1357
- Dd,
1358
- Defs,
1359
- Del,
1360
- Div,
1361
- Dl,
1362
- Dt,
1363
- Ellipse,
1364
- Em,
1365
- Figcaption,
1366
- Figure,
1367
- Footer,
1368
- Form,
1369
- G,
1370
- H1,
1371
- H2,
1372
- H3,
1373
- H4,
1374
- H5,
1375
- H6,
1376
- Head,
1377
- Header,
1378
- Hr,
1379
- Html,
1380
- I,
1381
- Iframe,
1382
- Img,
1383
- Input,
1384
- Ins,
1385
- Kbd,
1386
- Label,
1387
- Li,
1388
- Line,
1389
- Main,
1390
- Meta,
1391
- Nav,
1392
- Ol,
1393
- Option,
1394
- P,
1395
- Path,
1396
- Polygon,
1397
- Polyline,
1398
- Pre,
1399
- Quote,
1400
- Rect,
1401
- Reference,
1402
- Root,
1403
- Search: Search$2,
1404
- Section,
1405
- Select,
1406
- Span,
1407
- Strong,
1408
- Style,
1409
- Svg,
1410
- TBody,
1411
- THead,
1412
- Table,
1413
- Td,
1414
- Text,
1415
- TextArea,
1416
- Tfoot,
1417
- Th,
1418
- Time,
1419
- Title,
1420
- Tr,
1421
- Ul,
1422
- Use,
1423
- Video
1424
- };
1425
-
1426
1269
  const Button$1 = 'event.button';
1427
1270
  const ClientX = 'event.clientX';
1428
1271
  const ClientY = 'event.clientY';
@@ -1444,7 +1287,7 @@ const None$1 = 0;
1444
1287
  const LeftClick = 0;
1445
1288
 
1446
1289
  const ClipBoardWorker = 3400;
1447
- const DialogWorker = 7014;
1290
+ const DialogWorker$1 = 7014;
1448
1291
  const IconThemeWorker = 7009;
1449
1292
  const RendererProcess = 1670;
1450
1293
  const RendererWorker = 1;
@@ -1456,6 +1299,7 @@ const Match$1 = 2;
1456
1299
 
1457
1300
  const FocusElementByName = 'Viewlet.focusElementByName';
1458
1301
  const SetCss = 'Viewlet.setCss';
1302
+ const SetDom2 = 'Viewlet.setDom2';
1459
1303
  const SetFocusContext = 'Viewlet.setFocusContext';
1460
1304
  const SetValueByName = 'Viewlet.setValueByName';
1461
1305
  const SetPatches = 'Viewlet.setPatches';
@@ -1491,7 +1335,17 @@ const readText$1 = async () => {
1491
1335
  const {
1492
1336
  invoke: invoke$6,
1493
1337
  set: set$7
1494
- } = create$3(DialogWorker);
1338
+ } = create$3(DialogWorker$1);
1339
+ const prompt$1 = async (message, options = {}) => {
1340
+ return invoke$6('ConfirmPrompt.prompt', message, options);
1341
+ };
1342
+
1343
+ const DialogWorker = {
1344
+ __proto__: null,
1345
+ invoke: invoke$6,
1346
+ prompt: prompt$1,
1347
+ set: set$7
1348
+ };
1495
1349
 
1496
1350
  const {
1497
1351
  invoke: invoke$5,
@@ -1509,15 +1363,20 @@ const {
1509
1363
 
1510
1364
  const {
1511
1365
  invoke: invoke$3,
1512
- invokeAndTransfer,
1513
1366
  set: set$4
1367
+ } = create$3(TextMeasurementWorker);
1368
+
1369
+ const {
1370
+ invoke: invoke$2,
1371
+ invokeAndTransfer,
1372
+ set: set$3
1514
1373
  } = create$3(RendererWorker);
1515
1374
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1516
1375
  number(uid);
1517
1376
  number(menuId);
1518
1377
  number(x);
1519
1378
  number(y);
1520
- await invoke$3('ContextMenu.show2', uid, menuId, x, y, args);
1379
+ await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
1521
1380
  };
1522
1381
  const sendMessagePortToClipBoardWorker$1 = async (port, rpcId) => {
1523
1382
  const command = 'ClipBoard.handleMessagePort';
@@ -1536,31 +1395,46 @@ const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1536
1395
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1537
1396
  };
1538
1397
  const handleWorkspaceRefresh = async () => {
1539
- return invoke$3('Layout.handleWorkspaceRefresh');
1398
+ return invoke$2('Layout.handleWorkspaceRefresh');
1540
1399
  };
1541
1400
  const sendMessagePortToTextMeasurementWorker = async port => {
1542
1401
  const command = 'TextMeasurement.handleMessagePort';
1543
1402
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
1544
1403
  };
1545
1404
  const getPreference = async key => {
1546
- return await invoke$3('Preferences.get', key);
1405
+ return await invoke$2('Preferences.get', key);
1547
1406
  };
1548
1407
  const openUri$1 = async (uri, focus, options) => {
1549
- await invoke$3('Main.openUri', uri, focus, options);
1408
+ await invoke$2('Main.openUri', {
1409
+ ...options,
1410
+ focus,
1411
+ uri
1412
+ });
1413
+ };
1414
+ const openUri2 = async ({
1415
+ focus,
1416
+ selections,
1417
+ uri
1418
+ }) => {
1419
+ await invoke$2('Main.openUri', {
1420
+ focus,
1421
+ selections,
1422
+ uri
1423
+ });
1550
1424
  };
1551
1425
 
1552
1426
  const {
1553
- invoke: invoke$2,
1554
- set: set$3
1427
+ invoke: invoke$1,
1428
+ set: set$2
1555
1429
  } = create$3(TextSearchWorker);
1556
1430
  const getIncrementalResults = async (searchId, minLineY, maxLineY) => {
1557
- return invoke$2('TextSearch.getIncrementalResults', searchId, minLineY, maxLineY);
1431
+ return invoke$1('TextSearch.getIncrementalResults', searchId, minLineY, maxLineY);
1558
1432
  };
1559
1433
  const search$1 = async (...args) => {
1560
- return invoke$2('TextSearch.search', ...args);
1434
+ return invoke$1('TextSearch.search', ...args);
1561
1435
  };
1562
1436
  const searchIncremental = async (...args) => {
1563
- return invoke$2('TextSearch.searchIncremental', ...args);
1437
+ return invoke$1('TextSearch.searchIncremental', ...args);
1564
1438
  };
1565
1439
 
1566
1440
  const toCommandId = key => {
@@ -1821,8 +1695,6 @@ const text = data => {
1821
1695
  };
1822
1696
  };
1823
1697
 
1824
- new Set(Object.values(VirtualDomElements));
1825
-
1826
1698
  const SetText = 1;
1827
1699
  const Replace$1 = 2;
1828
1700
  const SetAttribute = 3;
@@ -1833,6 +1705,7 @@ const NavigateParent = 8;
1833
1705
  const RemoveChild = 9;
1834
1706
  const NavigateSibling = 10;
1835
1707
  const SetReferenceNodeUid = 11;
1708
+ const MultiNavigation = 18;
1836
1709
 
1837
1710
  const isKey = key => {
1838
1711
  return key !== 'type' && key !== 'childCount';
@@ -1893,6 +1766,55 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
1893
1766
  };
1894
1767
  };
1895
1768
 
1769
+ const isNavigationPatch = patch => {
1770
+ switch (patch.type) {
1771
+ case NavigateChild:
1772
+ case NavigateParent:
1773
+ case NavigateSibling:
1774
+ return true;
1775
+ default:
1776
+ return false;
1777
+ }
1778
+ };
1779
+ const getNavigationIndex = patch => {
1780
+ switch (patch.type) {
1781
+ case NavigateChild:
1782
+ case NavigateSibling:
1783
+ return patch.index;
1784
+ default:
1785
+ return 0;
1786
+ }
1787
+ };
1788
+ const appendNavigationPatch = (patches, type, index) => {
1789
+ const previousPatch = patches.at(-1);
1790
+ if (!previousPatch) {
1791
+ patches.push(type === NavigateParent ? {
1792
+ type
1793
+ } : {
1794
+ index,
1795
+ type
1796
+ });
1797
+ return;
1798
+ }
1799
+ if (previousPatch.type === MultiNavigation) {
1800
+ previousPatch.navigations.push(type, index);
1801
+ return;
1802
+ }
1803
+ if (isNavigationPatch(previousPatch)) {
1804
+ patches[patches.length - 1] = {
1805
+ navigations: [previousPatch.type, getNavigationIndex(previousPatch), type, index],
1806
+ type: MultiNavigation
1807
+ };
1808
+ return;
1809
+ }
1810
+ patches.push(type === NavigateParent ? {
1811
+ type
1812
+ } : {
1813
+ index,
1814
+ type
1815
+ });
1816
+ };
1817
+
1896
1818
  const compareNodes = (oldNode, newNode) => {
1897
1819
  // Check if node type changed - return null to signal incompatible nodes
1898
1820
  // (caller should handle this with a Replace operation)
@@ -1901,14 +1823,11 @@ const compareNodes = (oldNode, newNode) => {
1901
1823
  }
1902
1824
  const patches = [];
1903
1825
  // Handle reference nodes - special handling for uid changes
1904
- if (oldNode.type === Reference) {
1905
- if (oldNode.uid !== newNode.uid) {
1906
- patches.push({
1907
- type: SetReferenceNodeUid,
1908
- uid: newNode.uid
1909
- });
1910
- }
1911
- return patches;
1826
+ if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
1827
+ patches.push({
1828
+ type: SetReferenceNodeUid,
1829
+ uid: newNode.uid
1830
+ });
1912
1831
  }
1913
1832
  // Handle text nodes
1914
1833
  if (oldNode.type === Text && newNode.type === Text) {
@@ -1921,8 +1840,8 @@ const compareNodes = (oldNode, newNode) => {
1921
1840
  return patches;
1922
1841
  }
1923
1842
  // Compare attributes
1924
- const oldKeys = getKeys(oldNode);
1925
- const newKeys = getKeys(newNode);
1843
+ const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
1844
+ const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
1926
1845
  // Check for attribute changes
1927
1846
  for (const key of newKeys) {
1928
1847
  if (oldNode[key] !== newNode[key]) {
@@ -1946,34 +1865,31 @@ const compareNodes = (oldNode, newNode) => {
1946
1865
  };
1947
1866
 
1948
1867
  const treeToArray = node => {
1949
- const result = [node.node];
1950
- for (const child of node.children) {
1951
- result.push(...treeToArray(child));
1868
+ const result = [];
1869
+ const stack = [node];
1870
+ while (stack.length > 0) {
1871
+ const current = stack.pop();
1872
+ result.push(current.node);
1873
+ for (let i = current.children.length - 1; i >= 0; i--) {
1874
+ stack.push(current.children[i]);
1875
+ }
1952
1876
  }
1953
1877
  return result;
1954
1878
  };
1955
1879
 
1956
1880
  const navigateToChild = (patches, currentChildIndex, index) => {
1957
1881
  if (currentChildIndex === -1) {
1958
- patches.push({
1959
- type: NavigateChild,
1960
- index
1961
- });
1882
+ appendNavigationPatch(patches, NavigateChild, index);
1962
1883
  return index;
1963
1884
  }
1964
1885
  if (currentChildIndex !== index) {
1965
- patches.push({
1966
- type: NavigateSibling,
1967
- index
1968
- });
1886
+ appendNavigationPatch(patches, NavigateSibling, index);
1969
1887
  }
1970
1888
  return index;
1971
1889
  };
1972
1890
  const navigateToParent = (patches, currentChildIndex) => {
1973
1891
  if (currentChildIndex >= 0) {
1974
- patches.push({
1975
- type: NavigateParent
1976
- });
1892
+ appendNavigationPatch(patches, NavigateParent, 0);
1977
1893
  }
1978
1894
  return -1;
1979
1895
  };
@@ -1989,6 +1905,29 @@ const replaceTree = (newNode, patches) => {
1989
1905
  nodes: treeToArray(newNode)
1990
1906
  });
1991
1907
  };
1908
+ const appendPatch = (patches, patch) => {
1909
+ switch (patch.type) {
1910
+ case MultiNavigation:
1911
+ for (let i = 0; i < patch.navigations.length; i += 2) {
1912
+ appendNavigationPatch(patches, patch.navigations[i], patch.navigations[i + 1]);
1913
+ }
1914
+ return;
1915
+ case NavigateChild:
1916
+ case NavigateSibling:
1917
+ appendNavigationPatch(patches, patch.type, patch.index);
1918
+ return;
1919
+ case NavigateParent:
1920
+ appendNavigationPatch(patches, patch.type, 0);
1921
+ return;
1922
+ default:
1923
+ patches.push(patch);
1924
+ }
1925
+ };
1926
+ const appendPatches = (patches, newPatches) => {
1927
+ for (const patch of newPatches) {
1928
+ appendPatch(patches, patch);
1929
+ }
1930
+ };
1992
1931
  const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
1993
1932
  const nodePatches = compareNodes(oldNode.node, newNode.node);
1994
1933
  if (nodePatches === null) {
@@ -1997,16 +1936,16 @@ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index)
1997
1936
  return nextChildIndex;
1998
1937
  }
1999
1938
  const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
2000
- if (nodePatches.length === 0 && !hasChildrenToCompare) {
1939
+ const childPatches = [];
1940
+ if (hasChildrenToCompare) {
1941
+ diffChildren(oldNode.children, newNode.children, childPatches);
1942
+ }
1943
+ if (nodePatches.length === 0 && childPatches.length === 0) {
2001
1944
  return currentChildIndex;
2002
1945
  }
2003
1946
  const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
2004
- if (nodePatches.length > 0) {
2005
- patches.push(...nodePatches);
2006
- }
2007
- if (hasChildrenToCompare) {
2008
- diffChildren(oldNode.children, newNode.children, patches);
2009
- }
1947
+ patches.push(...nodePatches);
1948
+ appendPatches(patches, childPatches);
2010
1949
  return nextChildIndex;
2011
1950
  };
2012
1951
  const diffRootNode = (oldNode, newNode, patches) => {
@@ -2062,7 +2001,7 @@ const diffTrees = (oldTree, newTree, patches, path) => {
2062
2001
  const removeTrailingNavigationPatches = patches => {
2063
2002
  while (patches.length > 0) {
2064
2003
  const patch = patches.at(-1);
2065
- if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
2004
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
2066
2005
  break;
2067
2006
  }
2068
2007
  patches.pop();
@@ -2112,6 +2051,95 @@ const clearSearchResults$1 = state => {
2112
2051
  };
2113
2052
  };
2114
2053
 
2054
+ const clamp$1 = (num, min, max) => {
2055
+ return Math.min(Math.max(num, min), max);
2056
+ };
2057
+
2058
+ const File = 1;
2059
+ const Match = 2;
2060
+ const Context = 3;
2061
+
2062
+ const getFilteredResults = (results, collapsedPaths) => {
2063
+ if (collapsedPaths.length === 0) {
2064
+ return results;
2065
+ }
2066
+ const filteredResults = [];
2067
+ let collapsedDepth = -1;
2068
+ for (const result of results) {
2069
+ const depth = result.depth ?? (result.type === File ? 0 : 1);
2070
+ if (collapsedDepth !== -1) {
2071
+ if (depth > collapsedDepth) {
2072
+ continue;
2073
+ }
2074
+ collapsedDepth = -1;
2075
+ }
2076
+ filteredResults.push(result);
2077
+ if (result.type === File && collapsedPaths.includes(result.text)) {
2078
+ collapsedDepth = depth;
2079
+ }
2080
+ }
2081
+ return filteredResults;
2082
+ };
2083
+
2084
+ // TODO optimize this function to return the minimum number
2085
+ // of visible items needed, e.g. when not scrolled 5 items with
2086
+ // 20px fill 100px but when scrolled 6 items are needed
2087
+ const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
2088
+ return Math.ceil(listHeight / itemHeight) + 1;
2089
+ };
2090
+
2091
+ const getTreeListItems = results => {
2092
+ const listItems = [];
2093
+ const directories = new Set();
2094
+ let matchDepth = 0;
2095
+ for (const result of results) {
2096
+ if (result.type !== File) {
2097
+ listItems.push({
2098
+ ...result,
2099
+ depth: matchDepth
2100
+ });
2101
+ continue;
2102
+ }
2103
+ const path = result.text.startsWith('./') ? result.text.slice(2) : result.text;
2104
+ const parts = path.split('/');
2105
+ let directory = '';
2106
+ for (let i = 0; i < parts.length - 1; i++) {
2107
+ directory = directory ? `${directory}/${parts[i]}` : parts[i];
2108
+ if (!directories.has(directory)) {
2109
+ directories.add(directory);
2110
+ listItems.push({
2111
+ depth: i,
2112
+ end: 0,
2113
+ isDirectory: true,
2114
+ lineNumber: 0,
2115
+ start: 0,
2116
+ text: directory,
2117
+ type: File
2118
+ });
2119
+ }
2120
+ }
2121
+ matchDepth = parts.length;
2122
+ listItems.push({
2123
+ ...result,
2124
+ depth: matchDepth - 1,
2125
+ text: path
2126
+ });
2127
+ }
2128
+ return listItems;
2129
+ };
2130
+
2131
+ const getScrollBarSize$1 = (size, contentSize, minimumSliderSize) => {
2132
+ if (size >= contentSize) {
2133
+ return 0;
2134
+ }
2135
+ return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
2136
+ };
2137
+ const getScrollBarOffset$1 = (delta, finalDelta, size, scrollBarSize) => {
2138
+ const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
2139
+ return scrollBarOffset;
2140
+ };
2141
+ const getScrollBarY$1 = getScrollBarOffset$1;
2142
+
2115
2143
  const getFilePath = text => {
2116
2144
  // TODO make api stricter so that results always have the same shape
2117
2145
  if (text.startsWith('./')) {
@@ -2120,13 +2148,9 @@ const getFilePath = text => {
2120
2148
  return text;
2121
2149
  };
2122
2150
 
2123
- const File = 1;
2124
- const Match = 2;
2125
- const Context = 3;
2126
-
2127
2151
  const getIconsCached = (dirents, fileIconCache) => {
2128
2152
  return dirents.map(dirent => {
2129
- if (dirent.type !== File) {
2153
+ if (dirent.type !== File || dirent.isDirectory) {
2130
2154
  return '';
2131
2155
  }
2132
2156
  const path = getFilePath(dirent.text);
@@ -2143,7 +2167,7 @@ const getFileName = path => {
2143
2167
  };
2144
2168
 
2145
2169
  const isFile = match => {
2146
- return match.type === File;
2170
+ return match.type === File && !match.isDirectory;
2147
2171
  };
2148
2172
 
2149
2173
  const getMissingDirents = (searchResults, fileIconCache) => {
@@ -2224,60 +2248,72 @@ const getFileIcons = async (items, fileIconCache) => {
2224
2248
  };
2225
2249
  };
2226
2250
 
2227
- const getFilteredResults = (results, collapsedPaths) => {
2228
- if (collapsedPaths.length === 0) {
2229
- return results;
2230
- }
2231
- const filteredResults = [];
2232
- let isExcluded = false;
2233
- for (const result of results) {
2234
- if (result.type === File) {
2235
- filteredResults.push(result);
2236
- isExcluded = collapsedPaths.includes(result.text) ? true : false;
2237
- }
2238
- if ((result.type === Match || result.type === Context) && !isExcluded) {
2239
- filteredResults.push(result);
2240
- }
2251
+ const updateVisibleFileIcons = async (state, fileIconCache) => {
2252
+ const {
2253
+ fileIconCache: currentFileIconCache,
2254
+ listItems,
2255
+ maxLineY,
2256
+ minLineY
2257
+ } = state;
2258
+ const visibleItems = listItems.slice(minLineY, maxLineY);
2259
+ const {
2260
+ icons,
2261
+ newFileIconCache
2262
+ } = await getFileIcons(visibleItems, currentFileIconCache);
2263
+ return {
2264
+ ...state,
2265
+ fileIconCache: newFileIconCache,
2266
+ icons
2267
+ };
2268
+ };
2269
+ const updateVisibleFileIconsWhenRangeChanges = async (oldState, newState) => {
2270
+ if (oldState.listItems === newState.listItems && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY) {
2271
+ return newState;
2241
2272
  }
2242
- return filteredResults;
2273
+ return updateVisibleFileIcons(newState);
2243
2274
  };
2244
2275
 
2245
- // TODO optimize this function to return the minimum number
2246
- // of visible items needed, e.g. when not scrolled 5 items with
2247
- // 20px fill 100px but when scrolled 6 items are needed
2248
- const getNumberOfVisibleItems$1 = (listHeight, itemHeight) => {
2249
- return Math.ceil(listHeight / itemHeight) + 1;
2250
- };
2276
+ const List = 1;
2277
+ const Tree = 2;
2251
2278
 
2252
2279
  const applyCollapsedPaths = async (state, collapsedPaths, listFocusedIndex) => {
2253
2280
  const {
2254
- fileIconCache,
2281
+ deltaY: oldDeltaY,
2255
2282
  headerHeight,
2256
2283
  height,
2257
2284
  itemHeight,
2258
- items
2285
+ items,
2286
+ minimumSliderSize,
2287
+ viewMode
2259
2288
  } = state;
2260
- const filteredResults = getFilteredResults(items, collapsedPaths);
2261
- const {
2262
- icons,
2263
- newFileIconCache
2264
- } = await getFileIcons(filteredResults, fileIconCache);
2289
+ const sourceItems = viewMode === Tree ? getTreeListItems(items) : items;
2290
+ const filteredResults = getFilteredResults(sourceItems, collapsedPaths);
2265
2291
  const total = filteredResults.length;
2266
2292
  const listHeight = height - headerHeight;
2293
+ const contentHeight = total * itemHeight;
2294
+ const finalDeltaY = Math.max(contentHeight - listHeight, 0);
2295
+ const deltaY = clamp$1(oldDeltaY, 0, finalDeltaY);
2296
+ const minLineY = Math.floor(deltaY / itemHeight);
2267
2297
  const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
2268
- const maxLineY = Math.min(numberOfVisible, total);
2269
- return {
2298
+ const maxLineY = Math.min(minLineY + numberOfVisible, total);
2299
+ const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
2300
+ const scrollBarY = finalDeltaY === 0 ? 0 : getScrollBarY$1(deltaY, finalDeltaY, listHeight, scrollBarHeight);
2301
+ const updatedState = {
2270
2302
  ...state,
2271
2303
  collapsedPaths,
2272
- fileIconCache: newFileIconCache,
2304
+ deltaY,
2305
+ finalDeltaY,
2273
2306
  focus: FocusSearchResults,
2274
2307
  focusSource: Script,
2275
- icons,
2276
2308
  listFocused: true,
2277
2309
  listFocusedIndex,
2278
2310
  listItems: filteredResults,
2279
- maxLineY
2311
+ maxLineY,
2312
+ minLineY,
2313
+ scrollBarHeight,
2314
+ scrollBarY
2280
2315
  };
2316
+ return updateVisibleFileIcons(updatedState);
2281
2317
  };
2282
2318
 
2283
2319
  const getPaths = items => {
@@ -2292,12 +2328,13 @@ const getPaths = items => {
2292
2328
  const collapseAll$1 = async state => {
2293
2329
  const {
2294
2330
  items,
2295
- listFocusedIndex
2331
+ listFocusedIndex,
2332
+ listItems
2296
2333
  } = state;
2297
2334
  if (items.length === 0) {
2298
2335
  return state;
2299
2336
  }
2300
- const paths = getPaths(items);
2337
+ const paths = getPaths(listItems);
2301
2338
  return applyCollapsedPaths(state, paths, listFocusedIndex);
2302
2339
  };
2303
2340
 
@@ -2363,13 +2400,6 @@ const getHeaderHeightForFlags = (headerHeight, oldFlags, newFlags) => {
2363
2400
  return newTopHeight + additionalHeight;
2364
2401
  };
2365
2402
 
2366
- const invoke$1 = (method, ...params) => {
2367
- return get$1(TextMeasurementWorker).invoke(method, ...params);
2368
- };
2369
- const set$2 = rpc => {
2370
- set$9(TextMeasurementWorker, rpc);
2371
- };
2372
-
2373
2403
  const SearchMessageFontFamily = 'system-ui';
2374
2404
  const SearchMessageFontSize = 13;
2375
2405
  const SearchMessageLineHeight = 13;
@@ -2381,7 +2411,7 @@ const getSearchMessageHeight = async (message, width, flags) => {
2381
2411
  }
2382
2412
  const horizontalSpace = hasDetailsExpanded(flags) ? SearchMessageExpandedHorizontalSpace : SearchMessageCollapsedHorizontalSpace;
2383
2413
  const availableWidth = Math.max(width - horizontalSpace, 1);
2384
- const textHeight = await invoke$1('TextMeasurement.measureTextBlockHeight', message, SearchMessageFontFamily, SearchMessageFontSize, SearchMessageLineHeight, availableWidth);
2414
+ const textHeight = await invoke$3('TextMeasurement.measureTextBlockHeight', message, SearchMessageFontFamily, SearchMessageFontSize, SearchMessageLineHeight, availableWidth);
2385
2415
  return Math.max(textHeight + VerticalPadding, Minimum);
2386
2416
  };
2387
2417
 
@@ -2503,11 +2533,10 @@ const {
2503
2533
  set: set$1,
2504
2534
  wrapAsyncCommand,
2505
2535
  wrapCommand,
2506
- wrapGetter
2536
+ wrapGetter,
2537
+ wrapSerialCommand
2507
2538
  } = create$2();
2508
2539
 
2509
- const List = 1;
2510
-
2511
2540
  const create$1 = ({
2512
2541
  headerHeight = 0,
2513
2542
  itemHeight,
@@ -2824,18 +2853,6 @@ const removeItemFromItems = (items, index, matchCount, fileCount) => {
2824
2853
  };
2825
2854
  };
2826
2855
 
2827
- const getScrollBarSize$1 = (size, contentSize, minimumSliderSize) => {
2828
- if (size >= contentSize) {
2829
- return 0;
2830
- }
2831
- return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
2832
- };
2833
- const getScrollBarOffset$1 = (delta, finalDelta, size, scrollBarSize) => {
2834
- const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
2835
- return scrollBarOffset;
2836
- };
2837
- const getScrollBarY$1 = getScrollBarOffset$1;
2838
-
2839
2856
  const emptyObject = {};
2840
2857
  const i18nString = (key, placeholders = emptyObject) => {
2841
2858
  if (placeholders === emptyObject) {
@@ -3125,7 +3142,6 @@ const removeIndex = async (state, index) => {
3125
3142
  const {
3126
3143
  deltaY,
3127
3144
  fileCount,
3128
- fileIconCache,
3129
3145
  height,
3130
3146
  itemHeight,
3131
3147
  items,
@@ -3158,19 +3174,12 @@ const removeIndex = async (state, index) => {
3158
3174
  const listHeight = height - headerHeight;
3159
3175
  const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
3160
3176
  const finalDeltaY = Math.max(contentHeight - listHeight, 0);
3161
- const visible = newItems.slice(0, maxLineY);
3162
- const {
3163
- icons,
3164
- newFileIconCache
3165
- } = await getFileIcons(visible, fileIconCache);
3166
- return {
3177
+ const updatedState = {
3167
3178
  ...state,
3168
3179
  deltaY: newDeltaY,
3169
3180
  fileCount: newFileCount,
3170
- fileIconCache: newFileIconCache,
3171
3181
  finalDeltaY,
3172
3182
  headerHeight,
3173
- icons,
3174
3183
  items: newItems,
3175
3184
  listFocusedIndex: newFocusedIndex,
3176
3185
  listItems: newItems,
@@ -3181,6 +3190,7 @@ const removeIndex = async (state, index) => {
3181
3190
  minLineY: newMinLineY,
3182
3191
  scrollBarHeight
3183
3192
  };
3193
+ return updateVisibleFileIcons(updatedState);
3184
3194
  };
3185
3195
 
3186
3196
  const dismissItem = state => {
@@ -3585,7 +3595,7 @@ const getMenuEntriesFile = (state, props) => {
3585
3595
  label: copyAll()
3586
3596
  }, menuEntrySeparator, {
3587
3597
  args: [uri],
3588
- command: 'Search.revealInExplorer',
3598
+ command: 'RevealInExplorer.reveal',
3589
3599
  flags: None$1,
3590
3600
  id: 'revealInExplorerView',
3591
3601
  label: revealInExplorerView()
@@ -3611,7 +3621,7 @@ const getMenuEntriesMatch = (state, props) => {
3611
3621
  label: copyAll()
3612
3622
  }, menuEntrySeparator, {
3613
3623
  args: [uri],
3614
- command: 'Search.revealInExplorer',
3624
+ command: 'RevealInExplorer.reveal',
3615
3625
  flags: None$1,
3616
3626
  id: 'revealInExplorerView',
3617
3627
  label: revealInExplorerView()
@@ -3690,7 +3700,7 @@ const openSearchEditor = async state => {
3690
3700
 
3691
3701
  const getSearchExcludes = async (fallback = []) => {
3692
3702
  try {
3693
- const value = await invoke$3('Preferences.get', 'search.exclude');
3703
+ const value = await invoke$2('Preferences.get', 'search.exclude');
3694
3704
  if (Array.isArray(value)) {
3695
3705
  return value.filter(item => typeof item === 'string');
3696
3706
  }
@@ -3781,7 +3791,7 @@ const getSearchHeaderHeight = (flags, messageHeight, warningHeight) => {
3781
3791
  };
3782
3792
 
3783
3793
  const measureTextHeight = (text, fontFamily, fontSize, lineHeight, width) => {
3784
- return invoke$3('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, `${lineHeight}px`, width);
3794
+ return invoke$2('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, `${lineHeight}px`, width);
3785
3795
  };
3786
3796
 
3787
3797
  const SearchWarningFontFamily = 'system-ui';
@@ -3821,7 +3831,7 @@ const textSearch = async (root, query, options, assetDir, platform, searchId, ui
3821
3831
  if (!hasOpenEditors(options.flags)) {
3822
3832
  return search$1(root, query, options, assetDir, platform, searchId, uid);
3823
3833
  }
3824
- const openEditorUris = await invoke$3('GetActiveEditor.getOpenEditorUris');
3834
+ const openEditorUris = await invoke$2('GetActiveEditor.getOpenEditorUris');
3825
3835
  return search$1(root, query, {
3826
3836
  ...options,
3827
3837
  openEditorUris
@@ -3859,7 +3869,13 @@ const handleUpdateFull = async (state, update) => {
3859
3869
  const scheme = getProtocol(root);
3860
3870
  const isFileSearch = scheme === '' || scheme === 'file';
3861
3871
  const shouldUsePullBasedSearch = usePullBasedSearch && isFileSearch;
3862
- const searchId = shouldUsePullBasedSearch ? crypto.randomUUID() : '';
3872
+ const searchId = crypto.randomUUID();
3873
+ const current = get(uid);
3874
+ const oldState = current ? current.oldState : state;
3875
+ set$1(uid, oldState, {
3876
+ ...partialNewState,
3877
+ searchId
3878
+ });
3863
3879
  const {
3864
3880
  limitHit,
3865
3881
  results
@@ -3881,6 +3897,10 @@ const handleUpdateFull = async (state, update) => {
3881
3897
  usePullBasedSearch: shouldUsePullBasedSearch,
3882
3898
  useRegularExpression: Boolean(flags & UseRegularExpression$2)
3883
3899
  }, assetDir, platform, searchId, uid);
3900
+ const latestAfterSearch = get(uid);
3901
+ if (latestAfterSearch.newState.searchId !== searchId) {
3902
+ return state;
3903
+ }
3884
3904
  if (!Array.isArray(results)) {
3885
3905
  throw new TypeError('results must be of type array');
3886
3906
  }
@@ -3904,8 +3924,12 @@ const handleUpdateFull = async (state, update) => {
3904
3924
  icons,
3905
3925
  newFileIconCache
3906
3926
  } = await getFileIcons(visible, fileIconCache);
3907
- return {
3908
- ...partialNewState,
3927
+ const latest = get(uid);
3928
+ if (latest.newState.searchId !== searchId) {
3929
+ return state;
3930
+ }
3931
+ const updatedState = {
3932
+ ...latest.newState,
3909
3933
  collapsedPaths: [],
3910
3934
  deltaY: 0,
3911
3935
  fileCount,
@@ -3929,6 +3953,8 @@ const handleUpdateFull = async (state, update) => {
3929
3953
  threads,
3930
3954
  value
3931
3955
  };
3956
+ set$1(uid, latest.oldState, updatedState);
3957
+ return state;
3932
3958
  };
3933
3959
 
3934
3960
  const waitForNextFrame = async () => {
@@ -3968,8 +3994,7 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
3968
3994
  minLineY: 0
3969
3995
  };
3970
3996
  set$1(uid, latest2.oldState, updatedState2);
3971
- // @ts-ignore
3972
- await invoke$3('Search.rerender');
3997
+ await invoke$2('Viewlet.requestRender', uid);
3973
3998
  await waitForNextFrame();
3974
3999
  }
3975
4000
  await resultPromise;
@@ -4092,6 +4117,9 @@ const handleUpdatePullBased = async (state, update) => {
4092
4117
  if (!latest) {
4093
4118
  return state;
4094
4119
  }
4120
+ if (latest.newState.searchId !== searchId) {
4121
+ return state;
4122
+ }
4095
4123
  const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
4096
4124
  const {
4097
4125
  fileCount,
@@ -4099,15 +4127,21 @@ const handleUpdatePullBased = async (state, update) => {
4099
4127
  } = getTextSearchResultCounts(latest.newState.items);
4100
4128
  const message = getStatusMessage(resultCount, fileCount);
4101
4129
  const [messageHeight, warningHeight] = await Promise.all([getSearchMessageHeight(message, width, flags), getSearchWarningMessageHeight(limitHitWarning, width)]);
4130
+ const current = get(uid);
4131
+ if (current.newState.searchId !== searchId) {
4132
+ return state;
4133
+ }
4102
4134
  const headerHeight = getSearchHeaderHeight(flags, messageHeight, warningHeight);
4103
- return {
4104
- ...latest.newState,
4135
+ const updatedState = {
4136
+ ...current.newState,
4105
4137
  headerHeight,
4106
4138
  limitHit,
4107
4139
  limitHitWarning,
4108
4140
  message,
4109
4141
  messageHeight
4110
4142
  };
4143
+ set$1(uid, current.oldState, updatedState);
4144
+ return state;
4111
4145
  };
4112
4146
 
4113
4147
  const handleUpdateValidationError = (state, update, searchInputErrorMessage) => {
@@ -4163,7 +4197,12 @@ const handleUpdate = async (state, update) => {
4163
4197
  workspacePath
4164
4198
  } = partialNewState;
4165
4199
  if (isEmptyString(value) || isEmptyString(workspacePath)) {
4166
- return handleUpdateEmpty(state, update);
4200
+ const newState = handleUpdateEmpty(state, update);
4201
+ const current = get(newState.uid);
4202
+ if (current) {
4203
+ set$1(newState.uid, current.oldState, newState);
4204
+ }
4205
+ return newState;
4167
4206
  }
4168
4207
  const searchInputErrorMessage = validateSearchInput(value, flags);
4169
4208
  if (searchInputErrorMessage) {
@@ -4193,7 +4232,36 @@ const refresh = async state => {
4193
4232
  };
4194
4233
 
4195
4234
  const viewAsTree = async state => {
4196
- return state;
4235
+ const {
4236
+ headerHeight,
4237
+ height,
4238
+ itemHeight,
4239
+ items,
4240
+ minimumSliderSize
4241
+ } = state;
4242
+ if (items.length === 0) {
4243
+ return state;
4244
+ }
4245
+ const listItems = getTreeListItems(items);
4246
+ const total = listItems.length;
4247
+ const contentHeight = total * itemHeight;
4248
+ const listHeight = height - headerHeight;
4249
+ const finalDeltaY = Math.max(contentHeight - listHeight, 0);
4250
+ const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
4251
+ const maxLineY = Math.min(numberOfVisible, total);
4252
+ const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
4253
+ const updatedState = {
4254
+ ...state,
4255
+ collapsedPaths: [],
4256
+ deltaY: 0,
4257
+ finalDeltaY,
4258
+ listItems,
4259
+ maxLineY,
4260
+ minLineY: 0,
4261
+ scrollBarHeight,
4262
+ viewMode: Tree
4263
+ };
4264
+ return updateVisibleFileIcons(updatedState);
4197
4265
  };
4198
4266
 
4199
4267
  const handleActionClick = async (state, name) => {
@@ -4225,7 +4293,7 @@ const noop = state => {
4225
4293
  };
4226
4294
 
4227
4295
  const applyBulkReplacement = async bulkEdits => {
4228
- await invoke$3('BulkReplacement.applyBulkReplacement', bulkEdits);
4296
+ await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
4229
4297
  };
4230
4298
 
4231
4299
  const getReplacedMessage = (fileCount, replaceCount, replacement) => {
@@ -4292,17 +4360,9 @@ const getReplacingMessage = (fileCount, replaceCount) => {
4292
4360
  return replacingManyOccurrencesInManyFiles(replaceCount, fileCount);
4293
4361
  };
4294
4362
 
4295
- const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
4296
- const prompt = async (text, options) => {
4297
- try {
4298
- return await invoke$6('ConfirmPrompt.prompt', text, options);
4299
- } catch (error) {
4300
- if (!String(error).includes(missingDialogWorkerRelay)) {
4301
- throw error;
4302
- }
4303
- return invoke$3('ConfirmPrompt.prompt', text, options);
4304
- }
4305
- };
4363
+ const {
4364
+ prompt
4365
+ } = DialogWorker;
4306
4366
 
4307
4367
  const getReplaceAllConfirmText = (matchCount, fileCount, replacement) => {
4308
4368
  if (matchCount === 1) {
@@ -4375,7 +4435,6 @@ const replaceAllInFocusedFile = async (state, fileIndex) => {
4375
4435
  const {
4376
4436
  deltaY,
4377
4437
  fileCount,
4378
- fileIconCache,
4379
4438
  height,
4380
4439
  itemHeight,
4381
4440
  items,
@@ -4415,19 +4474,12 @@ const replaceAllInFocusedFile = async (state, fileIndex) => {
4415
4474
  const listHeight = height - headerHeight;
4416
4475
  const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
4417
4476
  const finalDeltaY = Math.max(contentHeight - listHeight, 0);
4418
- const visible = newItems.slice(0, newMaxLineY);
4419
- const {
4420
- icons,
4421
- newFileIconCache
4422
- } = await getFileIcons(visible, fileIconCache);
4423
- return {
4477
+ const updatedState = {
4424
4478
  ...state,
4425
4479
  deltaY: newDeltaY,
4426
4480
  fileCount: newFileCount,
4427
- fileIconCache: newFileIconCache,
4428
4481
  finalDeltaY,
4429
4482
  headerHeight,
4430
- icons,
4431
4483
  items: newItems,
4432
4484
  listFocusedIndex: newFocusedIndex,
4433
4485
  listItems: newItems,
@@ -4436,8 +4488,10 @@ const replaceAllInFocusedFile = async (state, fileIndex) => {
4436
4488
  message,
4437
4489
  messageHeight,
4438
4490
  minLineY: newMinLineY,
4439
- scrollBarHeight
4491
+ scrollBarHeight,
4492
+ searchId: ''
4440
4493
  };
4494
+ return updateVisibleFileIcons(updatedState);
4441
4495
  };
4442
4496
  const confirmReplaceAll = async (state, fileIndex) => {
4443
4497
  const {
@@ -4465,9 +4519,11 @@ const replaceAllConfirmed = async (state, fileIndex) => {
4465
4519
  workspacePath
4466
4520
  } = state;
4467
4521
  const bulkEdits = getReplaceElements(items, workspacePath, replacement);
4468
- // TODO this function should return an error message if an error occurred during bulk edit
4469
- await applyBulkReplacement(bulkEdits);
4470
- await handleWorkspaceRefresh();
4522
+ if (bulkEdits.length > 0) {
4523
+ // TODO this function should return an error message if an error occurred during bulk edit
4524
+ await applyBulkReplacement(bulkEdits);
4525
+ await handleWorkspaceRefresh();
4526
+ }
4471
4527
  const fileCount = bulkEdits.length;
4472
4528
  const message = getReplacedMessage(fileCount, matchCount, replacement);
4473
4529
  const {
@@ -4482,7 +4538,8 @@ const replaceAllConfirmed = async (state, fileIndex) => {
4482
4538
  maxLineY: 0,
4483
4539
  message,
4484
4540
  messageHeight,
4485
- minLineY: 0
4541
+ minLineY: 0,
4542
+ searchId: ''
4486
4543
  };
4487
4544
  };
4488
4545
  const replaceAll = async state => {
@@ -4498,7 +4555,9 @@ const replaceAllWithProgress = async context => {
4498
4555
  const state = context.getState();
4499
4556
  const {
4500
4557
  fileCount: totalFileCount,
4501
- matchCount: totalMatchCount
4558
+ matchCount: totalMatchCount,
4559
+ searchId: activeSearchId,
4560
+ uid
4502
4561
  } = state;
4503
4562
  const actualIndex = getActualIndex(state);
4504
4563
  const fileIndex = getFileIndex(state, actualIndex);
@@ -4508,16 +4567,49 @@ const replaceAllWithProgress = async context => {
4508
4567
  if (!shouldReplace) {
4509
4568
  return;
4510
4569
  }
4511
- const message = getReplacingMessage(fileCount, matchCount);
4512
- const messageLayout = await getSearchMessageLayout(state, message);
4570
+ if (context.getState().searchId !== activeSearchId) {
4571
+ return;
4572
+ }
4573
+ const replacementSearchId = crypto.randomUUID();
4574
+ let progressUpdate = {};
4575
+ if (matchCount > 0) {
4576
+ const message = getReplacingMessage(fileCount, matchCount);
4577
+ const messageLayout = await getSearchMessageLayout(state, message);
4578
+ progressUpdate = {
4579
+ ...messageLayout,
4580
+ message
4581
+ };
4582
+ }
4513
4583
  await context.updateState(latestState => ({
4514
4584
  ...latestState,
4515
- ...messageLayout,
4516
- message
4585
+ ...progressUpdate,
4586
+ searchId: replacementSearchId
4517
4587
  }));
4518
- await invoke$3('Search.rerender');
4519
- const updatedState = await replaceAllConfirmed(context.getState(), fileIndex);
4520
- await context.updateState(() => updatedState);
4588
+ if (matchCount > 0) {
4589
+ await invoke$2('Viewlet.requestRender', uid);
4590
+ }
4591
+ const currentBeforeReplacement = get(uid);
4592
+ let replacementState = context.getState();
4593
+ if (currentBeforeReplacement && currentBeforeReplacement.newState.searchId !== replacementSearchId) {
4594
+ if (currentBeforeReplacement.newState.searchId !== activeSearchId) {
4595
+ return;
4596
+ }
4597
+ replacementState = {
4598
+ ...currentBeforeReplacement.newState,
4599
+ ...progressUpdate,
4600
+ searchId: replacementSearchId
4601
+ };
4602
+ }
4603
+ const generationState = {
4604
+ ...replacementState
4605
+ };
4606
+ set$1(uid, generationState, generationState);
4607
+ const updatedState = await replaceAllConfirmed(generationState, fileIndex);
4608
+ const completedGenerationState = {
4609
+ ...updatedState
4610
+ };
4611
+ set$1(uid, completedGenerationState, completedGenerationState);
4612
+ set$1(uid, generationState, updatedState);
4521
4613
  };
4522
4614
 
4523
4615
  const toggleContextLines = async state => {
@@ -4669,21 +4761,11 @@ const handleHeaderFocusOut = state => {
4669
4761
  };
4670
4762
 
4671
4763
  const handleIconThemeChange = async state => {
4672
- const {
4673
- items,
4674
- maxLineY,
4675
- minLineY
4676
- } = state;
4677
- const visibleItems = items.slice(minLineY, maxLineY);
4678
- const {
4679
- icons,
4680
- newFileIconCache
4681
- } = await getFileIcons(visibleItems, {});
4682
- return {
4764
+ const stateWithEmptyIconCache = {
4683
4765
  ...state,
4684
- fileIconCache: newFileIconCache,
4685
- icons
4766
+ fileIconCache: {}
4686
4767
  };
4768
+ return updateVisibleFileIcons(stateWithEmptyIconCache);
4687
4769
  };
4688
4770
 
4689
4771
  const handleIncludeInput = (state, includeValue, inputSource = Script) => {
@@ -4808,6 +4890,7 @@ const getNewSelections = (selections, name, newValue) => {
4808
4890
  }
4809
4891
  };
4810
4892
  };
4893
+
4811
4894
  const updateValue = (state, name, newValue) => {
4812
4895
  const {
4813
4896
  selections
@@ -5038,7 +5121,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
5038
5121
  throw new TypeError(`Viewlet command not found: ${command}`);
5039
5122
  }
5040
5123
  await fn(uid, ...args);
5041
- await invoke$3('Viewlet.requestRender', uid);
5124
+ await invoke$2('Viewlet.requestRender', uid);
5042
5125
  };
5043
5126
  const rpc = await create$7({
5044
5127
  commandMap: {
@@ -5052,7 +5135,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
5052
5135
  };
5053
5136
 
5054
5137
  const openFolder = async () => {
5055
- await invoke$3('Dialog.openFolder');
5138
+ await invoke$2('Dialog.openFolder');
5056
5139
  };
5057
5140
 
5058
5141
  const handleOpenFolderClick = async state => {
@@ -5062,17 +5145,19 @@ const handleOpenFolderClick = async state => {
5062
5145
 
5063
5146
  const handlePullResultsFound = async (state, resultSearchId, newResults) => {
5064
5147
  const {
5065
- fileIconCache,
5066
- height,
5067
- itemHeight,
5068
- listItems,
5069
- minimumSliderSize,
5070
- searchId,
5071
5148
  uid
5072
5149
  } = state;
5073
- if (searchId !== resultSearchId) {
5150
+ const current = get(uid);
5151
+ if (!current || current.newState.searchId !== resultSearchId) {
5074
5152
  return state;
5075
5153
  }
5154
+ const {
5155
+ fileIconCache,
5156
+ height,
5157
+ itemHeight,
5158
+ listItems,
5159
+ minimumSliderSize
5160
+ } = current.newState;
5076
5161
  const allResults = [...listItems, ...newResults];
5077
5162
  const {
5078
5163
  fileCount,
@@ -5082,7 +5167,7 @@ const handlePullResultsFound = async (state, resultSearchId, newResults) => {
5082
5167
  const {
5083
5168
  headerHeight,
5084
5169
  messageHeight
5085
- } = await getSearchMessageLayout(state, message);
5170
+ } = await getSearchMessageLayout(current.newState, message);
5086
5171
  const total = allResults.length;
5087
5172
  const contentHeight = total * itemHeight;
5088
5173
  const listHeight = height - headerHeight;
@@ -5096,6 +5181,9 @@ const handlePullResultsFound = async (state, resultSearchId, newResults) => {
5096
5181
  newFileIconCache
5097
5182
  } = await getFileIcons(visible, fileIconCache);
5098
5183
  const latest = get(uid);
5184
+ if (!latest || latest.newState.searchId !== resultSearchId) {
5185
+ return state;
5186
+ }
5099
5187
  const updatedState = {
5100
5188
  ...latest.newState,
5101
5189
  fileCount,
@@ -5113,16 +5201,11 @@ const handlePullResultsFound = async (state, resultSearchId, newResults) => {
5113
5201
  minLineY: 0,
5114
5202
  scrollBarHeight
5115
5203
  };
5116
- const oldState = latest ? latest.oldState : state;
5117
- set$1(uid, oldState, updatedState);
5118
- await invoke$3('Search.rerender');
5204
+ set$1(uid, latest.oldState, updatedState);
5205
+ await invoke$2('Viewlet.requestRender', uid);
5119
5206
  return state;
5120
5207
  };
5121
5208
 
5122
- const clamp$1 = (num, min, max) => {
5123
- return Math.min(Math.max(num, min), max);
5124
- };
5125
-
5126
5209
  const handleResize = async (state, x, y, width, height) => {
5127
5210
  const {
5128
5211
  deltaY,
@@ -5278,7 +5361,7 @@ const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) =
5278
5361
  scrollBarY
5279
5362
  };
5280
5363
  };
5281
- const focusIndex = (state, index) => {
5364
+ const focusIndex$1 = (state, index) => {
5282
5365
  const {
5283
5366
  headerHeight,
5284
5367
  height,
@@ -5326,24 +5409,24 @@ const next = (items, index) => {
5326
5409
  const previous = (items, index) => {
5327
5410
  return (index === 0 ? items.length : index) - 1;
5328
5411
  };
5329
- const focusFirst = state => {
5412
+ const focusFirst$1 = state => {
5330
5413
  const firstIndex = first();
5331
- return focusIndex(state, firstIndex);
5414
+ return focusIndex$1(state, firstIndex);
5332
5415
  };
5333
- const focusLast = state => {
5416
+ const focusLast$1 = state => {
5334
5417
  const {
5335
5418
  items
5336
5419
  } = state;
5337
5420
  const lastIndex = last(items);
5338
- return focusIndex(state, lastIndex);
5421
+ return focusIndex$1(state, lastIndex);
5339
5422
  };
5340
- const focusNext = state => {
5423
+ const focusNext$1 = state => {
5341
5424
  const {
5342
5425
  focusedIndex,
5343
5426
  items
5344
5427
  } = state;
5345
5428
  const nextIndex = next(items, focusedIndex);
5346
- return focusIndex(state, nextIndex);
5429
+ return focusIndex$1(state, nextIndex);
5347
5430
  };
5348
5431
 
5349
5432
  // based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
@@ -5354,7 +5437,7 @@ const isLastIndex = (array, index) => {
5354
5437
  const lastIndex = array => {
5355
5438
  return array.length - 1;
5356
5439
  };
5357
- const focusNextPage = state => {
5440
+ const focusNextPage$1 = state => {
5358
5441
  const {
5359
5442
  focusedIndex,
5360
5443
  items,
@@ -5365,9 +5448,9 @@ const focusNextPage = state => {
5365
5448
  return state;
5366
5449
  }
5367
5450
  const indexNextPage = Math.min(maxLineY + (maxLineY - minLineY) - 2, lastIndex(items));
5368
- return focusIndex(state, indexNextPage);
5451
+ return focusIndex$1(state, indexNextPage);
5369
5452
  };
5370
- const focusPrevious = state => {
5453
+ const focusPrevious$1 = state => {
5371
5454
  const {
5372
5455
  focusedIndex,
5373
5456
  items
@@ -5376,9 +5459,9 @@ const focusPrevious = state => {
5376
5459
  return state;
5377
5460
  }
5378
5461
  const previousIndex = previous(items, focusedIndex);
5379
- return focusIndex(state, previousIndex);
5462
+ return focusIndex$1(state, previousIndex);
5380
5463
  };
5381
- const focusPreviousPage = state => {
5464
+ const focusPreviousPage$1 = state => {
5382
5465
  const {
5383
5466
  focusedIndex,
5384
5467
  maxLineY,
@@ -5388,7 +5471,7 @@ const focusPreviousPage = state => {
5388
5471
  return state;
5389
5472
  }
5390
5473
  const indexPreviousPage = Math.max(minLineY - (maxLineY - minLineY) + 1, 0);
5391
- return focusIndex(state, indexPreviousPage);
5474
+ return focusIndex$1(state, indexPreviousPage);
5392
5475
  };
5393
5476
  const handleScrollBarCaptureLost = state => {
5394
5477
  return {
@@ -5439,7 +5522,7 @@ const setDeltaY = (state, value) => {
5439
5522
  scrollBarY
5440
5523
  };
5441
5524
  };
5442
- const handleScrollBarClick = (state, eventY) => {
5525
+ const handleScrollBarClick$1 = (state, eventY) => {
5443
5526
  const {
5444
5527
  deltaY,
5445
5528
  finalDeltaY,
@@ -5478,7 +5561,7 @@ const getNewPercent = (contentHeight, scrollBarHeight, relativeY) => {
5478
5561
  // clicked at bottom
5479
5562
  return 1;
5480
5563
  };
5481
- const handleScrollBarMove = (state, eventY) => {
5564
+ const handleScrollBarMove$1 = (state, eventY) => {
5482
5565
  const {
5483
5566
  finalDeltaY,
5484
5567
  handleOffset,
@@ -5499,6 +5582,54 @@ const handleWheel$1 = (state, deltaMode, deltaY) => {
5499
5582
  return setDeltaY(state, state.deltaY + deltaY);
5500
5583
  };
5501
5584
 
5585
+ const applyListOperation = async (state, operation) => {
5586
+ const {
5587
+ items,
5588
+ listItems
5589
+ } = state;
5590
+ const listState = {
5591
+ ...state,
5592
+ items: listItems
5593
+ };
5594
+ const updatedListState = operation(listState);
5595
+ if (updatedListState === listState) {
5596
+ return state;
5597
+ }
5598
+ const updatedState = {
5599
+ ...updatedListState,
5600
+ items
5601
+ };
5602
+ return updateVisibleFileIconsWhenRangeChanges(state, updatedState);
5603
+ };
5604
+
5605
+ const focusFirst = async state => {
5606
+ return applyListOperation(state, focusFirst$1);
5607
+ };
5608
+
5609
+ const focusIndex = async (state, index) => {
5610
+ return applyListOperation(state, listState => focusIndex$1(listState, index));
5611
+ };
5612
+
5613
+ const focusLast = async state => {
5614
+ return applyListOperation(state, focusLast$1);
5615
+ };
5616
+
5617
+ const focusNext = async state => {
5618
+ return applyListOperation(state, focusNext$1);
5619
+ };
5620
+
5621
+ const focusNextPage = async state => {
5622
+ return applyListOperation(state, focusNextPage$1);
5623
+ };
5624
+
5625
+ const focusPrevious = async state => {
5626
+ return applyListOperation(state, focusPrevious$1);
5627
+ };
5628
+
5629
+ const focusPreviousPage = async state => {
5630
+ return applyListOperation(state, focusPreviousPage$1);
5631
+ };
5632
+
5502
5633
  const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemCount) => {
5503
5634
  const relativeY = eventY - y - topHeight + deltaY;
5504
5635
  const index = Math.floor(relativeY / itemHeight);
@@ -5545,8 +5676,10 @@ const selectIndexPreview = async (state, searchResult, index) => {
5545
5676
  const fileResult = listItems[fileIndex];
5546
5677
  const relativePath = getRelativePath(fileResult.text);
5547
5678
  const absolutePath = `${workspacePath}${relativePath}`;
5548
- await openUri(absolutePath, true, {
5549
- selections: new Uint32Array([rowIndex, startColumnIndex, rowIndex, endColumnIndex])
5679
+ await openUri2({
5680
+ focus: true,
5681
+ selections: new Uint32Array([rowIndex, startColumnIndex, rowIndex, endColumnIndex]),
5682
+ uri: absolutePath
5550
5683
  });
5551
5684
  return {
5552
5685
  ...state,
@@ -5616,31 +5749,16 @@ const handleListPointerDown = async (state, button, name) => {
5616
5749
  };
5617
5750
  };
5618
5751
 
5752
+ const handleScrollBarClick = async (state, eventY) => {
5753
+ return applyListOperation(state, listState => handleScrollBarClick$1(listState, eventY));
5754
+ };
5755
+
5756
+ const handleScrollBarMove = async (state, eventY) => {
5757
+ return applyListOperation(state, listState => handleScrollBarMove$1(listState, eventY));
5758
+ };
5759
+
5619
5760
  const handleWheel = async (state, deltaMode, deltaY) => {
5620
- const {
5621
- maxLineY: oldMaxLineY,
5622
- minLineY: oldMinLineY
5623
- } = state;
5624
- const newState = handleWheel$1(state, deltaMode, deltaY);
5625
- if (newState.minLineY === oldMinLineY && newState.maxLineY === oldMaxLineY) {
5626
- return newState;
5627
- }
5628
- const {
5629
- fileIconCache,
5630
- listItems,
5631
- maxLineY,
5632
- minLineY
5633
- } = newState;
5634
- const visibleItems = listItems.slice(minLineY, maxLineY);
5635
- const {
5636
- icons,
5637
- newFileIconCache
5638
- } = await getFileIcons(visibleItems, fileIconCache);
5639
- return {
5640
- ...newState,
5641
- fileIconCache: newFileIconCache,
5642
- icons
5643
- };
5761
+ return applyListOperation(state, listState => handleWheel$1(listState, deltaMode, deltaY));
5644
5762
  };
5645
5763
 
5646
5764
  const getUsePullBasedSearch = async () => {
@@ -5876,24 +5994,32 @@ const getTreeItemIndent = depth => {
5876
5994
  return baseIndent + depth * defaultIndent;
5877
5995
  };
5878
5996
 
5879
- const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, renderFolderPaths, originalResults) => {
5997
+ const normalizeRelativePath = path => {
5998
+ if (path.startsWith('./')) {
5999
+ return path.slice(2);
6000
+ }
6001
+ return path;
6002
+ };
6003
+
6004
+ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, renderFolderPaths, originalResults, resultDepth, isDirectory) => {
5880
6005
  const path = text;
5881
6006
  const absolutePath = getRelativePath(path);
5882
6007
  const baseName = pathBaseName(path);
5883
6008
  const relativeFolderPath = getRelativeFolderPath(path);
5884
- const displayText = renderFolderPaths && relativeFolderPath ? `${baseName} — ${relativeFolderPath}` : baseName;
5885
- const index = originalResults.indexOf(results[i]);
5886
- const matchCount = getMatchCount(originalResults, index);
6009
+ const displayText = renderFolderPaths && relativeFolderPath && !isDirectory ? `${baseName} — ${relativeFolderPath}` : baseName;
6010
+ const normalizedPath = normalizeRelativePath(path);
6011
+ const index = originalResults.findIndex(result => result.type === results[i].type && normalizeRelativePath(result.text) === normalizedPath);
6012
+ const matchCount = isDirectory ? 0 : getMatchCount(originalResults, index);
5887
6013
  const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
5888
- const badgeText = String(matchCount);
5889
- const depth = 0;
6014
+ const badgeText = isDirectory ? '' : String(matchCount);
6015
+ const depth = resultDepth ?? 0;
5890
6016
  const indent = getTreeItemIndent(depth);
5891
6017
  return {
5892
6018
  badgeText,
5893
6019
  depth,
5894
6020
  expanded,
5895
6021
  focused,
5896
- icon: fileIcons[relativeIndex],
6022
+ icon: isDirectory ? '' : fileIcons[relativeIndex],
5897
6023
  indent,
5898
6024
  matchLength: 0,
5899
6025
  matchStart: 0,
@@ -5905,8 +6031,8 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
5905
6031
  };
5906
6032
  };
5907
6033
 
5908
- const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, posInSet, start, focused) => {
5909
- const depth = 1;
6034
+ const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, posInSet, start, focused, resultDepth = 1) => {
6035
+ const depth = resultDepth;
5910
6036
  const indent = getTreeItemIndent(depth);
5911
6037
  return {
5912
6038
  badgeText: '',
@@ -5928,6 +6054,8 @@ const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, pos
5928
6054
  const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, renderFolderPaths, minLineY, originalResults) => {
5929
6055
  const result = results[i];
5930
6056
  const {
6057
+ depth,
6058
+ isDirectory,
5931
6059
  start,
5932
6060
  text,
5933
6061
  type
@@ -5937,11 +6065,11 @@ const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, repl
5937
6065
  const relativeIndex = i - minLineY;
5938
6066
  switch (type) {
5939
6067
  case Context:
5940
- return getDisplayResultMatch(setSize, 0, '', text, posInSet, 0, focused);
6068
+ return getDisplayResultMatch(setSize, 0, '', text, posInSet, 0, focused, depth);
5941
6069
  case File:
5942
- return getSearchDisplayResultFile(results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, renderFolderPaths, originalResults);
6070
+ return getSearchDisplayResultFile(results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, renderFolderPaths, originalResults, depth, isDirectory);
5943
6071
  case Match:
5944
- return getDisplayResultMatch(setSize, searchTermLength, replacement, text, posInSet, start, focused);
6072
+ return getDisplayResultMatch(setSize, searchTermLength, replacement, text, posInSet, start, focused, depth);
5945
6073
  default:
5946
6074
  throw new Error('unexpected search result type');
5947
6075
  }
@@ -6711,7 +6839,7 @@ const highlighted = {
6711
6839
  };
6712
6840
  const label1 = {
6713
6841
  childCount: 1,
6714
- className: mergeClassNames(Label$1, Grow),
6842
+ className: mergeClassNames(Label, Grow),
6715
6843
  type: Div
6716
6844
  };
6717
6845
  const label3 = {
@@ -6829,10 +6957,10 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
6829
6957
  const childCount = scrollbarHeight === 0 ? 1 : 2;
6830
6958
  return [{
6831
6959
  childCount,
6832
- className: mergeClassNames(Viewlet, List$1, Tree, focusOutline ? FocusOutline : Empty$1),
6960
+ className: mergeClassNames(Viewlet, List$1, Tree$1, focusOutline ? FocusOutline : Empty$1),
6833
6961
  onBlur: HandleListBlur,
6834
6962
  onFocus: HandleListFocus,
6835
- role: Tree$1,
6963
+ role: Tree$2,
6836
6964
  tabIndex: Focusable,
6837
6965
  type: Div
6838
6966
  // TODO renable this when dom diffing is supported
@@ -6840,7 +6968,7 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
6840
6968
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
6841
6969
  };
6842
6970
 
6843
- const className = mergeClassNames(Viewlet, Search$3);
6971
+ const className = mergeClassNames(Viewlet, Search$2);
6844
6972
  const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0, initial = false, isSearchEditor = false, contextLines = 1, contextLinesEnabled = false, workspacePath) => {
6845
6973
  if (initial) {
6846
6974
  return [];
@@ -6863,8 +6991,11 @@ const getDom = newState => {
6863
6991
 
6864
6992
  // TODO cache rendered dom so that it can be used for dom diffing
6865
6993
  const renderIncremental = (oldState, newState) => {
6866
- const oldDom = getDom(oldState);
6867
6994
  const newDom = getDom(newState);
6995
+ if (oldState.replacement !== newState.replacement) {
6996
+ return [SetDom2, newState.uid, newDom];
6997
+ }
6998
+ const oldDom = getDom(oldState);
6868
6999
  const patches = diffTree(oldDom, newDom);
6869
7000
  return [SetPatches, newState.uid, patches];
6870
7001
  };
@@ -6926,6 +7057,9 @@ const applyRender = (oldState, newState, diffResult) => {
6926
7057
  const renderDirect = async (uid, commands) => {
6927
7058
  const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
6928
7059
  const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
7060
+ if (rendererProcessCommands.length === 0) {
7061
+ return rendererWorkerCommands;
7062
+ }
6929
7063
  const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
6930
7064
  return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
6931
7065
  };
@@ -7036,7 +7170,7 @@ const getActions = state => {
7036
7170
  type: Button
7037
7171
  }, {
7038
7172
  command: '',
7039
- enabled: hasSearchResults,
7173
+ enabled: true,
7040
7174
  icon: ListFlat,
7041
7175
  id: ViewAsTree,
7042
7176
  label: viewAsTree$1(),
@@ -7145,19 +7279,6 @@ const rerender = state => {
7145
7279
  };
7146
7280
  };
7147
7281
 
7148
- const revealInExplorerActual = async uri => {
7149
- await invoke$3('SideBar.show', 'Explorer');
7150
- const states = await invoke$3('Viewlet.getAllStates');
7151
- const viewlets = Object.values(states);
7152
- const sideBar = viewlets.find(viewlet => viewlet.currentViewletId === 'Explorer');
7153
- const explorerUid = Math.max(...viewlets.filter(viewlet => viewlet.parentUid === sideBar.uid).map(viewlet => viewlet.uid));
7154
- await invoke$3('Viewlet.executeViewletCommand', explorerUid, 'reveal', uri);
7155
- };
7156
- const revealInExplorer = async (state, uri) => {
7157
- await revealInExplorerActual(uri);
7158
- return state;
7159
- };
7160
-
7161
7282
  const saveState = state => {
7162
7283
  const {
7163
7284
  collapsedPaths,
@@ -7261,6 +7382,7 @@ const getNewHistory = (history, newValue) => {
7261
7382
  const cutHistory = newHistory.slice(0, maxHistoryLength);
7262
7383
  return cutHistory;
7263
7384
  };
7385
+
7264
7386
  const submit = state => {
7265
7387
  const {
7266
7388
  history,
@@ -7380,16 +7502,16 @@ const commandMap$1 = {
7380
7502
  'TextSearch.handleActionClick': wrapCommand(handleActionClick),
7381
7503
  'TextSearch.handleClickAt': wrapCommand(handleClickAt),
7382
7504
  'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
7383
- 'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
7505
+ 'TextSearch.handleExcludeInput': wrapSerialCommand(handleExcludeInput),
7384
7506
  'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
7385
7507
  'TextSearch.handleHeaderClick': wrapCommand(handleHeaderClick),
7386
7508
  'TextSearch.handleHeaderContextMenu': wrapCommand(handleHeaderContextMenu),
7387
7509
  'TextSearch.handleHeaderFocusIn': wrapCommand(handleHeaderFocusIn),
7388
7510
  'TextSearch.handleHeaderFocusOut': wrapCommand(handleHeaderFocusOut),
7389
7511
  'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
7390
- 'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
7391
- 'TextSearch.handleInput': wrapCommand(handleInput),
7392
- 'TextSearch.handleInput2': wrapCommand(handleInput2),
7512
+ 'TextSearch.handleIncludeInput': wrapSerialCommand(handleIncludeInput),
7513
+ 'TextSearch.handleInput': wrapSerialCommand(handleInput),
7514
+ 'TextSearch.handleInput2': wrapSerialCommand(handleInput2),
7393
7515
  'TextSearch.handleInputBlur': wrapCommand(handleInputBlur),
7394
7516
  'TextSearch.handleInputContextMenu': wrapCommand(handleInputContextMenu),
7395
7517
  'TextSearch.handleInputCopy': wrapCommand(handleInputCopy),
@@ -7404,7 +7526,7 @@ const commandMap$1 = {
7404
7526
  'TextSearch.handleMessagePort': handleDirectMessagePort,
7405
7527
  'TextSearch.handleOpenFolderClick': wrapCommand(handleOpenFolderClick),
7406
7528
  'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound),
7407
- 'TextSearch.handleReplaceInput': wrapCommand(handleReplaceInput),
7529
+ 'TextSearch.handleReplaceInput': wrapSerialCommand(handleReplaceInput),
7408
7530
  'TextSearch.handleResize': wrapCommand(handleResize),
7409
7531
  'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
7410
7532
  'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
@@ -7413,9 +7535,9 @@ const commandMap$1 = {
7413
7535
  'TextSearch.handleWheel': wrapCommand(handleWheel),
7414
7536
  'TextSearch.handleWorkspaceChange': wrapCommand(handleWorkspaceChange),
7415
7537
  'TextSearch.loadContent': wrapCommand(loadContent),
7416
- 'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
7538
+ 'TextSearch.nextHistoryResult': wrapSerialCommand(nextHistoryResult),
7417
7539
  'TextSearch.openSearchEditor': wrapCommand(openSearchEditor),
7418
- 'TextSearch.previousHistoryResult': wrapCommand(previousHistoryResult),
7540
+ 'TextSearch.previousHistoryResult': wrapSerialCommand(previousHistoryResult),
7419
7541
  'TextSearch.refresh': wrapCommand(refresh),
7420
7542
  'TextSearch.removeCurrent': wrapCommand(removeCurrent),
7421
7543
  'TextSearch.removeIndex': wrapCommand(removeIndex),
@@ -7429,21 +7551,20 @@ const commandMap$1 = {
7429
7551
  'TextSearch.replaceAllInFile': wrapCommand(replaceAllInFile),
7430
7552
  'TextSearch.rerender': rerender,
7431
7553
  'TextSearch.restoreState': restoreState,
7432
- 'TextSearch.revealInExplorer': wrapCommand(revealInExplorer),
7433
7554
  'TextSearch.saveState': wrapGetter(saveState),
7434
7555
  'TextSearch.selectIndex': wrapCommand(selectIndex),
7435
- 'TextSearch.setLimit': wrapCommand(setLimit),
7436
- 'TextSearch.submit': wrapCommand(submit),
7556
+ 'TextSearch.setLimit': wrapSerialCommand(setLimit),
7557
+ 'TextSearch.submit': wrapSerialCommand(submit),
7437
7558
  'TextSearch.terminate': terminate,
7438
7559
  'TextSearch.textSearch': textSearch,
7439
- 'TextSearch.toggleMatchCase': wrapCommand(toggleMatchCase),
7440
- 'TextSearch.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord),
7441
- 'TextSearch.toggleOpenEditors': wrapCommand(toggleOpenEditors),
7560
+ 'TextSearch.toggleMatchCase': wrapSerialCommand(toggleMatchCase),
7561
+ 'TextSearch.toggleMatchWholeWord': wrapSerialCommand(toggleMatchWholeWord),
7562
+ 'TextSearch.toggleOpenEditors': wrapSerialCommand(toggleOpenEditors),
7442
7563
  'TextSearch.togglePreserveCase': wrapCommand(togglePreserveCase),
7443
- 'TextSearch.toggleReplace': wrapCommand(toggleReplace),
7564
+ 'TextSearch.toggleReplace': wrapSerialCommand(toggleReplace),
7444
7565
  'TextSearch.toggleSearchDetails': wrapCommand(toggleDetailsExpanded),
7445
- 'TextSearch.toggleUseIgnoreFiles': wrapCommand(toggleUseIgnoreFiles),
7446
- 'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
7566
+ 'TextSearch.toggleUseIgnoreFiles': wrapSerialCommand(toggleUseIgnoreFiles),
7567
+ 'TextSearch.toggleUseRegularExpression': wrapSerialCommand(toggleUseRegularExpression),
7447
7568
  'TextSearch.viewAsTree': wrapCommand(viewAsTree)
7448
7569
  };
7449
7570
 
@@ -7491,7 +7612,7 @@ const initializeTextMeasurementWorker = async () => {
7491
7612
  commandMap: {},
7492
7613
  send: send$1
7493
7614
  });
7494
- set$2(rpc);
7615
+ set$4(rpc);
7495
7616
  };
7496
7617
 
7497
7618
  const commandMap = {
@@ -7510,7 +7631,7 @@ const launchTextSearchWorker = async () => {
7510
7631
 
7511
7632
  const initializeTextSearchWorker = async () => {
7512
7633
  const rpc = await launchTextSearchWorker();
7513
- set$3(rpc);
7634
+ set$2(rpc);
7514
7635
  };
7515
7636
 
7516
7637
  const listen = async () => {
@@ -7518,7 +7639,7 @@ const listen = async () => {
7518
7639
  const rpc = await create$4({
7519
7640
  commandMap: commandMap$1
7520
7641
  });
7521
- set$4(rpc);
7642
+ set$3(rpc);
7522
7643
  await Promise.all([initializeClipBoardWorker(), initializeDialogWorker(), initializeIconThemeWorker(), initializeTextMeasurementWorker(), initializeTextSearchWorker()]);
7523
7644
  };
7524
7645