@lvce-editor/editor-worker 19.63.1 → 19.64.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/editorWorkerMain.js +68 -20
- package/dist/settings.json +10 -0
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -4885,6 +4885,46 @@ const findBracketPair = (lines, rowIndex, columnIndex) => {
|
|
|
4885
4885
|
};
|
|
4886
4886
|
|
|
4887
4887
|
const getPositionKey = position => `${position.rowIndex}:${position.columnIndex}`;
|
|
4888
|
+
const bracketMatchCache = new WeakMap();
|
|
4889
|
+
const selectionsEqual$1 = (left, right) => {
|
|
4890
|
+
if (left.length !== right.length) {
|
|
4891
|
+
return false;
|
|
4892
|
+
}
|
|
4893
|
+
for (let i = 0; i < left.length; i++) {
|
|
4894
|
+
if (left[i] !== right[i]) {
|
|
4895
|
+
return false;
|
|
4896
|
+
}
|
|
4897
|
+
}
|
|
4898
|
+
return true;
|
|
4899
|
+
};
|
|
4900
|
+
const findBracketMatchPositions = (lines, selections) => {
|
|
4901
|
+
const cached = bracketMatchCache.get(lines);
|
|
4902
|
+
if (cached && selectionsEqual$1(cached.selections, selections)) {
|
|
4903
|
+
return cached.positions;
|
|
4904
|
+
}
|
|
4905
|
+
const positions = new Map();
|
|
4906
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
4907
|
+
const startRowIndex = selections[i];
|
|
4908
|
+
const startColumnIndex = selections[i + 1];
|
|
4909
|
+
const endRowIndex = selections[i + 2];
|
|
4910
|
+
const endColumnIndex = selections[i + 3];
|
|
4911
|
+
if (startRowIndex !== endRowIndex || startColumnIndex !== endColumnIndex) {
|
|
4912
|
+
continue;
|
|
4913
|
+
}
|
|
4914
|
+
const pair = findMatchingBracket(lines, endRowIndex, endColumnIndex);
|
|
4915
|
+
if (!pair) {
|
|
4916
|
+
continue;
|
|
4917
|
+
}
|
|
4918
|
+
positions.set(getPositionKey(pair.source), pair.source);
|
|
4919
|
+
positions.set(getPositionKey(pair.match), pair.match);
|
|
4920
|
+
}
|
|
4921
|
+
const entry = {
|
|
4922
|
+
positions: positions.values().toArray(),
|
|
4923
|
+
selections: new Uint32Array(selections)
|
|
4924
|
+
};
|
|
4925
|
+
bracketMatchCache.set(lines, entry);
|
|
4926
|
+
return entry.positions;
|
|
4927
|
+
};
|
|
4888
4928
|
const getInfo = async (editor, position, visibleLineIndices, startVisualRow) => {
|
|
4889
4929
|
if (!visibleLineIndices.includes(position.rowIndex)) {
|
|
4890
4930
|
return undefined;
|
|
@@ -4932,23 +4972,8 @@ const getVisibleBracketMatches = async editor => {
|
|
|
4932
4972
|
length: maxLineY - minLineY
|
|
4933
4973
|
}, (_, index) => minLineY + index);
|
|
4934
4974
|
const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : viewLineIndices ? getVisualRowForDocumentRow$1(minLineY, viewLineIndices) : getVisualRowForDocumentRow(minLineY, foldingRanges);
|
|
4935
|
-
const positions =
|
|
4936
|
-
|
|
4937
|
-
const startRowIndex = selections[i];
|
|
4938
|
-
const startColumnIndex = selections[i + 1];
|
|
4939
|
-
const endRowIndex = selections[i + 2];
|
|
4940
|
-
const endColumnIndex = selections[i + 3];
|
|
4941
|
-
if (startRowIndex !== endRowIndex || startColumnIndex !== endColumnIndex) {
|
|
4942
|
-
continue;
|
|
4943
|
-
}
|
|
4944
|
-
const pair = findMatchingBracket(lines, endRowIndex, endColumnIndex);
|
|
4945
|
-
if (!pair) {
|
|
4946
|
-
continue;
|
|
4947
|
-
}
|
|
4948
|
-
positions.set(getPositionKey(pair.source), pair.source);
|
|
4949
|
-
positions.set(getPositionKey(pair.match), pair.match);
|
|
4950
|
-
}
|
|
4951
|
-
const infos = await Promise.all(Array.from(positions.values(), position => getInfo(editor, position, actualVisibleLineIndices, startVisualRow)));
|
|
4975
|
+
const positions = findBracketMatchPositions(lines, selections);
|
|
4976
|
+
const infos = await Promise.all(positions.map(position => getInfo(editor, position, actualVisibleLineIndices, startVisualRow)));
|
|
4952
4977
|
return infos.filter(info => info !== undefined);
|
|
4953
4978
|
};
|
|
4954
4979
|
|
|
@@ -10690,6 +10715,9 @@ const getLines = editorUid => {
|
|
|
10690
10715
|
const getSelections$1 = editorUid => {
|
|
10691
10716
|
return getEditor$1(editorUid).selections;
|
|
10692
10717
|
};
|
|
10718
|
+
const getFindWidgetFontSize = async () => {
|
|
10719
|
+
return get$3('editor.findWidgetFontSize');
|
|
10720
|
+
};
|
|
10693
10721
|
const setSelections$1 = async (editorUid, selections) => {
|
|
10694
10722
|
const editor = getEditor$1(editorUid);
|
|
10695
10723
|
const newEditor = setSelections$2(editor, selections);
|
|
@@ -10699,6 +10727,7 @@ const setSelections$1 = async (editorUid, selections) => {
|
|
|
10699
10727
|
const getFindWidgetWorkerCommandMap = () => ({
|
|
10700
10728
|
'Editor.applyDocumentEdits': applyDocumentEdits,
|
|
10701
10729
|
'Editor.closeFind2': closeFind,
|
|
10730
|
+
'Editor.getFindWidgetFontSize': getFindWidgetFontSize,
|
|
10702
10731
|
'Editor.getLines2': getLines,
|
|
10703
10732
|
'Editor.getSelections2': getSelections$1,
|
|
10704
10733
|
'Editor.setSelections2': setSelections$1
|
|
@@ -10961,6 +10990,7 @@ const {
|
|
|
10961
10990
|
handleInput: handleInput$1,
|
|
10962
10991
|
handleReplaceFocus,
|
|
10963
10992
|
handleReplaceInput,
|
|
10993
|
+
handleSettingsChanged: handleSettingsChanged$1,
|
|
10964
10994
|
handleToggleReplaceFocus,
|
|
10965
10995
|
replace,
|
|
10966
10996
|
replaceAll,
|
|
@@ -10970,7 +11000,7 @@ const {
|
|
|
10970
11000
|
togglePreserveCase,
|
|
10971
11001
|
toggleReplace,
|
|
10972
11002
|
toggleUseRegularExpression
|
|
10973
|
-
} = createFns(['close', 'focusCloseButton', 'focusFind', 'focusNext', 'focusNextMatchButton', 'focusPrevious', 'focusPreviousMatchButton', 'focusReplace', 'focusReplaceAllButton', 'focusReplaceButton', 'focusToggleReplace', 'handleBlur', 'handleClickButton', 'handleFocus', 'handleInput', 'handleReplaceFocus', 'handleReplaceInput', 'handleToggleReplaceFocus', 'replace', 'replaceAll', 'resize', 'toggleMatchCase', 'toggleMatchWholeWord', 'toggleReplace', 'toggleUseRegularExpression', 'focusNextElement', 'focusPreviousElement', 'togglePreserveCase'], 'FindWidget', Find);
|
|
11003
|
+
} = createFns(['close', 'focusCloseButton', 'focusFind', 'focusNext', 'focusNextMatchButton', 'focusPrevious', 'focusPreviousMatchButton', 'focusReplace', 'focusReplaceAllButton', 'focusReplaceButton', 'focusToggleReplace', 'handleBlur', 'handleClickButton', 'handleFocus', 'handleInput', 'handleReplaceFocus', 'handleReplaceInput', 'handleSettingsChanged', 'handleToggleReplaceFocus', 'replace', 'replaceAll', 'resize', 'toggleMatchCase', 'toggleMatchWholeWord', 'toggleReplace', 'toggleUseRegularExpression', 'focusNextElement', 'focusPreviousElement', 'togglePreserveCase'], 'FindWidget', Find);
|
|
10974
11004
|
|
|
10975
11005
|
const EditorFindWidget = {
|
|
10976
11006
|
__proto__: null,
|
|
@@ -10995,6 +11025,7 @@ const EditorFindWidget = {
|
|
|
10995
11025
|
handleInput: handleInput$1,
|
|
10996
11026
|
handleReplaceFocus,
|
|
10997
11027
|
handleReplaceInput,
|
|
11028
|
+
handleSettingsChanged: handleSettingsChanged$1,
|
|
10998
11029
|
handleToggleReplaceFocus,
|
|
10999
11030
|
remove: remove$7,
|
|
11000
11031
|
render: render$c,
|
|
@@ -14558,6 +14589,22 @@ const getWorkspaceUri$1 = async applicationId => {
|
|
|
14558
14589
|
return '';
|
|
14559
14590
|
}
|
|
14560
14591
|
};
|
|
14592
|
+
const updateFindWidget = async state => {
|
|
14593
|
+
const widget = (state.widgets || []).find(widget => widget.id === Find);
|
|
14594
|
+
if (!widget) {
|
|
14595
|
+
return state;
|
|
14596
|
+
}
|
|
14597
|
+
const {
|
|
14598
|
+
uid
|
|
14599
|
+
} = widget.newState;
|
|
14600
|
+
await invoke$4('FindWidget.handleSettingsChanged', uid);
|
|
14601
|
+
const diff = await invoke$4('FindWidget.diff2', uid);
|
|
14602
|
+
const commands = await invoke$4('FindWidget.render2', uid, diff);
|
|
14603
|
+
return updateWidget(state, Find, {
|
|
14604
|
+
...widget.newState,
|
|
14605
|
+
commands
|
|
14606
|
+
});
|
|
14607
|
+
};
|
|
14561
14608
|
const handleSettingsChanged = async state => {
|
|
14562
14609
|
const editorPreferences = {
|
|
14563
14610
|
...(await getEditorPreferences()),
|
|
@@ -14602,9 +14649,10 @@ const handleSettingsChanged = async state => {
|
|
|
14602
14649
|
documentSymbols,
|
|
14603
14650
|
workspaceUri
|
|
14604
14651
|
}, {}, charWidth);
|
|
14652
|
+
const editorWithUpdatedFindWidget = await updateFindWidget(resizedEditor);
|
|
14605
14653
|
return {
|
|
14606
|
-
...
|
|
14607
|
-
gutterDecorations: await getEditorGutterDecorations(
|
|
14654
|
+
...editorWithUpdatedFindWidget,
|
|
14655
|
+
gutterDecorations: await getEditorGutterDecorations(editorWithUpdatedFindWidget)
|
|
14608
14656
|
};
|
|
14609
14657
|
};
|
|
14610
14658
|
|
package/dist/settings.json
CHANGED
|
@@ -25,6 +25,16 @@
|
|
|
25
25
|
"type": "string",
|
|
26
26
|
"value": "Fira Code"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"category": "text-editor",
|
|
30
|
+
"description": "The font size of the find widget",
|
|
31
|
+
"heading": "Find Widget Font Size",
|
|
32
|
+
"id": "editor.findWidgetFontSize",
|
|
33
|
+
"type": "number",
|
|
34
|
+
"value": 0,
|
|
35
|
+
"minimum": 0,
|
|
36
|
+
"maximum": 100
|
|
37
|
+
},
|
|
28
38
|
{
|
|
29
39
|
"category": "text-editor",
|
|
30
40
|
"description": "Format a file when it is saved",
|