@lvce-editor/text-search-view 1.5.0 → 1.7.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/textSearchViewMain.js +110 -32
- package/package.json +1 -1
|
@@ -1135,7 +1135,7 @@ const createMockRpc = ({
|
|
|
1135
1135
|
};
|
|
1136
1136
|
|
|
1137
1137
|
const rpcs = Object.create(null);
|
|
1138
|
-
const set$
|
|
1138
|
+
const set$5 = (id, rpc) => {
|
|
1139
1139
|
rpcs[id] = rpc;
|
|
1140
1140
|
};
|
|
1141
1141
|
const get$1 = id => {
|
|
@@ -1168,7 +1168,7 @@ const create$3 = rpcId => {
|
|
|
1168
1168
|
const mockRpc = createMockRpc({
|
|
1169
1169
|
commandMap
|
|
1170
1170
|
});
|
|
1171
|
-
set$
|
|
1171
|
+
set$5(rpcId, mockRpc);
|
|
1172
1172
|
// @ts-ignore
|
|
1173
1173
|
mockRpc[Symbol.dispose] = () => {
|
|
1174
1174
|
remove$2(rpcId);
|
|
@@ -1177,7 +1177,7 @@ const create$3 = rpcId => {
|
|
|
1177
1177
|
return mockRpc;
|
|
1178
1178
|
},
|
|
1179
1179
|
set(rpc) {
|
|
1180
|
-
set$
|
|
1180
|
+
set$5(rpcId, rpc);
|
|
1181
1181
|
}
|
|
1182
1182
|
};
|
|
1183
1183
|
};
|
|
@@ -1443,6 +1443,7 @@ const None$1 = 0;
|
|
|
1443
1443
|
|
|
1444
1444
|
const LeftClick = 0;
|
|
1445
1445
|
|
|
1446
|
+
const DialogWorker = 7014;
|
|
1446
1447
|
const IconThemeWorker = 7009;
|
|
1447
1448
|
const RendererWorker = 1;
|
|
1448
1449
|
const TextSearchWorker = 7010;
|
|
@@ -1473,6 +1474,11 @@ const FocusSearchWholeWord = 34;
|
|
|
1473
1474
|
const FocusToggleDetails = 1010;
|
|
1474
1475
|
const FocusToggleReplace = 1020;
|
|
1475
1476
|
|
|
1477
|
+
const {
|
|
1478
|
+
invoke: invoke$3,
|
|
1479
|
+
set: set$4
|
|
1480
|
+
} = create$3(DialogWorker);
|
|
1481
|
+
|
|
1476
1482
|
const {
|
|
1477
1483
|
invoke: invoke$2,
|
|
1478
1484
|
set: set$3
|
|
@@ -1498,6 +1504,10 @@ const sendMessagePortToTextSearchWorker = async (port, rpcId) => {
|
|
|
1498
1504
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1499
1505
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextSearchWorker', port, command, rpcId);
|
|
1500
1506
|
};
|
|
1507
|
+
const sendMessagePortToDialogWorker = async port => {
|
|
1508
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1509
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1510
|
+
};
|
|
1501
1511
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1502
1512
|
const command = 'IconTheme.handleMessagePort';
|
|
1503
1513
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
@@ -2076,9 +2086,13 @@ const getFilePath = text => {
|
|
|
2076
2086
|
return text;
|
|
2077
2087
|
};
|
|
2078
2088
|
|
|
2089
|
+
const File = 1;
|
|
2090
|
+
const Match = 2;
|
|
2091
|
+
const Context = 3;
|
|
2092
|
+
|
|
2079
2093
|
const getIconsCached = (dirents, fileIconCache) => {
|
|
2080
2094
|
return dirents.map(dirent => {
|
|
2081
|
-
if (dirent.type
|
|
2095
|
+
if (dirent.type !== File) {
|
|
2082
2096
|
return '';
|
|
2083
2097
|
}
|
|
2084
2098
|
const path = getFilePath(dirent.text);
|
|
@@ -2094,9 +2108,6 @@ const getFileName = path => {
|
|
|
2094
2108
|
return path.slice(slashIndex + 1);
|
|
2095
2109
|
};
|
|
2096
2110
|
|
|
2097
|
-
const File = 1;
|
|
2098
|
-
const Match = 2;
|
|
2099
|
-
|
|
2100
2111
|
const isFile = match => {
|
|
2101
2112
|
return match.type === File;
|
|
2102
2113
|
};
|
|
@@ -2190,7 +2201,7 @@ const getFilteredResults = (results, collapsedPaths) => {
|
|
|
2190
2201
|
filteredResults.push(result);
|
|
2191
2202
|
isExcluded = collapsedPaths.includes(result.text) ? true : false;
|
|
2192
2203
|
}
|
|
2193
|
-
if (result.type === Match && !isExcluded) {
|
|
2204
|
+
if ((result.type === Match || result.type === Context) && !isExcluded) {
|
|
2194
2205
|
filteredResults.push(result);
|
|
2195
2206
|
}
|
|
2196
2207
|
}
|
|
@@ -2291,6 +2302,9 @@ const hasReplaceExpanded = flags => {
|
|
|
2291
2302
|
const hasDetailsExpanded = flags => {
|
|
2292
2303
|
return (flags & DetailsExpanded) === DetailsExpanded;
|
|
2293
2304
|
};
|
|
2305
|
+
const hasOpenEditors = flags => {
|
|
2306
|
+
return (flags & OpenEditors) === OpenEditors;
|
|
2307
|
+
};
|
|
2294
2308
|
const hasUseIgnoreFiles = flags => {
|
|
2295
2309
|
return (flags & UseIgnoreFiles) === UseIgnoreFiles;
|
|
2296
2310
|
};
|
|
@@ -2418,7 +2432,6 @@ const copyPath$1 = async state => {
|
|
|
2418
2432
|
};
|
|
2419
2433
|
|
|
2420
2434
|
const defaultExcludes = ['.git', 'node_modules'];
|
|
2421
|
-
defaultExcludes.join(',');
|
|
2422
2435
|
|
|
2423
2436
|
const minimumSliderSize = 20;
|
|
2424
2437
|
|
|
@@ -2547,16 +2560,6 @@ const isEqual$7 = (oldState, newState) => {
|
|
|
2547
2560
|
return oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.headerHeight === newState.headerHeight && oldState.itemHeight === newState.itemHeight && oldState.items === newState.items;
|
|
2548
2561
|
};
|
|
2549
2562
|
|
|
2550
|
-
const RenderFocus = 2;
|
|
2551
|
-
const RenderValue = 3;
|
|
2552
|
-
const RenderReplaceValue = 4;
|
|
2553
|
-
const RenderIncludeValue = 5;
|
|
2554
|
-
const RenderExcludeValue = 6;
|
|
2555
|
-
const RenderFocusContext = 7;
|
|
2556
|
-
const RenderSelections = 8;
|
|
2557
|
-
const RenderIncremental = 9;
|
|
2558
|
-
const RenderCss = 10;
|
|
2559
|
-
|
|
2560
2563
|
const isEqual$6 = (oldState, newState) => {
|
|
2561
2564
|
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
2562
2565
|
};
|
|
@@ -2581,6 +2584,16 @@ const isEqual$1 = (oldState, newState) => {
|
|
|
2581
2584
|
return oldState.replacement === newState.replacement || newState.inputSource === User;
|
|
2582
2585
|
};
|
|
2583
2586
|
|
|
2587
|
+
const RenderFocus = 2;
|
|
2588
|
+
const RenderValue = 3;
|
|
2589
|
+
const RenderReplaceValue = 4;
|
|
2590
|
+
const RenderIncludeValue = 5;
|
|
2591
|
+
const RenderExcludeValue = 6;
|
|
2592
|
+
const RenderFocusContext = 7;
|
|
2593
|
+
const RenderSelections = 8;
|
|
2594
|
+
const RenderIncremental = 9;
|
|
2595
|
+
const RenderCss = 10;
|
|
2596
|
+
|
|
2584
2597
|
const isEqual = (oldState, newState) => {
|
|
2585
2598
|
return oldState.value === newState.value || newState.inputSource === User;
|
|
2586
2599
|
};
|
|
@@ -2649,12 +2662,25 @@ const getSetSize = (items, index) => {
|
|
|
2649
2662
|
}
|
|
2650
2663
|
return setSize;
|
|
2651
2664
|
};
|
|
2665
|
+
const getMatchCount$1 = (items, index) => {
|
|
2666
|
+
let matchCount = 0;
|
|
2667
|
+
for (let i = index + 1; i < items.length; i++) {
|
|
2668
|
+
if (items[i].type === File) {
|
|
2669
|
+
break;
|
|
2670
|
+
}
|
|
2671
|
+
if (items[i].type === Match) {
|
|
2672
|
+
matchCount++;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
return matchCount;
|
|
2676
|
+
};
|
|
2652
2677
|
const getRemoveIndicesFile = (items, item, index, matchCount, fileCount) => {
|
|
2653
2678
|
const setSize = getSetSize(items, index);
|
|
2679
|
+
const removedMatchCount = getMatchCount$1(items, index);
|
|
2654
2680
|
return {
|
|
2655
2681
|
newFileCount: fileCount - 1,
|
|
2656
2682
|
newFocusedIndex: index + setSize + 1 < items.length ? index : index - 1,
|
|
2657
|
-
newMatchCount: matchCount -
|
|
2683
|
+
newMatchCount: matchCount - removedMatchCount,
|
|
2658
2684
|
removeCount: setSize + 1,
|
|
2659
2685
|
startIndex: index
|
|
2660
2686
|
};
|
|
@@ -2683,9 +2709,20 @@ const getRemoveIndicesMatch = (items, index, matchCount, fileCount) => {
|
|
|
2683
2709
|
}
|
|
2684
2710
|
throw new Error('could not compute indices to remove');
|
|
2685
2711
|
};
|
|
2712
|
+
const getRemoveIndicesContext = (index, matchCount, fileCount) => {
|
|
2713
|
+
return {
|
|
2714
|
+
newFileCount: fileCount,
|
|
2715
|
+
newFocusedIndex: index,
|
|
2716
|
+
newMatchCount: matchCount,
|
|
2717
|
+
removeCount: 1,
|
|
2718
|
+
startIndex: index
|
|
2719
|
+
};
|
|
2720
|
+
};
|
|
2686
2721
|
const getRemoveIndices = (items, index, matchCount, fileCount) => {
|
|
2687
2722
|
const item = items[index];
|
|
2688
2723
|
switch (item.type) {
|
|
2724
|
+
case Context:
|
|
2725
|
+
return getRemoveIndicesContext(index, matchCount, fileCount);
|
|
2689
2726
|
case File:
|
|
2690
2727
|
return getRemoveIndicesFile(items, item, index, matchCount, fileCount);
|
|
2691
2728
|
case Match:
|
|
@@ -3593,7 +3630,14 @@ const getTextSearchResultCounts = results => {
|
|
|
3593
3630
|
};
|
|
3594
3631
|
|
|
3595
3632
|
const textSearch = async (root, query, options, assetDir, platform, searchId, uid) => {
|
|
3596
|
-
|
|
3633
|
+
if (!hasOpenEditors(options.flags)) {
|
|
3634
|
+
return search$1(root, query, options, assetDir, platform, searchId, uid);
|
|
3635
|
+
}
|
|
3636
|
+
const openEditorUris = await invoke$1('GetActiveEditor.getOpenEditorUris');
|
|
3637
|
+
return search$1(root, query, {
|
|
3638
|
+
...options,
|
|
3639
|
+
openEditorUris
|
|
3640
|
+
}, assetDir, platform, searchId, uid);
|
|
3597
3641
|
};
|
|
3598
3642
|
|
|
3599
3643
|
const handleUpdateFull = async (state, update) => {
|
|
@@ -3606,6 +3650,8 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3606
3650
|
};
|
|
3607
3651
|
const {
|
|
3608
3652
|
assetDir,
|
|
3653
|
+
contextLines,
|
|
3654
|
+
contextLinesEnabled,
|
|
3609
3655
|
excludeValue,
|
|
3610
3656
|
fileIconCache,
|
|
3611
3657
|
flags,
|
|
@@ -3631,6 +3677,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3631
3677
|
results
|
|
3632
3678
|
} = await textSearch(root, value, {
|
|
3633
3679
|
assetDir,
|
|
3680
|
+
contextLines: contextLinesEnabled ? contextLines : 0,
|
|
3634
3681
|
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3635
3682
|
exclude: excludeValue,
|
|
3636
3683
|
flags,
|
|
@@ -3749,6 +3796,8 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3749
3796
|
};
|
|
3750
3797
|
const {
|
|
3751
3798
|
assetDir,
|
|
3799
|
+
contextLines,
|
|
3800
|
+
contextLinesEnabled,
|
|
3752
3801
|
excludeValue,
|
|
3753
3802
|
flags,
|
|
3754
3803
|
includeValue,
|
|
@@ -3773,6 +3822,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3773
3822
|
// TODO await promise?
|
|
3774
3823
|
void textSearchIncremental(root, value, {
|
|
3775
3824
|
assetDir: assetDir,
|
|
3825
|
+
contextLines: contextLinesEnabled ? contextLines : 0,
|
|
3776
3826
|
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3777
3827
|
exclude: excludeValue,
|
|
3778
3828
|
flags,
|
|
@@ -3812,6 +3862,8 @@ const handleUpdatePullBased = async (state, update) => {
|
|
|
3812
3862
|
set(previousUid, state, partialNewState);
|
|
3813
3863
|
const {
|
|
3814
3864
|
assetDir,
|
|
3865
|
+
contextLines,
|
|
3866
|
+
contextLinesEnabled,
|
|
3815
3867
|
excludeValue,
|
|
3816
3868
|
flags,
|
|
3817
3869
|
includeValue,
|
|
@@ -3831,6 +3883,7 @@ const handleUpdatePullBased = async (state, update) => {
|
|
|
3831
3883
|
limitHit
|
|
3832
3884
|
} = await textSearch(root, value, {
|
|
3833
3885
|
assetDir,
|
|
3886
|
+
contextLines: contextLinesEnabled ? contextLines : 0,
|
|
3834
3887
|
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3835
3888
|
exclude: excludeValue,
|
|
3836
3889
|
flags,
|
|
@@ -4001,8 +4054,10 @@ const getReplaceElements = (items, workspacePath, replacement) => {
|
|
|
4001
4054
|
for (const match of items) {
|
|
4002
4055
|
const {
|
|
4003
4056
|
end,
|
|
4057
|
+
endColumnIndex,
|
|
4004
4058
|
lineNumber,
|
|
4005
4059
|
start,
|
|
4060
|
+
startColumnIndex,
|
|
4006
4061
|
text,
|
|
4007
4062
|
type
|
|
4008
4063
|
} = match;
|
|
@@ -4014,11 +4069,11 @@ const getReplaceElements = (items, workspacePath, replacement) => {
|
|
|
4014
4069
|
changes,
|
|
4015
4070
|
uri: absolutePath
|
|
4016
4071
|
});
|
|
4017
|
-
} else {
|
|
4072
|
+
} else if (type === Match) {
|
|
4018
4073
|
changes.push({
|
|
4019
|
-
endColumnIndex: end,
|
|
4074
|
+
endColumnIndex: endColumnIndex ?? end,
|
|
4020
4075
|
endRowIndex: lineNumber,
|
|
4021
|
-
startColumnIndex: start,
|
|
4076
|
+
startColumnIndex: startColumnIndex ?? start,
|
|
4022
4077
|
startRowIndex: lineNumber - 1,
|
|
4023
4078
|
text: replacement
|
|
4024
4079
|
});
|
|
@@ -4037,8 +4092,16 @@ const getReplacingMessage = (fileCount, replaceCount) => {
|
|
|
4037
4092
|
return replacingManyOccurrencesInManyFiles(replaceCount, fileCount);
|
|
4038
4093
|
};
|
|
4039
4094
|
|
|
4040
|
-
const
|
|
4041
|
-
|
|
4095
|
+
const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
|
|
4096
|
+
const prompt = async (text, options) => {
|
|
4097
|
+
try {
|
|
4098
|
+
return await invoke$3('ConfirmPrompt.prompt', text, options);
|
|
4099
|
+
} catch (error) {
|
|
4100
|
+
if (!String(error).includes(missingDialogWorkerRelay)) {
|
|
4101
|
+
throw error;
|
|
4102
|
+
}
|
|
4103
|
+
return invoke$1('ConfirmPrompt.prompt', text, options);
|
|
4104
|
+
}
|
|
4042
4105
|
};
|
|
4043
4106
|
|
|
4044
4107
|
const getReplaceAllConfirmText = (matchCount, fileCount, replacement) => {
|
|
@@ -4724,13 +4787,15 @@ const handleListBlur = state => {
|
|
|
4724
4787
|
|
|
4725
4788
|
const handleListFocus = async state => {
|
|
4726
4789
|
const {
|
|
4790
|
+
focus,
|
|
4727
4791
|
listFocused
|
|
4728
4792
|
} = state;
|
|
4729
|
-
if (listFocused) {
|
|
4793
|
+
if (focus === FocusSearchResults && listFocused) {
|
|
4730
4794
|
return state;
|
|
4731
4795
|
}
|
|
4732
4796
|
return {
|
|
4733
4797
|
...state,
|
|
4798
|
+
focus: FocusSearchResults,
|
|
4734
4799
|
listFocused: true
|
|
4735
4800
|
};
|
|
4736
4801
|
};
|
|
@@ -5283,6 +5348,8 @@ const selectIndexPreview = async (state, searchResult, index) => {
|
|
|
5283
5348
|
|
|
5284
5349
|
const getSelectHandler = type => {
|
|
5285
5350
|
switch (type) {
|
|
5351
|
+
case Context:
|
|
5352
|
+
return selectIndexPreview;
|
|
5286
5353
|
case File:
|
|
5287
5354
|
return selectIndexFile;
|
|
5288
5355
|
case Match:
|
|
@@ -5565,13 +5632,17 @@ const Collapsed = 1;
|
|
|
5565
5632
|
const Expanded = 2;
|
|
5566
5633
|
|
|
5567
5634
|
const getMatchCount = (results, startIndex) => {
|
|
5635
|
+
let matchCount = 0;
|
|
5568
5636
|
for (let i = startIndex + 1; i < results.length; i++) {
|
|
5569
5637
|
const result = results[i];
|
|
5570
5638
|
if (result.type === File) {
|
|
5571
|
-
|
|
5639
|
+
break;
|
|
5640
|
+
}
|
|
5641
|
+
if (result.type === Match) {
|
|
5642
|
+
matchCount++;
|
|
5572
5643
|
}
|
|
5573
5644
|
}
|
|
5574
|
-
return
|
|
5645
|
+
return matchCount;
|
|
5575
5646
|
};
|
|
5576
5647
|
|
|
5577
5648
|
const defaultIndent = 12;
|
|
@@ -5640,6 +5711,8 @@ const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, repl
|
|
|
5640
5711
|
const focused = i === focusedIndex;
|
|
5641
5712
|
const relativeIndex = i - minLineY;
|
|
5642
5713
|
switch (type) {
|
|
5714
|
+
case Context:
|
|
5715
|
+
return getDisplayResultMatch(setSize, 0, '', text, posInSet, 0, focused);
|
|
5643
5716
|
case File:
|
|
5644
5717
|
return getSearchDisplayResultFile(results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, renderFolderPaths, originalResults);
|
|
5645
5718
|
case Match:
|
|
@@ -5890,8 +5963,8 @@ const getSearchHeaderDetailsCollapsedVirtualDom = message => {
|
|
|
5890
5963
|
|
|
5891
5964
|
const CheckBoxEnabled = 1;
|
|
5892
5965
|
const CheckBoxDisabled = 2;
|
|
5893
|
-
const ButtonEnabled =
|
|
5894
|
-
const ButtonDisabled =
|
|
5966
|
+
const ButtonEnabled = 3;
|
|
5967
|
+
const ButtonDisabled = 4;
|
|
5895
5968
|
|
|
5896
5969
|
const getInputActionsExclude = flags => {
|
|
5897
5970
|
const inside = [{
|
|
@@ -6469,12 +6542,12 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
|
|
|
6469
6542
|
childCount,
|
|
6470
6543
|
className: mergeClassNames(Viewlet, List$1, Tree, focusOutline ? FocusOutline : Empty$1),
|
|
6471
6544
|
onBlur: HandleListBlur,
|
|
6545
|
+
onFocus: HandleListFocus,
|
|
6472
6546
|
role: Tree$1,
|
|
6473
6547
|
tabIndex: Focusable,
|
|
6474
6548
|
type: Div
|
|
6475
6549
|
// TODO renable this when dom diffing is supported
|
|
6476
6550
|
// onPointerDown: HandleListPointerDown,
|
|
6477
|
-
// onFocus: HandleListFocus,
|
|
6478
6551
|
}, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
|
|
6479
6552
|
};
|
|
6480
6553
|
|
|
@@ -7054,6 +7127,11 @@ const listen = async () => {
|
|
|
7054
7127
|
commandMap: commandMap
|
|
7055
7128
|
});
|
|
7056
7129
|
set$2(rpc);
|
|
7130
|
+
const dialogRpc = await create$5({
|
|
7131
|
+
commandMap: {},
|
|
7132
|
+
send: sendMessagePortToDialogWorker
|
|
7133
|
+
});
|
|
7134
|
+
set$4(dialogRpc);
|
|
7057
7135
|
};
|
|
7058
7136
|
|
|
7059
7137
|
const main = async () => {
|