@lvce-editor/text-search-worker 3.9.0 → 3.11.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 +272 -120
- package/package.json +1 -1
|
@@ -799,6 +799,21 @@ const WebWorkerRpcClient = {
|
|
|
799
799
|
create: create$1$1
|
|
800
800
|
};
|
|
801
801
|
|
|
802
|
+
const Empty$1 = 0;
|
|
803
|
+
const FocusSearchInput = 21;
|
|
804
|
+
const FocusSearchReplaceInput = 31;
|
|
805
|
+
const FocusSearchMatchCase = 32;
|
|
806
|
+
const FocusSearchRegex = 33;
|
|
807
|
+
const FocusSearchWholeWord = 34;
|
|
808
|
+
const FocusSearchReplaceAll = 35;
|
|
809
|
+
const FocusSearchPreserveCase = 36;
|
|
810
|
+
const FocusSearchIncludeInput = 1007;
|
|
811
|
+
const FocusSearchExcludeInput = 1008;
|
|
812
|
+
const FocusSearchResults = 22;
|
|
813
|
+
|
|
814
|
+
const User = 1;
|
|
815
|
+
const Script = 2;
|
|
816
|
+
|
|
802
817
|
const clearSearchResults$1 = state => {
|
|
803
818
|
return {
|
|
804
819
|
...state,
|
|
@@ -806,7 +821,9 @@ const clearSearchResults$1 = state => {
|
|
|
806
821
|
items: [],
|
|
807
822
|
minLineY: 0,
|
|
808
823
|
maxLineY: 0,
|
|
809
|
-
message: ''
|
|
824
|
+
message: '',
|
|
825
|
+
focus: FocusSearchInput,
|
|
826
|
+
focusSource: Script
|
|
810
827
|
};
|
|
811
828
|
};
|
|
812
829
|
|
|
@@ -835,9 +852,6 @@ const copy = async state => {
|
|
|
835
852
|
return state;
|
|
836
853
|
};
|
|
837
854
|
|
|
838
|
-
const User = 1;
|
|
839
|
-
const Script = 2;
|
|
840
|
-
|
|
841
855
|
const minimumSliderSize = 20;
|
|
842
856
|
|
|
843
857
|
const states = Object.create(null);
|
|
@@ -874,16 +888,6 @@ const create$1 = ({
|
|
|
874
888
|
};
|
|
875
889
|
};
|
|
876
890
|
|
|
877
|
-
const Empty$1 = 0;
|
|
878
|
-
const FocusSearchInput = 21;
|
|
879
|
-
const FocusSearchReplaceInput = 31;
|
|
880
|
-
const FocusSearchMatchCase = 32;
|
|
881
|
-
const FocusSearchRegex = 33;
|
|
882
|
-
const FocusSearchWholeWord = 34;
|
|
883
|
-
const FocusSearchReplaceAll = 35;
|
|
884
|
-
const FocusSearchPreserveCase = 36;
|
|
885
|
-
const FocusSearchIncludeInput = 1007;
|
|
886
|
-
|
|
887
891
|
const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '') => {
|
|
888
892
|
const state = {
|
|
889
893
|
uid,
|
|
@@ -963,59 +967,6 @@ const fromAsync = async asyncIterable => {
|
|
|
963
967
|
return children;
|
|
964
968
|
};
|
|
965
969
|
|
|
966
|
-
class AssertionError extends Error {
|
|
967
|
-
constructor(message) {
|
|
968
|
-
super(message);
|
|
969
|
-
this.name = 'AssertionError';
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
const getType = value => {
|
|
973
|
-
switch (typeof value) {
|
|
974
|
-
case 'number':
|
|
975
|
-
return 'number';
|
|
976
|
-
case 'function':
|
|
977
|
-
return 'function';
|
|
978
|
-
case 'string':
|
|
979
|
-
return 'string';
|
|
980
|
-
case 'object':
|
|
981
|
-
if (value === null) {
|
|
982
|
-
return 'null';
|
|
983
|
-
}
|
|
984
|
-
if (Array.isArray(value)) {
|
|
985
|
-
return 'array';
|
|
986
|
-
}
|
|
987
|
-
return 'object';
|
|
988
|
-
case 'boolean':
|
|
989
|
-
return 'boolean';
|
|
990
|
-
default:
|
|
991
|
-
return 'unknown';
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
|
-
const object = value => {
|
|
995
|
-
const type = getType(value);
|
|
996
|
-
if (type !== 'object') {
|
|
997
|
-
throw new AssertionError('expected value to be of type object');
|
|
998
|
-
}
|
|
999
|
-
};
|
|
1000
|
-
const number = value => {
|
|
1001
|
-
const type = getType(value);
|
|
1002
|
-
if (type !== 'number') {
|
|
1003
|
-
throw new AssertionError('expected value to be of type number');
|
|
1004
|
-
}
|
|
1005
|
-
};
|
|
1006
|
-
const array = value => {
|
|
1007
|
-
const type = getType(value);
|
|
1008
|
-
if (type !== 'array') {
|
|
1009
|
-
throw new AssertionError('expected value to be of type array');
|
|
1010
|
-
}
|
|
1011
|
-
};
|
|
1012
|
-
const string = value => {
|
|
1013
|
-
const type = getType(value);
|
|
1014
|
-
if (type !== 'string') {
|
|
1015
|
-
throw new AssertionError('expected value to be of type string');
|
|
1016
|
-
}
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
970
|
const emptyObject = {};
|
|
1020
971
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1021
972
|
const i18nString = (key, placeholders = emptyObject) => {
|
|
@@ -1122,9 +1073,6 @@ const confirmReplaceManyOccurrencesInOneFileNoValue = matchCount => {
|
|
|
1122
1073
|
});
|
|
1123
1074
|
};
|
|
1124
1075
|
const confirmReplaceManyOccurrencesInManyFiles = (matchCount, fileCount, replacement) => {
|
|
1125
|
-
number(matchCount);
|
|
1126
|
-
number(fileCount);
|
|
1127
|
-
string(replacement);
|
|
1128
1076
|
return i18nString(UiStrings.ConfirmReplaceManyOccurrencesInManyFiles, {
|
|
1129
1077
|
PH1: matchCount,
|
|
1130
1078
|
PH2: fileCount,
|
|
@@ -1132,8 +1080,6 @@ const confirmReplaceManyOccurrencesInManyFiles = (matchCount, fileCount, replace
|
|
|
1132
1080
|
});
|
|
1133
1081
|
};
|
|
1134
1082
|
const confirmReplaceManyOccurrencesInManyFilesNoValue = (matchCount, fileCount) => {
|
|
1135
|
-
number(matchCount);
|
|
1136
|
-
number(fileCount);
|
|
1137
1083
|
return i18nString(UiStrings.ConfirmReplaceManyOccurrencesInManyFilesNoValue, {
|
|
1138
1084
|
PH1: matchCount,
|
|
1139
1085
|
PH2: fileCount
|
|
@@ -1174,8 +1120,6 @@ const useExcludeSettings = () => {
|
|
|
1174
1120
|
};
|
|
1175
1121
|
|
|
1176
1122
|
const getStatusMessage = (resultCount, fileResultCount) => {
|
|
1177
|
-
number(resultCount);
|
|
1178
|
-
number(fileResultCount);
|
|
1179
1123
|
if (resultCount === 0) {
|
|
1180
1124
|
return noResults();
|
|
1181
1125
|
}
|
|
@@ -1328,7 +1272,8 @@ const focusMatchCase$1 = state => {
|
|
|
1328
1272
|
const focusReplaceValue$1 = state => {
|
|
1329
1273
|
return {
|
|
1330
1274
|
...state,
|
|
1331
|
-
focus: FocusSearchReplaceInput
|
|
1275
|
+
focus: FocusSearchReplaceInput,
|
|
1276
|
+
focusSource: Script
|
|
1332
1277
|
};
|
|
1333
1278
|
};
|
|
1334
1279
|
|
|
@@ -1402,10 +1347,10 @@ const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
|
|
|
1402
1347
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
1403
1348
|
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
1404
1349
|
const MaskIconEllipsis = 'MaskIconEllipsis';
|
|
1350
|
+
const MaskIconExclude = 'MaskIconExclude';
|
|
1405
1351
|
const MaskIconPreserveCase = 'MaskIconPreserveCase';
|
|
1406
1352
|
const MaskIconRegex = 'MaskIconRegex';
|
|
1407
1353
|
const MaskIconReplaceAll = 'MaskIconReplaceAll';
|
|
1408
|
-
const MaskIconSettings = 'MaskIconSettings';
|
|
1409
1354
|
const MaskIconWholeWord = 'MaskIconWholeWord';
|
|
1410
1355
|
const MultilineInputBox = 'MultilineInputBox';
|
|
1411
1356
|
const Search$1 = 'Search';
|
|
@@ -1489,6 +1434,83 @@ const getActionsVirtualDom = actions => {
|
|
|
1489
1434
|
}, ...actions.flatMap(getActionVirtualDom)];
|
|
1490
1435
|
};
|
|
1491
1436
|
|
|
1437
|
+
const Tab = 2;
|
|
1438
|
+
const Enter = 3;
|
|
1439
|
+
const End = 255;
|
|
1440
|
+
const Home = 12;
|
|
1441
|
+
const UpArrow = 14;
|
|
1442
|
+
const DownArrow = 16;
|
|
1443
|
+
const Delete = 18;
|
|
1444
|
+
const KeyC = 31;
|
|
1445
|
+
|
|
1446
|
+
const CtrlCmd = 1 << 11 >>> 0;
|
|
1447
|
+
const Shift = 1 << 10 >>> 0;
|
|
1448
|
+
const Alt = 1 << 9 >>> 0;
|
|
1449
|
+
|
|
1450
|
+
const getKeyBindings = () => {
|
|
1451
|
+
return [{
|
|
1452
|
+
key: CtrlCmd | Alt | Enter,
|
|
1453
|
+
command: 'Search.replaceAll',
|
|
1454
|
+
when: FocusSearchReplaceInput
|
|
1455
|
+
}, {
|
|
1456
|
+
key: DownArrow,
|
|
1457
|
+
command: 'Search.focusNext',
|
|
1458
|
+
when: FocusSearchResults
|
|
1459
|
+
}, {
|
|
1460
|
+
key: UpArrow,
|
|
1461
|
+
command: 'Search.focusPrevious',
|
|
1462
|
+
when: FocusSearchResults
|
|
1463
|
+
}, {
|
|
1464
|
+
key: Delete,
|
|
1465
|
+
command: 'Search.dismissItem',
|
|
1466
|
+
when: FocusSearchResults
|
|
1467
|
+
}, {
|
|
1468
|
+
key: Home,
|
|
1469
|
+
command: 'Search.focusFirst',
|
|
1470
|
+
when: FocusSearchResults
|
|
1471
|
+
}, {
|
|
1472
|
+
key: End,
|
|
1473
|
+
command: 'Search.focusLast',
|
|
1474
|
+
when: FocusSearchResults
|
|
1475
|
+
}, {
|
|
1476
|
+
key: CtrlCmd | KeyC,
|
|
1477
|
+
command: 'Search.copy',
|
|
1478
|
+
when: FocusSearchResults
|
|
1479
|
+
}, {
|
|
1480
|
+
key: Tab,
|
|
1481
|
+
command: 'Search.focusSearchValueNext',
|
|
1482
|
+
when: FocusSearchInput
|
|
1483
|
+
}, {
|
|
1484
|
+
key: Shift | Tab,
|
|
1485
|
+
command: 'Search.focusReplaceValuePrevious',
|
|
1486
|
+
when: FocusSearchReplaceInput
|
|
1487
|
+
}, {
|
|
1488
|
+
key: Tab,
|
|
1489
|
+
command: 'Search.focusReplaceValueNext',
|
|
1490
|
+
when: FocusSearchReplaceInput
|
|
1491
|
+
}, {
|
|
1492
|
+
key: Shift | Tab,
|
|
1493
|
+
command: 'Search.focusMatchCasePrevious',
|
|
1494
|
+
when: FocusSearchMatchCase
|
|
1495
|
+
}, {
|
|
1496
|
+
key: Tab,
|
|
1497
|
+
command: 'Search.focusRegexNext',
|
|
1498
|
+
when: FocusSearchRegex
|
|
1499
|
+
}, {
|
|
1500
|
+
key: Shift | Tab,
|
|
1501
|
+
command: 'Search.focusPreserveCasePrevious',
|
|
1502
|
+
when: FocusSearchPreserveCase
|
|
1503
|
+
}, {
|
|
1504
|
+
key: Enter,
|
|
1505
|
+
command: 'Search.submit',
|
|
1506
|
+
when: FocusSearchInput
|
|
1507
|
+
}, {
|
|
1508
|
+
key: Enter,
|
|
1509
|
+
command: 'Search.submit',
|
|
1510
|
+
when: FocusSearchReplaceInput
|
|
1511
|
+
}];
|
|
1512
|
+
};
|
|
1513
|
+
|
|
1492
1514
|
const ClearAll = 'ClearAll';
|
|
1493
1515
|
const CollapseAll = 'CollapseAll';
|
|
1494
1516
|
const ListFlat = 'ListFlat';
|
|
@@ -1750,7 +1772,7 @@ const getSearchHeaderDetailsExpandedVirtualDom = message => {
|
|
|
1750
1772
|
checked: false
|
|
1751
1773
|
}];
|
|
1752
1774
|
const excludeButtons = [{
|
|
1753
|
-
icon:
|
|
1775
|
+
icon: MaskIconExclude,
|
|
1754
1776
|
title: useExcludeSettings(),
|
|
1755
1777
|
command: 'toggleUseExcludeSettings',
|
|
1756
1778
|
checked: false
|
|
@@ -1865,9 +1887,6 @@ const chevronDownVirtualDom = {
|
|
|
1865
1887
|
className: mergeClassNames(Chevron, MaskIconChevronRight),
|
|
1866
1888
|
childCount: 0
|
|
1867
1889
|
});
|
|
1868
|
-
const getChevronDownVirtualDom = () => {
|
|
1869
|
-
return chevronDownVirtualDom;
|
|
1870
|
-
};
|
|
1871
1890
|
|
|
1872
1891
|
const getFileIconVirtualDom = icon => {
|
|
1873
1892
|
return {
|
|
@@ -1964,7 +1983,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
1964
1983
|
dom.push(treeItem);
|
|
1965
1984
|
if (type === File$1) {
|
|
1966
1985
|
treeItem.childCount += 2;
|
|
1967
|
-
dom.push(
|
|
1986
|
+
dom.push(chevronDownVirtualDom, getFileIconVirtualDom(icon));
|
|
1968
1987
|
}
|
|
1969
1988
|
dom.push(...getLabelVirtualDom(displayText, matchLength, matchStart, replacement));
|
|
1970
1989
|
if (matchCount) {
|
|
@@ -2005,6 +2024,10 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
|
|
|
2005
2024
|
return dom;
|
|
2006
2025
|
};
|
|
2007
2026
|
|
|
2027
|
+
const handleError = error => {
|
|
2028
|
+
console.error(`[text-search-worker] ${error}`);
|
|
2029
|
+
};
|
|
2030
|
+
|
|
2008
2031
|
const getFileIcons = async files => {
|
|
2009
2032
|
// TODO cache file icons
|
|
2010
2033
|
const promises = [];
|
|
@@ -2020,24 +2043,6 @@ const getFileIcons = async files => {
|
|
|
2020
2043
|
return icons;
|
|
2021
2044
|
};
|
|
2022
2045
|
|
|
2023
|
-
const handleIconThemeChange = async state => {
|
|
2024
|
-
const {
|
|
2025
|
-
items,
|
|
2026
|
-
minLineY,
|
|
2027
|
-
maxLineY
|
|
2028
|
-
} = state;
|
|
2029
|
-
const visibleItems = items.slice(minLineY, maxLineY);
|
|
2030
|
-
const icons = await getFileIcons(visibleItems);
|
|
2031
|
-
return {
|
|
2032
|
-
...state,
|
|
2033
|
-
icons
|
|
2034
|
-
};
|
|
2035
|
-
};
|
|
2036
|
-
|
|
2037
|
-
const handleError = error => {
|
|
2038
|
-
console.error(`[text-search-worker] ${error}`);
|
|
2039
|
-
};
|
|
2040
|
-
|
|
2041
2046
|
// TODO optimize this function to return the minimum number
|
|
2042
2047
|
// of visible items needed, e.g. when not scrolled 5 items with
|
|
2043
2048
|
// 20px fill 100px but when scrolled 6 items are needed
|
|
@@ -2104,6 +2109,59 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
2104
2109
|
};
|
|
2105
2110
|
};
|
|
2106
2111
|
|
|
2112
|
+
class AssertionError extends Error {
|
|
2113
|
+
constructor(message) {
|
|
2114
|
+
super(message);
|
|
2115
|
+
this.name = 'AssertionError';
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
const getType = value => {
|
|
2119
|
+
switch (typeof value) {
|
|
2120
|
+
case 'number':
|
|
2121
|
+
return 'number';
|
|
2122
|
+
case 'function':
|
|
2123
|
+
return 'function';
|
|
2124
|
+
case 'string':
|
|
2125
|
+
return 'string';
|
|
2126
|
+
case 'object':
|
|
2127
|
+
if (value === null) {
|
|
2128
|
+
return 'null';
|
|
2129
|
+
}
|
|
2130
|
+
if (Array.isArray(value)) {
|
|
2131
|
+
return 'array';
|
|
2132
|
+
}
|
|
2133
|
+
return 'object';
|
|
2134
|
+
case 'boolean':
|
|
2135
|
+
return 'boolean';
|
|
2136
|
+
default:
|
|
2137
|
+
return 'unknown';
|
|
2138
|
+
}
|
|
2139
|
+
};
|
|
2140
|
+
const object = value => {
|
|
2141
|
+
const type = getType(value);
|
|
2142
|
+
if (type !== 'object') {
|
|
2143
|
+
throw new AssertionError('expected value to be of type object');
|
|
2144
|
+
}
|
|
2145
|
+
};
|
|
2146
|
+
const number = value => {
|
|
2147
|
+
const type = getType(value);
|
|
2148
|
+
if (type !== 'number') {
|
|
2149
|
+
throw new AssertionError('expected value to be of type number');
|
|
2150
|
+
}
|
|
2151
|
+
};
|
|
2152
|
+
const array = value => {
|
|
2153
|
+
const type = getType(value);
|
|
2154
|
+
if (type !== 'array') {
|
|
2155
|
+
throw new AssertionError('expected value to be of type array');
|
|
2156
|
+
}
|
|
2157
|
+
};
|
|
2158
|
+
const string = value => {
|
|
2159
|
+
const type = getType(value);
|
|
2160
|
+
if (type !== 'string') {
|
|
2161
|
+
throw new AssertionError('expected value to be of type string');
|
|
2162
|
+
}
|
|
2163
|
+
};
|
|
2164
|
+
|
|
2107
2165
|
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2108
2166
|
const getProtocol = uri => {
|
|
2109
2167
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
@@ -2807,6 +2865,35 @@ const handleUpdate = async (state, update) => {
|
|
|
2807
2865
|
}
|
|
2808
2866
|
};
|
|
2809
2867
|
|
|
2868
|
+
const handleExcludeInput = (state, value, inputSource = Script) => {
|
|
2869
|
+
return handleUpdate(state, {
|
|
2870
|
+
excludeValue: value,
|
|
2871
|
+
inputSource
|
|
2872
|
+
});
|
|
2873
|
+
};
|
|
2874
|
+
|
|
2875
|
+
const handleIconThemeChange = async state => {
|
|
2876
|
+
const {
|
|
2877
|
+
items,
|
|
2878
|
+
minLineY,
|
|
2879
|
+
maxLineY
|
|
2880
|
+
} = state;
|
|
2881
|
+
const visibleItems = items.slice(minLineY, maxLineY);
|
|
2882
|
+
const icons = await getFileIcons(visibleItems);
|
|
2883
|
+
return {
|
|
2884
|
+
...state,
|
|
2885
|
+
icons
|
|
2886
|
+
};
|
|
2887
|
+
};
|
|
2888
|
+
|
|
2889
|
+
const handleIncludeInput = (state, includeValue) => {
|
|
2890
|
+
return {
|
|
2891
|
+
...state,
|
|
2892
|
+
includeValue,
|
|
2893
|
+
focusSource: User
|
|
2894
|
+
};
|
|
2895
|
+
};
|
|
2896
|
+
|
|
2810
2897
|
const handleInput = (state, value, inputSource = Script) => {
|
|
2811
2898
|
return handleUpdate(state, {
|
|
2812
2899
|
value,
|
|
@@ -2827,6 +2914,8 @@ const getInputHandler = name => {
|
|
|
2827
2914
|
return handleInput;
|
|
2828
2915
|
case 'replacement-value':
|
|
2829
2916
|
return handleReplaceInput;
|
|
2917
|
+
case 'files-to-exclude-value':
|
|
2918
|
+
return handleExcludeInput;
|
|
2830
2919
|
default:
|
|
2831
2920
|
throw new Error(`unknown input handler: ${name}`);
|
|
2832
2921
|
}
|
|
@@ -3182,13 +3271,27 @@ const getSavedFlags = savedState => {
|
|
|
3182
3271
|
}
|
|
3183
3272
|
return 0;
|
|
3184
3273
|
};
|
|
3274
|
+
const getSavedIncludeValue = savedState => {
|
|
3275
|
+
if (savedState && typeof savedState === 'object' && 'includeValue' in savedState && typeof savedState.includeValue === 'string') {
|
|
3276
|
+
return savedState.includeValue;
|
|
3277
|
+
}
|
|
3278
|
+
return '';
|
|
3279
|
+
};
|
|
3280
|
+
const getSavedExcludeValue = savedState => {
|
|
3281
|
+
if (savedState && typeof savedState === 'object' && 'excludeValue' in savedState && typeof savedState.excludeValue === 'string') {
|
|
3282
|
+
return savedState.excludeValue;
|
|
3283
|
+
}
|
|
3284
|
+
return '';
|
|
3285
|
+
};
|
|
3185
3286
|
const restoreState = savedState => {
|
|
3186
3287
|
return {
|
|
3187
3288
|
savedValue: getSavedValue(savedState),
|
|
3188
3289
|
replacement: getSavedReplacement(savedState),
|
|
3189
3290
|
savedCollapsedPaths: [],
|
|
3190
3291
|
threads: 1,
|
|
3191
|
-
flags: getSavedFlags(savedState)
|
|
3292
|
+
flags: getSavedFlags(savedState),
|
|
3293
|
+
includeValue: getSavedIncludeValue(savedState),
|
|
3294
|
+
excludeValue: getSavedExcludeValue(savedState)
|
|
3192
3295
|
};
|
|
3193
3296
|
};
|
|
3194
3297
|
|
|
@@ -3198,7 +3301,9 @@ const loadContent = async (state, savedState) => {
|
|
|
3198
3301
|
savedCollapsedPaths,
|
|
3199
3302
|
threads,
|
|
3200
3303
|
replacement,
|
|
3201
|
-
flags
|
|
3304
|
+
flags,
|
|
3305
|
+
includeValue,
|
|
3306
|
+
excludeValue
|
|
3202
3307
|
} = restoreState(savedState);
|
|
3203
3308
|
if (savedValue) {
|
|
3204
3309
|
return handleUpdate(state, {
|
|
@@ -3207,7 +3312,9 @@ const loadContent = async (state, savedState) => {
|
|
|
3207
3312
|
inputSource: Script,
|
|
3208
3313
|
collapsedPaths: savedCollapsedPaths,
|
|
3209
3314
|
replacement,
|
|
3210
|
-
flags
|
|
3315
|
+
flags,
|
|
3316
|
+
includeValue,
|
|
3317
|
+
excludeValue
|
|
3211
3318
|
});
|
|
3212
3319
|
}
|
|
3213
3320
|
return {
|
|
@@ -3237,6 +3344,8 @@ const getFocusSelector = focusKey => {
|
|
|
3237
3344
|
return '[title="Use Regular Expression"]';
|
|
3238
3345
|
case FocusSearchIncludeInput:
|
|
3239
3346
|
return '[name="files-to-include-value"]';
|
|
3347
|
+
case FocusSearchExcludeInput:
|
|
3348
|
+
return '[name="files-to-exclude-value"]';
|
|
3240
3349
|
default:
|
|
3241
3350
|
return '';
|
|
3242
3351
|
}
|
|
@@ -3275,10 +3384,29 @@ const renderReplacement = {
|
|
|
3275
3384
|
return oldState.replacement === newState.replacement || newState.inputSource === User;
|
|
3276
3385
|
},
|
|
3277
3386
|
apply(oldState, newState) {
|
|
3278
|
-
|
|
3387
|
+
const selector = getFocusSelector(FocusSearchReplaceInput);
|
|
3388
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, selector];
|
|
3389
|
+
}
|
|
3390
|
+
};
|
|
3391
|
+
const renderIncludeValue = {
|
|
3392
|
+
isEqual(oldState, newState) {
|
|
3393
|
+
return oldState.includeValue === newState.includeValue || newState.inputSource === User;
|
|
3394
|
+
},
|
|
3395
|
+
apply(oldState, newState) {
|
|
3396
|
+
const selector = getFocusSelector(FocusSearchIncludeInput);
|
|
3397
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, selector];
|
|
3279
3398
|
}
|
|
3280
3399
|
};
|
|
3281
|
-
const
|
|
3400
|
+
const renderExcludeValue = {
|
|
3401
|
+
isEqual(oldState, newState) {
|
|
3402
|
+
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
3403
|
+
},
|
|
3404
|
+
apply(oldState, newState) {
|
|
3405
|
+
const selector = getFocusSelector(FocusSearchExcludeInput);
|
|
3406
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, selector];
|
|
3407
|
+
}
|
|
3408
|
+
};
|
|
3409
|
+
const render = [renderItems, renderValue, renderIncludeValue, renderExcludeValue, renderReplacement, renderFocus];
|
|
3282
3410
|
const doRender = uid => {
|
|
3283
3411
|
const {
|
|
3284
3412
|
oldState,
|
|
@@ -3379,13 +3507,23 @@ const replaceAllAndPrompt = async (workspacePath, items, replacement, matchCount
|
|
|
3379
3507
|
return true;
|
|
3380
3508
|
};
|
|
3381
3509
|
|
|
3382
|
-
const saveState =
|
|
3510
|
+
const saveState = uid => {
|
|
3511
|
+
const {
|
|
3512
|
+
newState
|
|
3513
|
+
} = get(uid);
|
|
3514
|
+
const {
|
|
3515
|
+
value,
|
|
3516
|
+
replacement,
|
|
3517
|
+
flags,
|
|
3518
|
+
includeValue,
|
|
3519
|
+
excludeValue
|
|
3520
|
+
} = newState;
|
|
3383
3521
|
return {
|
|
3384
|
-
value
|
|
3385
|
-
replacement
|
|
3386
|
-
flags
|
|
3387
|
-
includeValue
|
|
3388
|
-
excludeValue
|
|
3522
|
+
value,
|
|
3523
|
+
replacement,
|
|
3524
|
+
flags,
|
|
3525
|
+
includeValue,
|
|
3526
|
+
excludeValue
|
|
3389
3527
|
};
|
|
3390
3528
|
};
|
|
3391
3529
|
|
|
@@ -3431,6 +3569,9 @@ const focusMatchCasePrevious = state => {
|
|
|
3431
3569
|
}
|
|
3432
3570
|
return focusSearchValue(state);
|
|
3433
3571
|
};
|
|
3572
|
+
const focusReplaceValuePrevious = state => {
|
|
3573
|
+
return focusSearchValue(state);
|
|
3574
|
+
};
|
|
3434
3575
|
const focusReplaceValueNext = state => {
|
|
3435
3576
|
return focusMatchCase(state);
|
|
3436
3577
|
};
|
|
@@ -3482,22 +3623,29 @@ const toggleSearchFlag = (state, flag) => {
|
|
|
3482
3623
|
};
|
|
3483
3624
|
};
|
|
3484
3625
|
|
|
3485
|
-
const
|
|
3486
|
-
const newState = toggleSearchFlag(state, DetailsExpanded);
|
|
3487
|
-
if (hasDetailsExpanded(newState.flags)) {
|
|
3488
|
-
return {
|
|
3489
|
-
...newState,
|
|
3490
|
-
focus: FocusSearchIncludeInput,
|
|
3491
|
-
focusSource: Script
|
|
3492
|
-
};
|
|
3493
|
-
}
|
|
3626
|
+
const collapseDetails = state => {
|
|
3494
3627
|
return {
|
|
3495
|
-
...
|
|
3628
|
+
...toggleSearchFlag(state, DetailsExpanded),
|
|
3496
3629
|
focus: FocusSearchInput,
|
|
3497
3630
|
focusSource: Script
|
|
3498
3631
|
};
|
|
3499
3632
|
};
|
|
3500
3633
|
|
|
3634
|
+
const expandDetails = state => {
|
|
3635
|
+
return {
|
|
3636
|
+
...toggleSearchFlag(state, DetailsExpanded),
|
|
3637
|
+
focus: FocusSearchIncludeInput,
|
|
3638
|
+
focusSource: Script
|
|
3639
|
+
};
|
|
3640
|
+
};
|
|
3641
|
+
|
|
3642
|
+
const toggleDetailsExpanded = state => {
|
|
3643
|
+
if (hasDetailsExpanded(state.flags)) {
|
|
3644
|
+
return collapseDetails(state);
|
|
3645
|
+
}
|
|
3646
|
+
return expandDetails(state);
|
|
3647
|
+
};
|
|
3648
|
+
|
|
3501
3649
|
const toggleMatchCase = state => {
|
|
3502
3650
|
return toggleSearchFlag(state, MatchCase);
|
|
3503
3651
|
};
|
|
@@ -3590,6 +3738,7 @@ const commandMap = {
|
|
|
3590
3738
|
'TextSearch.focusRegexNext': wrapCommand(focusRegexNext),
|
|
3591
3739
|
'TextSearch.focusReplaceAll': wrapCommand(focusReplaceAll),
|
|
3592
3740
|
'TextSearch.focusReplaceValue': wrapCommand(focusReplaceValue$1),
|
|
3741
|
+
'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
|
|
3593
3742
|
'TextSearch.focusReplaceValueNext': wrapCommand(focusReplaceValueNext),
|
|
3594
3743
|
'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
|
|
3595
3744
|
'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
|
|
@@ -3603,6 +3752,8 @@ const commandMap = {
|
|
|
3603
3752
|
'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
|
|
3604
3753
|
'TextSearch.handleInput': wrapCommand(handleInput),
|
|
3605
3754
|
'TextSearch.handleReplaceInput': wrapCommand(handleReplaceInput),
|
|
3755
|
+
'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
|
|
3756
|
+
'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
|
|
3606
3757
|
'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
|
|
3607
3758
|
'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
3608
3759
|
'TextSearch.handleScrollBarMove': wrapCommand(handleScrollBarMove),
|
|
@@ -3625,6 +3776,7 @@ const commandMap = {
|
|
|
3625
3776
|
'TextSearch.create': create,
|
|
3626
3777
|
'TextSearch.render': doRender,
|
|
3627
3778
|
'TextSearch.saveState': saveState,
|
|
3779
|
+
'TextSearch.getKeyBindings': getKeyBindings,
|
|
3628
3780
|
// TODO needed?
|
|
3629
3781
|
'TextSearch.textSearch': textSearch
|
|
3630
3782
|
};
|