@lvce-editor/text-search-worker 3.23.0 → 3.24.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 +59 -60
- package/package.json +1 -1
|
@@ -598,10 +598,10 @@ const create$4 = (method, params) => {
|
|
|
598
598
|
};
|
|
599
599
|
};
|
|
600
600
|
const callbacks = Object.create(null);
|
|
601
|
-
const set$
|
|
601
|
+
const set$2 = (id, fn) => {
|
|
602
602
|
callbacks[id] = fn;
|
|
603
603
|
};
|
|
604
|
-
const get$
|
|
604
|
+
const get$2 = id => {
|
|
605
605
|
return callbacks[id];
|
|
606
606
|
};
|
|
607
607
|
const remove$1 = id => {
|
|
@@ -617,7 +617,7 @@ const registerPromise = () => {
|
|
|
617
617
|
resolve,
|
|
618
618
|
promise
|
|
619
619
|
} = Promise.withResolvers();
|
|
620
|
-
set$
|
|
620
|
+
set$2(id, resolve);
|
|
621
621
|
return {
|
|
622
622
|
id,
|
|
623
623
|
promise
|
|
@@ -774,7 +774,7 @@ const warn = (...args) => {
|
|
|
774
774
|
console.warn(...args);
|
|
775
775
|
};
|
|
776
776
|
const resolve = (id, response) => {
|
|
777
|
-
const fn = get$
|
|
777
|
+
const fn = get$2(id);
|
|
778
778
|
if (!fn) {
|
|
779
779
|
console.log(response);
|
|
780
780
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -1085,22 +1085,26 @@ const clearSearchResults$1 = state => {
|
|
|
1085
1085
|
};
|
|
1086
1086
|
};
|
|
1087
1087
|
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1088
|
+
const RendererWorker = 1;
|
|
1089
|
+
|
|
1090
|
+
const rpcs = Object.create(null);
|
|
1091
|
+
const set$1 = (id, rpc) => {
|
|
1092
|
+
rpcs[id] = rpc;
|
|
1090
1093
|
};
|
|
1094
|
+
const get$1 = id => {
|
|
1095
|
+
return rpcs[id];
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1091
1098
|
const invoke$2 = (method, ...params) => {
|
|
1092
|
-
const rpc =
|
|
1099
|
+
const rpc = get$1(RendererWorker);
|
|
1093
1100
|
// @ts-ignore
|
|
1094
1101
|
return rpc.invoke(method, ...params);
|
|
1095
1102
|
};
|
|
1096
1103
|
const invokeAndTransfer = (method, ...params) => {
|
|
1097
|
-
const rpc =
|
|
1104
|
+
const rpc = get$1(RendererWorker);
|
|
1098
1105
|
// @ts-ignore
|
|
1099
1106
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1100
1107
|
};
|
|
1101
|
-
const setRpc = rpc => {
|
|
1102
|
-
state$2.rpc = rpc;
|
|
1103
|
-
};
|
|
1104
1108
|
|
|
1105
1109
|
const copy = async state => {
|
|
1106
1110
|
const {
|
|
@@ -1200,21 +1204,6 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
1200
1204
|
|
|
1201
1205
|
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
1202
1206
|
|
|
1203
|
-
const insertInto = (array, start, newItems) => {
|
|
1204
|
-
const originalLength = array.length;
|
|
1205
|
-
const newItemsLength = newItems.length;
|
|
1206
|
-
array.length = originalLength + newItemsLength;
|
|
1207
|
-
// Move the items after the start index, start from the end so that we don't overwrite any value.
|
|
1208
|
-
for (let i = originalLength - 1; i >= start; i--) {
|
|
1209
|
-
array[i + newItemsLength] = array[i];
|
|
1210
|
-
}
|
|
1211
|
-
for (let i = 0; i < newItemsLength; i++) {
|
|
1212
|
-
array[i + start] = newItems[i];
|
|
1213
|
-
}
|
|
1214
|
-
};
|
|
1215
|
-
const push = (array, newItems) => {
|
|
1216
|
-
insertInto(array, array.length, newItems);
|
|
1217
|
-
};
|
|
1218
1207
|
const isLastIndex = (array, index) => {
|
|
1219
1208
|
return index === array.length - 1;
|
|
1220
1209
|
};
|
|
@@ -2805,36 +2794,50 @@ const noop = state => {
|
|
|
2805
2794
|
return state;
|
|
2806
2795
|
};
|
|
2807
2796
|
|
|
2808
|
-
const
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2797
|
+
const getFileName = text => {
|
|
2798
|
+
// TODO make api stricter so that results always have the same shape
|
|
2799
|
+
if (text.startsWith('./')) {
|
|
2800
|
+
return text.slice(2);
|
|
2801
|
+
}
|
|
2802
|
+
return text;
|
|
2803
|
+
};
|
|
2804
|
+
|
|
2805
|
+
const getReplaceElements = (items, workspacePath, replacement) => {
|
|
2806
|
+
let element = {
|
|
2807
|
+
uri: '',
|
|
2808
|
+
changes: []
|
|
2809
|
+
};
|
|
2810
|
+
const bulkChanges = [];
|
|
2811
|
+
let changes = [];
|
|
2812
|
+
// TODO simplify code by first matching files with their elements, then creating bulk edits
|
|
2813
|
+
for (const match of items) {
|
|
2815
2814
|
const {
|
|
2816
2815
|
type,
|
|
2817
|
-
text
|
|
2816
|
+
text,
|
|
2817
|
+
lineNumber,
|
|
2818
|
+
end,
|
|
2819
|
+
start
|
|
2818
2820
|
} = match;
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2821
|
+
if (type === File) {
|
|
2822
|
+
changes = [];
|
|
2823
|
+
const fileName = getFileName(text);
|
|
2824
|
+
const absolutePath = `${workspacePath}/${fileName}`;
|
|
2825
|
+
element = {
|
|
2826
|
+
uri: absolutePath,
|
|
2827
|
+
changes
|
|
2828
|
+
};
|
|
2829
|
+
bulkChanges.push(element);
|
|
2830
|
+
} else {
|
|
2831
|
+
changes.push({
|
|
2832
|
+
text: replacement,
|
|
2833
|
+
startRowIndex: lineNumber - 1,
|
|
2834
|
+
startColumnIndex: start,
|
|
2835
|
+
endRowIndex: lineNumber,
|
|
2836
|
+
endColumnIndex: end
|
|
2837
|
+
});
|
|
2830
2838
|
}
|
|
2831
2839
|
}
|
|
2832
|
-
|
|
2833
|
-
push(ranges, currentRanges);
|
|
2834
|
-
return {
|
|
2835
|
-
files,
|
|
2836
|
-
ranges: ranges.slice(1)
|
|
2837
|
-
};
|
|
2840
|
+
return bulkChanges;
|
|
2838
2841
|
};
|
|
2839
2842
|
|
|
2840
2843
|
const replaceAll = async state => {
|
|
@@ -2843,11 +2846,8 @@ const replaceAll = async state => {
|
|
|
2843
2846
|
items,
|
|
2844
2847
|
replacement
|
|
2845
2848
|
} = state;
|
|
2846
|
-
const
|
|
2847
|
-
|
|
2848
|
-
ranges
|
|
2849
|
-
} = getBulkReplacementEdits(workspacePath, items);
|
|
2850
|
-
await invoke$2('BulkReplacement.applyBulkReplacement', files, ranges, replacement);
|
|
2849
|
+
const bulkEdits = getReplaceElements(items, workspacePath, replacement);
|
|
2850
|
+
await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
|
|
2851
2851
|
return state;
|
|
2852
2852
|
};
|
|
2853
2853
|
|
|
@@ -3515,7 +3515,7 @@ const renderValue = {
|
|
|
3515
3515
|
return oldState.value === newState.value || newState.inputSource === User;
|
|
3516
3516
|
},
|
|
3517
3517
|
apply(oldState, newState) {
|
|
3518
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.value,
|
|
3518
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
|
|
3519
3519
|
}
|
|
3520
3520
|
};
|
|
3521
3521
|
const renderReplacement = {
|
|
@@ -3523,8 +3523,7 @@ const renderReplacement = {
|
|
|
3523
3523
|
return oldState.replacement === newState.replacement || newState.inputSource === User;
|
|
3524
3524
|
},
|
|
3525
3525
|
apply(oldState, newState) {
|
|
3526
|
-
|
|
3527
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, selector];
|
|
3526
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, `[name=${ReplaceValue}]`];
|
|
3528
3527
|
}
|
|
3529
3528
|
};
|
|
3530
3529
|
const renderIncludeValue = {
|
|
@@ -3841,7 +3840,7 @@ const listen = async () => {
|
|
|
3841
3840
|
const rpc = await WebWorkerRpcClient.create({
|
|
3842
3841
|
commandMap: commandMap
|
|
3843
3842
|
});
|
|
3844
|
-
|
|
3843
|
+
set$1(RendererWorker, rpc);
|
|
3845
3844
|
};
|
|
3846
3845
|
|
|
3847
3846
|
const main = async () => {
|