@lvce-editor/editor-worker 19.63.0 → 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.
@@ -3738,7 +3738,7 @@ const characterWidth = 0.75;
3738
3738
  const lineHeight = 2;
3739
3739
  const minimumViewportHeight = 20;
3740
3740
 
3741
- const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3741
+ const resize$2 = (state, dimensions, columnWidth = state.columnWidth) => {
3742
3742
  const x = dimensions.x ?? state.x;
3743
3743
  const y = dimensions.y ?? state.y;
3744
3744
  const outerWidth = dimensions.width ?? state.outerWidth ?? state.width;
@@ -4442,7 +4442,7 @@ const hasSelection = editor => {
4442
4442
  return editor.selections && editor.selections.length > 0;
4443
4443
  };
4444
4444
  const setBounds = (editor, x, y, width, height, columnWidth) => {
4445
- return resize(editor, {
4445
+ return resize$2(editor, {
4446
4446
  height,
4447
4447
  width,
4448
4448
  x,
@@ -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 = new Map();
4936
- for (let i = 0; i < selections.length; i += 4) {
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,15 +10990,17 @@ 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,
10997
+ resize: resize$1,
10967
10998
  toggleMatchCase,
10968
10999
  toggleMatchWholeWord,
10969
11000
  togglePreserveCase,
10970
11001
  toggleReplace,
10971
11002
  toggleUseRegularExpression
10972
- } = createFns(['close', 'focusCloseButton', 'focusFind', 'focusNext', 'focusNextMatchButton', 'focusPrevious', 'focusPreviousMatchButton', 'focusReplace', 'focusReplaceAllButton', 'focusReplaceButton', 'focusToggleReplace', 'handleBlur', 'handleClickButton', 'handleFocus', 'handleInput', 'handleReplaceFocus', 'handleReplaceInput', 'handleToggleReplaceFocus', 'replace', 'replaceAll', '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);
10973
11004
 
10974
11005
  const EditorFindWidget = {
10975
11006
  __proto__: null,
@@ -10994,11 +11025,13 @@ const EditorFindWidget = {
10994
11025
  handleInput: handleInput$1,
10995
11026
  handleReplaceFocus,
10996
11027
  handleReplaceInput,
11028
+ handleSettingsChanged: handleSettingsChanged$1,
10997
11029
  handleToggleReplaceFocus,
10998
11030
  remove: remove$7,
10999
11031
  render: render$c,
11000
11032
  replace,
11001
11033
  replaceAll,
11034
+ resize: resize$1,
11002
11035
  toggleMatchCase,
11003
11036
  toggleMatchWholeWord,
11004
11037
  togglePreserveCase,
@@ -14556,6 +14589,22 @@ const getWorkspaceUri$1 = async applicationId => {
14556
14589
  return '';
14557
14590
  }
14558
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
+ };
14559
14608
  const handleSettingsChanged = async state => {
14560
14609
  const editorPreferences = {
14561
14610
  ...(await getEditorPreferences()),
@@ -14595,14 +14644,15 @@ const handleSettingsChanged = async state => {
14595
14644
  } else if (!state.breadcrumbsEnabled) {
14596
14645
  [documentSymbols, workspaceUri] = await Promise.all([getDocumentSymbols(editorWithUpdatedSettings), getWorkspaceUri$1(state.applicationId)]);
14597
14646
  }
14598
- const resizedEditor = resize({
14647
+ const resizedEditor = resize$2({
14599
14648
  ...editorWithUpdatedSettings,
14600
14649
  documentSymbols,
14601
14650
  workspaceUri
14602
14651
  }, {}, charWidth);
14652
+ const editorWithUpdatedFindWidget = await updateFindWidget(resizedEditor);
14603
14653
  return {
14604
- ...resizedEditor,
14605
- gutterDecorations: await getEditorGutterDecorations(resizedEditor)
14654
+ ...editorWithUpdatedFindWidget,
14655
+ gutterDecorations: await getEditorGutterDecorations(editorWithUpdatedFindWidget)
14606
14656
  };
14607
14657
  };
14608
14658
 
@@ -16833,6 +16883,10 @@ const wrapFocusCommand = fn => {
16833
16883
  const executeViewletCommand = (uid, commandId, ...args) => {
16834
16884
  return executeViewletCommand$1(commandMap, uid, commandId, ...args);
16835
16885
  };
16886
+ const resize = async (editor, dimensions) => {
16887
+ const resizedEditor = resize$2(editor, dimensions, editor.columnWidth);
16888
+ return resize$1(resizedEditor, dimensions);
16889
+ };
16836
16890
  const commandMap = {
16837
16891
  'ActivateByEvent.activateByEvent': activateByEvent,
16838
16892
  'CodeGenerator.accept': codeGeneratorAccept,
@@ -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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.63.0",
3
+ "version": "19.64.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"