@lvce-editor/text-search-worker 3.7.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/textSearchWorkerMain.js +241 -108
- package/package.json +1 -1
|
@@ -882,6 +882,7 @@ const FocusSearchRegex = 33;
|
|
|
882
882
|
const FocusSearchWholeWord = 34;
|
|
883
883
|
const FocusSearchReplaceAll = 35;
|
|
884
884
|
const FocusSearchPreserveCase = 36;
|
|
885
|
+
const FocusSearchIncludeInput = 1007;
|
|
885
886
|
|
|
886
887
|
const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '') => {
|
|
887
888
|
const state = {
|
|
@@ -1059,7 +1060,12 @@ const UiStrings = {
|
|
|
1059
1060
|
ReplacedOneOccurrenceInOneFile: "Replaced 1 occurrence across 1 file with '{PH1}'",
|
|
1060
1061
|
ToggleReplace: 'Toggle Replace',
|
|
1061
1062
|
UseRegularExpression: 'Use Regular Expression',
|
|
1062
|
-
ViewAsTree: 'View as Tree'
|
|
1063
|
+
ViewAsTree: 'View as Tree',
|
|
1064
|
+
FilesToInclude: 'Files to Include',
|
|
1065
|
+
FilesToExclude: 'Files to Exclude',
|
|
1066
|
+
ToggleSearchDetails: 'Toggle Search Details',
|
|
1067
|
+
SearchOnlyOpenEditors: 'Search Only Open Editors',
|
|
1068
|
+
UseExcludeSettings: 'Use Exclude Settings'
|
|
1063
1069
|
};
|
|
1064
1070
|
const noResults = () => {
|
|
1065
1071
|
return i18nString(UiStrings.NoResults);
|
|
@@ -1079,6 +1085,9 @@ const preserveCase = () => {
|
|
|
1079
1085
|
const matchWholeWord = () => {
|
|
1080
1086
|
return i18nString(UiStrings.MatchWholeWord);
|
|
1081
1087
|
};
|
|
1088
|
+
const toggleSearchDetails = () => {
|
|
1089
|
+
return i18nString(UiStrings.ToggleSearchDetails);
|
|
1090
|
+
};
|
|
1082
1091
|
const useRegularExpression = () => {
|
|
1083
1092
|
return i18nString(UiStrings.UseRegularExpression);
|
|
1084
1093
|
};
|
|
@@ -1151,6 +1160,18 @@ const viewAsTree = () => {
|
|
|
1151
1160
|
const collapseAll = () => {
|
|
1152
1161
|
return i18nString(UiStrings.CollapseAll);
|
|
1153
1162
|
};
|
|
1163
|
+
const filesToInclude = () => {
|
|
1164
|
+
return i18nString(UiStrings.FilesToInclude);
|
|
1165
|
+
};
|
|
1166
|
+
const filesToExclude = () => {
|
|
1167
|
+
return i18nString(UiStrings.FilesToExclude);
|
|
1168
|
+
};
|
|
1169
|
+
const searchOnlyOpenEditors = () => {
|
|
1170
|
+
return i18nString(UiStrings.SearchOnlyOpenEditors);
|
|
1171
|
+
};
|
|
1172
|
+
const useExcludeSettings = () => {
|
|
1173
|
+
return i18nString(UiStrings.UseExcludeSettings);
|
|
1174
|
+
};
|
|
1154
1175
|
|
|
1155
1176
|
const getStatusMessage = (resultCount, fileResultCount) => {
|
|
1156
1177
|
number(resultCount);
|
|
@@ -1324,6 +1345,8 @@ const ReplaceExpanded = 1 << 2; // 4
|
|
|
1324
1345
|
const MatchWholeWord = 1 << 3; // 8
|
|
1325
1346
|
const MatchCase = 1 << 4; // 16
|
|
1326
1347
|
const DetailsExpanded = 1 << 5; // 32
|
|
1348
|
+
const OpenEditors = 1 << 6; // 64
|
|
1349
|
+
const UseIgnoreFiles = 1 << 7; // 128
|
|
1327
1350
|
|
|
1328
1351
|
const hasPreserveCase = flags => {
|
|
1329
1352
|
return (flags & PreserveCase) === PreserveCase;
|
|
@@ -1357,6 +1380,7 @@ const Status = 'status';
|
|
|
1357
1380
|
const Tree = 'tree';
|
|
1358
1381
|
const TreeItem$1 = 'treeitem';
|
|
1359
1382
|
const ToolBar = 'toolbar';
|
|
1383
|
+
const Button$2 = 'button';
|
|
1360
1384
|
|
|
1361
1385
|
const Actions = 'Actions';
|
|
1362
1386
|
const Badge = 'Badge';
|
|
@@ -1373,12 +1397,15 @@ const IconButton = 'IconButton';
|
|
|
1373
1397
|
const Label = 'Label';
|
|
1374
1398
|
const List = 'List';
|
|
1375
1399
|
const MaskIcon = 'MaskIcon';
|
|
1400
|
+
const MaskIconBook = 'MaskIconBook';
|
|
1376
1401
|
const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
|
|
1377
1402
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
1378
1403
|
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
1404
|
+
const MaskIconEllipsis = 'MaskIconEllipsis';
|
|
1379
1405
|
const MaskIconPreserveCase = 'MaskIconPreserveCase';
|
|
1380
1406
|
const MaskIconRegex = 'MaskIconRegex';
|
|
1381
1407
|
const MaskIconReplaceAll = 'MaskIconReplaceAll';
|
|
1408
|
+
const MaskIconSettings = 'MaskIconSettings';
|
|
1382
1409
|
const MaskIconWholeWord = 'MaskIconWholeWord';
|
|
1383
1410
|
const MultilineInputBox = 'MultilineInputBox';
|
|
1384
1411
|
const Search$1 = 'Search';
|
|
@@ -1389,12 +1416,16 @@ const SearchFieldButtons = 'SearchFieldButtons';
|
|
|
1389
1416
|
const SearchFieldContainer = 'SearchFieldContainer';
|
|
1390
1417
|
const SearchHeader = 'SearchHeader';
|
|
1391
1418
|
const SearchHeaderDetails = 'SearchHeaderDetails';
|
|
1419
|
+
const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
|
|
1420
|
+
const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
|
|
1421
|
+
const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
|
|
1392
1422
|
const SearchHeaderTop = 'SearchHeaderTop';
|
|
1393
1423
|
const SearchHeaderTopRight = 'SearchHeaderTopRight';
|
|
1394
1424
|
const SearchRemove = 'SearchRemove';
|
|
1395
1425
|
const SearchToggleButton = 'SearchToggleButton';
|
|
1396
1426
|
const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
1397
1427
|
const SourceControlBadge = 'SourceControlBadge';
|
|
1428
|
+
const ToggleDetails = 'ToggleDetails';
|
|
1398
1429
|
const TreeItem = 'TreeItem';
|
|
1399
1430
|
const TreeItemActive = 'TreeItemActive';
|
|
1400
1431
|
const Viewlet = 'Viewlet';
|
|
@@ -1403,13 +1434,13 @@ const ViewletSearchMessage = 'ViewletSearchMessage';
|
|
|
1403
1434
|
const Button$1 = 1;
|
|
1404
1435
|
|
|
1405
1436
|
const Button = 1;
|
|
1437
|
+
const Del = 21;
|
|
1406
1438
|
const Div = 4;
|
|
1407
|
-
const
|
|
1408
|
-
const Span = 8;
|
|
1409
|
-
const Text = 12;
|
|
1439
|
+
const H4 = 24;
|
|
1410
1440
|
const Img = 17;
|
|
1411
1441
|
const Ins = 20;
|
|
1412
|
-
const
|
|
1442
|
+
const Span = 8;
|
|
1443
|
+
const Text = 12;
|
|
1413
1444
|
const TextArea = 62;
|
|
1414
1445
|
|
|
1415
1446
|
const mergeClassNames = (...classNames) => {
|
|
@@ -1602,6 +1633,48 @@ const HandleHeaderClick = 'handleHeaderClick';
|
|
|
1602
1633
|
const HandleHeaderFocusIn = 'handleHeaderFocusIn';
|
|
1603
1634
|
const HandleListBlur = 'handleListBlur';
|
|
1604
1635
|
|
|
1636
|
+
const getSearchDetailsToggleVirtualDom = () => {
|
|
1637
|
+
return [{
|
|
1638
|
+
type: Div,
|
|
1639
|
+
className: ToggleDetails,
|
|
1640
|
+
role: Button$2,
|
|
1641
|
+
tabIndex: 0,
|
|
1642
|
+
ariaLabel: toggleSearchDetails(),
|
|
1643
|
+
title: toggleSearchDetails(),
|
|
1644
|
+
childCount: 1
|
|
1645
|
+
}, {
|
|
1646
|
+
type: Div,
|
|
1647
|
+
className: mergeClassNames(MaskIcon, MaskIconEllipsis),
|
|
1648
|
+
childCount: 0
|
|
1649
|
+
}];
|
|
1650
|
+
};
|
|
1651
|
+
|
|
1652
|
+
const text = data => {
|
|
1653
|
+
return {
|
|
1654
|
+
type: Text,
|
|
1655
|
+
text: data,
|
|
1656
|
+
childCount: 0
|
|
1657
|
+
};
|
|
1658
|
+
};
|
|
1659
|
+
|
|
1660
|
+
const getSearchMessageVirtualDom = message => {
|
|
1661
|
+
return [{
|
|
1662
|
+
type: Div,
|
|
1663
|
+
className: ViewletSearchMessage,
|
|
1664
|
+
role: Status,
|
|
1665
|
+
tabIndex: 0,
|
|
1666
|
+
childCount: 1
|
|
1667
|
+
}, text(message)];
|
|
1668
|
+
};
|
|
1669
|
+
|
|
1670
|
+
const getSearchHeaderDetailsCollapsedVirtualDom = message => {
|
|
1671
|
+
return [{
|
|
1672
|
+
type: Div,
|
|
1673
|
+
className: SearchHeaderDetails,
|
|
1674
|
+
childCount: 2
|
|
1675
|
+
}, ...getSearchMessageVirtualDom(message), ...getSearchDetailsToggleVirtualDom()];
|
|
1676
|
+
};
|
|
1677
|
+
|
|
1605
1678
|
const getSearchFieldButtonVirtualDom = button => {
|
|
1606
1679
|
const {
|
|
1607
1680
|
icon,
|
|
@@ -1669,28 +1742,47 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
1669
1742
|
return dom;
|
|
1670
1743
|
};
|
|
1671
1744
|
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
};
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1745
|
+
const getSearchHeaderDetailsExpandedVirtualDom = message => {
|
|
1746
|
+
const includeButtons = [{
|
|
1747
|
+
icon: MaskIconBook,
|
|
1748
|
+
title: searchOnlyOpenEditors(),
|
|
1749
|
+
command: 'searchOnlyOpenEditors',
|
|
1750
|
+
checked: false
|
|
1751
|
+
}];
|
|
1752
|
+
const excludeButtons = [{
|
|
1753
|
+
icon: MaskIconSettings,
|
|
1754
|
+
title: useExcludeSettings(),
|
|
1755
|
+
command: 'toggleUseExcludeSettings',
|
|
1756
|
+
checked: false
|
|
1757
|
+
}];
|
|
1758
|
+
return [{
|
|
1682
1759
|
type: Div,
|
|
1683
|
-
className:
|
|
1684
|
-
|
|
1685
|
-
childCount: hasDetailsExpanded(flags) ? 3 : 2,
|
|
1686
|
-
onClick: HandleHeaderClick,
|
|
1687
|
-
onFocusIn: HandleHeaderFocusIn
|
|
1760
|
+
className: SearchHeaderDetailsExpanded,
|
|
1761
|
+
childCount: 5
|
|
1688
1762
|
}, {
|
|
1689
1763
|
type: Div,
|
|
1690
|
-
className:
|
|
1691
|
-
role: None,
|
|
1764
|
+
className: SearchHeaderDetailsExpandedTop,
|
|
1692
1765
|
childCount: 2
|
|
1693
|
-
}, {
|
|
1766
|
+
}, ...getSearchDetailsToggleVirtualDom(), {
|
|
1767
|
+
type: H4,
|
|
1768
|
+
className: SearchHeaderDetailsHeading,
|
|
1769
|
+
childCount: 1
|
|
1770
|
+
}, text(filesToInclude()), ...getSearchFieldVirtualDom('files-to-include-value', 'Include', 'handleIncludeInput', includeButtons, []), {
|
|
1771
|
+
type: H4,
|
|
1772
|
+
className: SearchHeaderDetailsHeading,
|
|
1773
|
+
childCount: 1
|
|
1774
|
+
}, text(filesToExclude()), ...getSearchFieldVirtualDom('files-to-exclude-value', 'Exclude', 'handleExcludeInput', excludeButtons, []), ...getSearchMessageVirtualDom(message)];
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
const getSearchHeaderDetailsVirtualDom = (flags, message) => {
|
|
1778
|
+
if (flags & DetailsExpanded) {
|
|
1779
|
+
return getSearchHeaderDetailsExpandedVirtualDom(message);
|
|
1780
|
+
}
|
|
1781
|
+
return getSearchHeaderDetailsCollapsedVirtualDom(message);
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
const getSearchToggleVirtualDom = flags => {
|
|
1785
|
+
return [{
|
|
1694
1786
|
type: Button,
|
|
1695
1787
|
className: mergeClassNames(IconButton, SearchToggleButton, hasReplaceExpanded(flags) ? SearchToggleButtonExpanded : ''),
|
|
1696
1788
|
title: toggleReplace$1(),
|
|
@@ -1702,7 +1794,16 @@ const getSearchHeaderVirtualDom = flags => {
|
|
|
1702
1794
|
type: Div,
|
|
1703
1795
|
className: mergeClassNames(MaskIcon, hasReplaceExpanded(flags) ? MaskIconChevronDown : MaskIconChevronRight),
|
|
1704
1796
|
childCount: 0
|
|
1705
|
-
}
|
|
1797
|
+
}];
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
const getSearchHeaderTopVirtualDom = flags => {
|
|
1801
|
+
const dom = [{
|
|
1802
|
+
type: Div,
|
|
1803
|
+
className: SearchHeaderTop,
|
|
1804
|
+
role: None,
|
|
1805
|
+
childCount: 2
|
|
1806
|
+
}, ...getSearchToggleVirtualDom(flags), {
|
|
1706
1807
|
type: Div,
|
|
1707
1808
|
className: SearchHeaderTopRight,
|
|
1708
1809
|
role: None,
|
|
@@ -1731,21 +1832,18 @@ const getSearchHeaderVirtualDom = flags => {
|
|
|
1731
1832
|
title: replaceAll$1()
|
|
1732
1833
|
}]));
|
|
1733
1834
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
childCount: 0
|
|
1747
|
-
});
|
|
1748
|
-
}
|
|
1835
|
+
return dom;
|
|
1836
|
+
};
|
|
1837
|
+
|
|
1838
|
+
const getSearchHeaderVirtualDom = (flags, message) => {
|
|
1839
|
+
const dom = [{
|
|
1840
|
+
type: Div,
|
|
1841
|
+
className: SearchHeader,
|
|
1842
|
+
role: None,
|
|
1843
|
+
childCount: 2,
|
|
1844
|
+
onClick: HandleHeaderClick,
|
|
1845
|
+
onFocusIn: HandleHeaderFocusIn
|
|
1846
|
+
}, ...getSearchHeaderTopVirtualDom(flags), ...getSearchHeaderDetailsVirtualDom(flags, message)];
|
|
1749
1847
|
return dom;
|
|
1750
1848
|
};
|
|
1751
1849
|
|
|
@@ -1886,22 +1984,8 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
1886
1984
|
return dom;
|
|
1887
1985
|
};
|
|
1888
1986
|
|
|
1889
|
-
const getSearchResultsVirtualDom = visibleItems => {
|
|
1890
|
-
return
|
|
1891
|
-
};
|
|
1892
|
-
|
|
1893
|
-
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
|
|
1894
|
-
const dom = [{
|
|
1895
|
-
type: Div,
|
|
1896
|
-
className: mergeClassNames(Viewlet, Search$1),
|
|
1897
|
-
childCount: 2
|
|
1898
|
-
}, ...getSearchHeaderVirtualDom(flags), {
|
|
1899
|
-
type: Div,
|
|
1900
|
-
className: ViewletSearchMessage,
|
|
1901
|
-
role: Status,
|
|
1902
|
-
tabIndex: 0,
|
|
1903
|
-
childCount: 1
|
|
1904
|
-
}, text(message), {
|
|
1987
|
+
const getSearchResultsVirtualDom = (visibleItems, focusOutline) => {
|
|
1988
|
+
return [{
|
|
1905
1989
|
type: Div,
|
|
1906
1990
|
className: mergeClassNames(Viewlet, List, focusOutline ? FocusOutline : Empty),
|
|
1907
1991
|
role: Tree,
|
|
@@ -1909,7 +1993,15 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
|
|
|
1909
1993
|
childCount: visibleItems.length,
|
|
1910
1994
|
onClick: HandleClick,
|
|
1911
1995
|
onBlur: HandleListBlur
|
|
1912
|
-
}, ...
|
|
1996
|
+
}, ...visibleItems.flatMap(getSearchResultVirtualDom)];
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1999
|
+
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
|
|
2000
|
+
const dom = [{
|
|
2001
|
+
type: Div,
|
|
2002
|
+
className: mergeClassNames(Viewlet, Search$1),
|
|
2003
|
+
childCount: 2
|
|
2004
|
+
}, ...getSearchHeaderVirtualDom(flags, message), ...getSearchResultsVirtualDom(visibleItems, focusOutline)];
|
|
1913
2005
|
return dom;
|
|
1914
2006
|
};
|
|
1915
2007
|
|
|
@@ -2729,6 +2821,22 @@ const handleReplaceInput = (state, value, inputSource = Script) => {
|
|
|
2729
2821
|
});
|
|
2730
2822
|
};
|
|
2731
2823
|
|
|
2824
|
+
const getInputHandler = name => {
|
|
2825
|
+
switch (name) {
|
|
2826
|
+
case 'search-value':
|
|
2827
|
+
return handleInput;
|
|
2828
|
+
case 'replacement-value':
|
|
2829
|
+
return handleReplaceInput;
|
|
2830
|
+
default:
|
|
2831
|
+
throw new Error(`unknown input handler: ${name}`);
|
|
2832
|
+
}
|
|
2833
|
+
};
|
|
2834
|
+
|
|
2835
|
+
const handleSharedInput = (state, name, value, inputSource = Script) => {
|
|
2836
|
+
const fn = getInputHandler(name);
|
|
2837
|
+
return fn(state, value, inputSource);
|
|
2838
|
+
};
|
|
2839
|
+
|
|
2732
2840
|
const first = () => {
|
|
2733
2841
|
return 0;
|
|
2734
2842
|
};
|
|
@@ -2841,29 +2949,29 @@ const focusNextPage = state => {
|
|
|
2841
2949
|
return focusIndex(state, indexNextPage);
|
|
2842
2950
|
};
|
|
2843
2951
|
|
|
2844
|
-
const
|
|
2952
|
+
const focusPrevious = state => {
|
|
2845
2953
|
const {
|
|
2846
2954
|
focusedIndex,
|
|
2847
|
-
|
|
2848
|
-
maxLineY
|
|
2955
|
+
items
|
|
2849
2956
|
} = state;
|
|
2850
2957
|
if (focusedIndex === 0 || focusedIndex === -1) {
|
|
2851
2958
|
return state;
|
|
2852
2959
|
}
|
|
2853
|
-
const
|
|
2854
|
-
return focusIndex(state,
|
|
2960
|
+
const previousIndex = previous(items, focusedIndex);
|
|
2961
|
+
return focusIndex(state, previousIndex);
|
|
2855
2962
|
};
|
|
2856
2963
|
|
|
2857
|
-
const
|
|
2964
|
+
const focusPreviousPage = state => {
|
|
2858
2965
|
const {
|
|
2859
2966
|
focusedIndex,
|
|
2860
|
-
|
|
2967
|
+
minLineY,
|
|
2968
|
+
maxLineY
|
|
2861
2969
|
} = state;
|
|
2862
2970
|
if (focusedIndex === 0 || focusedIndex === -1) {
|
|
2863
2971
|
return state;
|
|
2864
2972
|
}
|
|
2865
|
-
const
|
|
2866
|
-
return focusIndex(state,
|
|
2973
|
+
const indexPreviousPage = Math.max(minLineY - (maxLineY - minLineY) + 1, 0);
|
|
2974
|
+
return focusIndex(state, indexPreviousPage);
|
|
2867
2975
|
};
|
|
2868
2976
|
|
|
2869
2977
|
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
|
|
@@ -2872,19 +2980,6 @@ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
|
|
|
2872
2980
|
return index;
|
|
2873
2981
|
};
|
|
2874
2982
|
|
|
2875
|
-
const openUri = async (path, focus = true, props = {}) => {
|
|
2876
|
-
await invoke$1(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
|
|
2877
|
-
};
|
|
2878
|
-
|
|
2879
|
-
const getFileIndex = (items, index) => {
|
|
2880
|
-
for (let i = index; i >= 0; i--) {
|
|
2881
|
-
const item = items[i];
|
|
2882
|
-
if (item.type === File$1) {
|
|
2883
|
-
return i;
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
return -1;
|
|
2887
|
-
};
|
|
2888
2983
|
const selectIndexFile = (state, searchResult, index) => {
|
|
2889
2984
|
const {
|
|
2890
2985
|
collapsedPaths
|
|
@@ -2898,6 +2993,20 @@ const selectIndexFile = (state, searchResult, index) => {
|
|
|
2898
2993
|
listFocused: true
|
|
2899
2994
|
};
|
|
2900
2995
|
};
|
|
2996
|
+
|
|
2997
|
+
const openUri = async (path, focus = true, props = {}) => {
|
|
2998
|
+
await invoke$1(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
|
|
2999
|
+
};
|
|
3000
|
+
|
|
3001
|
+
const getFileIndex = (items, index) => {
|
|
3002
|
+
for (let i = index; i >= 0; i--) {
|
|
3003
|
+
const item = items[i];
|
|
3004
|
+
if (item.type === File$1) {
|
|
3005
|
+
return i;
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
return -1;
|
|
3009
|
+
};
|
|
2901
3010
|
const selectIndexPreview = async (state, searchResult, index) => {
|
|
2902
3011
|
const {
|
|
2903
3012
|
items
|
|
@@ -2922,6 +3031,7 @@ const selectIndexPreview = async (state, searchResult, index) => {
|
|
|
2922
3031
|
listFocused: false
|
|
2923
3032
|
};
|
|
2924
3033
|
};
|
|
3034
|
+
|
|
2925
3035
|
const selectIndex = async (state, index) => {
|
|
2926
3036
|
if (index === -1) {
|
|
2927
3037
|
return {
|
|
@@ -2963,9 +3073,6 @@ const handleScrollBarCaptureLost = state => {
|
|
|
2963
3073
|
};
|
|
2964
3074
|
|
|
2965
3075
|
const clamp = (num, min, max) => {
|
|
2966
|
-
number(num);
|
|
2967
|
-
number(min);
|
|
2968
|
-
number(max);
|
|
2969
3076
|
return Math.min(Math.max(num, min), max);
|
|
2970
3077
|
};
|
|
2971
3078
|
|
|
@@ -3115,18 +3222,8 @@ const refresh = state => {
|
|
|
3115
3222
|
return handleUpdate(state, {});
|
|
3116
3223
|
};
|
|
3117
3224
|
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons;
|
|
3121
|
-
},
|
|
3122
|
-
apply(oldState, newState) {
|
|
3123
|
-
const displayResults = getDisplayResults(newState.items, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.collapsedPaths, newState.icons, newState.focusedIndex);
|
|
3124
|
-
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3125
|
-
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
|
|
3126
|
-
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3127
|
-
}
|
|
3128
|
-
};
|
|
3129
|
-
const getSelector = focusKey => {
|
|
3225
|
+
// TODO just return name
|
|
3226
|
+
const getFocusSelector = focusKey => {
|
|
3130
3227
|
switch (focusKey) {
|
|
3131
3228
|
case FocusSearchInput:
|
|
3132
3229
|
return '[name="search-value"]';
|
|
@@ -3138,16 +3235,30 @@ const getSelector = focusKey => {
|
|
|
3138
3235
|
return '[title="Preserve Case"]';
|
|
3139
3236
|
case FocusSearchRegex:
|
|
3140
3237
|
return '[title="Use Regular Expression"]';
|
|
3238
|
+
case FocusSearchIncludeInput:
|
|
3239
|
+
return '[name="files-to-include-value"]';
|
|
3141
3240
|
default:
|
|
3142
3241
|
return '';
|
|
3143
3242
|
}
|
|
3144
3243
|
};
|
|
3244
|
+
|
|
3245
|
+
const renderItems = {
|
|
3246
|
+
isEqual(oldState, newState) {
|
|
3247
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons;
|
|
3248
|
+
},
|
|
3249
|
+
apply(oldState, newState) {
|
|
3250
|
+
const displayResults = getDisplayResults(newState.items, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.collapsedPaths, newState.icons, newState.focusedIndex);
|
|
3251
|
+
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3252
|
+
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
|
|
3253
|
+
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3254
|
+
}
|
|
3255
|
+
};
|
|
3145
3256
|
const renderFocus = {
|
|
3146
3257
|
isEqual(oldState, newState) {
|
|
3147
3258
|
return oldState.focus === newState.focus || newState.focusSource === User;
|
|
3148
3259
|
},
|
|
3149
|
-
apply(newState) {
|
|
3150
|
-
const selector =
|
|
3260
|
+
apply(oldState, newState) {
|
|
3261
|
+
const selector = getFocusSelector(newState.focus);
|
|
3151
3262
|
return ['Viewlet.send', newState.uid, 'setFocus', selector, newState.focusSource];
|
|
3152
3263
|
}
|
|
3153
3264
|
};
|
|
@@ -3167,7 +3278,7 @@ const renderReplacement = {
|
|
|
3167
3278
|
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, '[name="search-replace-value"]'];
|
|
3168
3279
|
}
|
|
3169
3280
|
};
|
|
3170
|
-
const render = [renderItems,
|
|
3281
|
+
const render = [renderItems, renderValue, renderReplacement, renderFocus];
|
|
3171
3282
|
const doRender = uid => {
|
|
3172
3283
|
const {
|
|
3173
3284
|
oldState,
|
|
@@ -3268,19 +3379,13 @@ const replaceAllAndPrompt = async (workspacePath, items, replacement, matchCount
|
|
|
3268
3379
|
return true;
|
|
3269
3380
|
};
|
|
3270
3381
|
|
|
3271
|
-
const saveState =
|
|
3272
|
-
const {
|
|
3273
|
-
newState
|
|
3274
|
-
} = get(uid);
|
|
3275
|
-
const {
|
|
3276
|
-
value,
|
|
3277
|
-
replacement,
|
|
3278
|
-
flags
|
|
3279
|
-
} = newState;
|
|
3382
|
+
const saveState = state => {
|
|
3280
3383
|
return {
|
|
3281
|
-
value,
|
|
3282
|
-
replacement,
|
|
3283
|
-
flags
|
|
3384
|
+
value: state.value,
|
|
3385
|
+
replacement: state.replacement,
|
|
3386
|
+
flags: state.flags,
|
|
3387
|
+
includeValue: state.includeValue,
|
|
3388
|
+
excludeValue: state.excludeValue
|
|
3284
3389
|
};
|
|
3285
3390
|
};
|
|
3286
3391
|
|
|
@@ -3377,6 +3482,22 @@ const toggleSearchFlag = (state, flag) => {
|
|
|
3377
3482
|
};
|
|
3378
3483
|
};
|
|
3379
3484
|
|
|
3485
|
+
const toggleDetailsExpanded = state => {
|
|
3486
|
+
const newState = toggleSearchFlag(state, DetailsExpanded);
|
|
3487
|
+
if (hasDetailsExpanded(newState.flags)) {
|
|
3488
|
+
return {
|
|
3489
|
+
...newState,
|
|
3490
|
+
focus: FocusSearchIncludeInput,
|
|
3491
|
+
focusSource: Script
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
return {
|
|
3495
|
+
...newState,
|
|
3496
|
+
focus: FocusSearchInput,
|
|
3497
|
+
focusSource: Script
|
|
3498
|
+
};
|
|
3499
|
+
};
|
|
3500
|
+
|
|
3380
3501
|
const toggleMatchCase = state => {
|
|
3381
3502
|
return toggleSearchFlag(state, MatchCase);
|
|
3382
3503
|
};
|
|
@@ -3385,6 +3506,10 @@ const toggleMatchWholeWord = state => {
|
|
|
3385
3506
|
return toggleSearchFlag(state, MatchWholeWord);
|
|
3386
3507
|
};
|
|
3387
3508
|
|
|
3509
|
+
const toggleOpenEditors = state => {
|
|
3510
|
+
return toggleSearchFlag(state, OpenEditors);
|
|
3511
|
+
};
|
|
3512
|
+
|
|
3388
3513
|
const togglePreserveCase = state => {
|
|
3389
3514
|
return toggleSearchFlag(state, PreserveCase);
|
|
3390
3515
|
};
|
|
@@ -3393,6 +3518,10 @@ const toggleReplace = state => {
|
|
|
3393
3518
|
return toggleSearchFlag(state, ReplaceExpanded);
|
|
3394
3519
|
};
|
|
3395
3520
|
|
|
3521
|
+
const toggleUseIgnoreFiles = state => {
|
|
3522
|
+
return toggleSearchFlag(state, UseIgnoreFiles);
|
|
3523
|
+
};
|
|
3524
|
+
|
|
3396
3525
|
const toggleUseRegularExpression = state => {
|
|
3397
3526
|
return toggleSearchFlag(state, UseRegularExpression);
|
|
3398
3527
|
};
|
|
@@ -3477,6 +3606,7 @@ const commandMap = {
|
|
|
3477
3606
|
'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
|
|
3478
3607
|
'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
3479
3608
|
'TextSearch.handleScrollBarMove': wrapCommand(handleScrollBarMove),
|
|
3609
|
+
'TextSearch.handleSharedInput': wrapCommand(handleSharedInput),
|
|
3480
3610
|
'TextSearch.handleWheel': wrapCommand(handleWheel),
|
|
3481
3611
|
'TextSearch.loadContent': wrapCommand(loadContent),
|
|
3482
3612
|
'TextSearch.refresh': wrapCommand(refresh),
|
|
@@ -3485,8 +3615,11 @@ const commandMap = {
|
|
|
3485
3615
|
'TextSearch.submit': wrapCommand(submit),
|
|
3486
3616
|
'TextSearch.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
3487
3617
|
'TextSearch.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord),
|
|
3618
|
+
'TextSearch.toggleOpenEditors': wrapCommand(toggleOpenEditors),
|
|
3488
3619
|
'TextSearch.togglePreserveCase': wrapCommand(togglePreserveCase),
|
|
3489
3620
|
'TextSearch.toggleReplace': wrapCommand(toggleReplace),
|
|
3621
|
+
'TextSearch.toggleSearchDetails': wrapCommand(toggleDetailsExpanded),
|
|
3622
|
+
'TextSearch.toggleUseIgnoreFiles': wrapCommand(toggleUseIgnoreFiles),
|
|
3490
3623
|
'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
|
|
3491
3624
|
// not wrapped
|
|
3492
3625
|
'TextSearch.create': create,
|