@lvce-editor/editor-worker 19.30.13 → 19.32.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.
@@ -3260,7 +3260,7 @@ const getEnabled = () => {
3260
3260
  };
3261
3261
 
3262
3262
  // TODO this should be in a separate scrolling module
3263
- const setDeltaY$2 = async (state, value) => {
3263
+ const setDeltaY$1 = async (state, value) => {
3264
3264
  object(state);
3265
3265
  number(value);
3266
3266
  const {
@@ -4002,11 +4002,11 @@ const applyEdit$1 = (editor, changes) => {
4002
4002
  };
4003
4003
 
4004
4004
  // TODO
4005
- const setDeltaYFixedValue$1 = (editor, value) => {
4006
- return setDeltaY$2(editor, value);
4005
+ const setDeltaYFixedValue = (editor, value) => {
4006
+ return setDeltaY$1(editor, value);
4007
4007
  };
4008
- const setDeltaY$1 = (editor, value) => {
4009
- return setDeltaYFixedValue$1(editor, editor.deltaY + value);
4008
+ const setDeltaY = (editor, value) => {
4009
+ return setDeltaYFixedValue(editor, editor.deltaY + value);
4010
4010
  };
4011
4011
  const isAutoClosingChange = change => {
4012
4012
  return change.origin === EditorTypeWithAutoClosing;
@@ -4865,9 +4865,9 @@ const createEditor = async ({
4865
4865
  if (lineToReveal && columnToReveal) {
4866
4866
  const delta = lineToReveal * rowHeight;
4867
4867
  // TODO scroll to this line
4868
- newEditor3 = await setDeltaY$2(newEditor2, delta);
4868
+ newEditor3 = await setDeltaY$1(newEditor2, delta);
4869
4869
  } else {
4870
- newEditor3 = await setDeltaY$2(newEditor2, 0);
4870
+ newEditor3 = await setDeltaY$1(newEditor2, 0);
4871
4871
  }
4872
4872
 
4873
4873
  // Detect links and initialize decorations
@@ -6942,7 +6942,7 @@ const cursorPageDown = editor => {
6942
6942
  moveRangeToPosition$1(result, index, Math.min(endRow + pageSize, lastRowIndex), endColumn);
6943
6943
  });
6944
6944
  const newEditor = scheduleSelections(editor, newSelections);
6945
- return setDeltaYFixedValue$1(newEditor, deltaY + pageSize * itemHeight);
6945
+ return setDeltaYFixedValue(newEditor, deltaY + pageSize * itemHeight);
6946
6946
  };
6947
6947
 
6948
6948
  const cursorSet = (editor, rowIndex, columnIndex) => {
@@ -7455,10 +7455,12 @@ const DeleteLine = 'Delete Line';
7455
7455
  const EditorCloseColorPicker = 'Editor: Close Color Picker';
7456
7456
  const EditorCopyLineDown = 'Editor: Copy Line Down';
7457
7457
  const EditorCopyLineUp = 'Editor: Copy Line Up';
7458
+ const EditorDecrementSelection = 'Editor: Decrement Selection';
7458
7459
  const EditorFormatDocumentForced = 'Editor: Format Document (forced)';
7459
7460
  const EditorGoToDefinition = 'Editor: Go To Definition';
7460
7461
  const EditorGoToTypeDefinition = 'Editor: Go To Type Definition';
7461
7462
  const EditorIndent = 'Editor: Indent';
7463
+ const EditorIncrementSelection = 'Editor: Increment Selection';
7462
7464
  const EditorOpenColorPicker = 'Editor: Open Color Picker';
7463
7465
  const EditorSelectAllOccurrences = 'Editor: Select All Occurrences';
7464
7466
  const EditorSelectDown = 'Editor: Select Down';
@@ -7594,6 +7596,9 @@ const editorSelectInsideString = () => {
7594
7596
  const editorIndent = () => {
7595
7597
  return i18nString(EditorIndent);
7596
7598
  };
7599
+ const editorIncrementSelection = () => {
7600
+ return i18nString(EditorIncrementSelection);
7601
+ };
7597
7602
  const editorUnindent$1 = () => {
7598
7603
  return i18nString(EditorUnindent);
7599
7604
  };
@@ -7603,6 +7608,9 @@ const editorSortLinesAscending = () => {
7603
7608
  const editorToggleComment = () => {
7604
7609
  return i18nString(EditorToggleComment);
7605
7610
  };
7611
+ const editorDecrementSelection = () => {
7612
+ return i18nString(EditorDecrementSelection);
7613
+ };
7606
7614
  const editorSelectUp = () => {
7607
7615
  return i18nString(EditorSelectUp);
7608
7616
  };
@@ -8874,7 +8882,7 @@ const handleScrollBarMove = async (state, eventY) => {
8874
8882
  const relativeY = eventY - y - handleOffset;
8875
8883
  const newPercent = getNewPercent(state, relativeY);
8876
8884
  const newDeltaY = newPercent * finalDeltaY;
8877
- const newState = await setDeltaYFixedValue$1(state, newDeltaY);
8885
+ const newState = await setDeltaYFixedValue(state, newDeltaY);
8878
8886
  return newState;
8879
8887
  };
8880
8888
  const handleScrollBarVerticalPointerMove = handleScrollBarMove;
@@ -8907,7 +8915,7 @@ const handleScrollBarPointerDown = async (state, eventY) => {
8907
8915
  percent
8908
8916
  } = getNewDeltaPercent(height, scrollBarHeight, relativeY);
8909
8917
  const newDeltaY = percent * finalDeltaY;
8910
- const newState = await setDeltaYFixedValue$1(state, newDeltaY);
8918
+ const newState = await setDeltaYFixedValue(state, newDeltaY);
8911
8919
  return {
8912
8920
  ...newState,
8913
8921
  handleOffset
@@ -8955,13 +8963,9 @@ const handleTouchStart = (editor, touchEvent) => {
8955
8963
  };
8956
8964
 
8957
8965
  // @ts-ignore
8958
- const setDeltaY = (editor, deltaY) => {
8959
- return setDeltaY$1(editor, deltaY);
8960
- };
8961
-
8962
- // @ts-ignore
8963
- const setDeltaYFixedValue = (editor, deltaY) => {
8964
- return setDeltaYFixedValue$1(editor, deltaY);
8966
+ const scrollByLines = (editor, lineCount) => {
8967
+ number(lineCount);
8968
+ return setDeltaY(editor, lineCount * editor.itemHeight);
8965
8969
  };
8966
8970
 
8967
8971
  // @ts-ignore
@@ -11880,6 +11884,15 @@ const EditorSourceActionWidget = {
11880
11884
  toggleDetails
11881
11885
  };
11882
11886
 
11887
+ const executeViewletCommand$1 = async (commandMap, uid, commandId, ...args) => {
11888
+ const fn = commandMap[commandId];
11889
+ if (typeof fn !== 'function') {
11890
+ throw new TypeError(`Viewlet command not found: ${commandId}`);
11891
+ }
11892
+ await fn(uid, ...args);
11893
+ await invoke$a('Viewlet.requestRender', uid);
11894
+ };
11895
+
11883
11896
  const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...params) => {
11884
11897
  const invoke = getWidgetInvoke(widgetId);
11885
11898
  const actualMethod = method.slice(name.length + 1);
@@ -11985,6 +11998,13 @@ const getLines2 = editorUid => {
11985
11998
  } = editor;
11986
11999
  return lines;
11987
12000
  };
12001
+ const getVisibleLineRange = editorUid => {
12002
+ const {
12003
+ maxLineY,
12004
+ minLineY
12005
+ } = getEditor$1(editorUid);
12006
+ return [minLineY, maxLineY];
12007
+ };
11988
12008
  const getSelections2 = editorUid => {
11989
12009
  const editor = getEditor$1(editorUid);
11990
12010
  const {
@@ -12557,6 +12577,12 @@ const getQuickPickMenuEntries = () => {
12557
12577
  }, {
12558
12578
  id: 'Editor.deleteLine',
12559
12579
  label: deleteLine()
12580
+ }, {
12581
+ id: 'Editor.incrementSelection',
12582
+ label: editorIncrementSelection()
12583
+ }, {
12584
+ id: 'Editor.decrementSelection',
12585
+ label: editorDecrementSelection()
12560
12586
  }, {
12561
12587
  id: 'Editor.format',
12562
12588
  label: formatDocument()
@@ -12776,16 +12802,24 @@ const applyTabCompletion = (editor, result) => {
12776
12802
  return editorSnippet(editor, result);
12777
12803
  };
12778
12804
 
12805
+ const insertTab = editor => {
12806
+ // TODO have setting what should be inserted on tab
12807
+ return type(editor, ' ');
12808
+ };
12779
12809
  const handleTab = async editor => {
12780
12810
  if (!isEverySelectionEmpty(editor.selections)) {
12781
12811
  return indentMore(editor);
12782
12812
  }
12783
- const result = await getTabCompletion(editor);
12784
- if (!result) {
12785
- // TODO enter tab or two spaces
12786
- return editor;
12813
+ try {
12814
+ const result = await getTabCompletion(editor);
12815
+ if (!result) {
12816
+ return insertTab(editor);
12817
+ }
12818
+ return applyTabCompletion(editor, result);
12819
+ } catch (error) {
12820
+ await handleError$1(error, 'Failed to execute tab completion provider: ');
12821
+ return insertTab(editor);
12787
12822
  }
12788
- return applyTabCompletion(editor, result);
12789
12823
  };
12790
12824
 
12791
12825
  const relaunchWorkers = async () => {
@@ -14471,6 +14505,9 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
14471
14505
  }
14472
14506
  };
14473
14507
 
14508
+ const executeViewletCommand = (uid, commandId, ...args) => {
14509
+ return executeViewletCommand$1(commandMap, uid, commandId, ...args);
14510
+ };
14474
14511
  const commandMap = {
14475
14512
  'ActivateByEvent.activateByEvent': activateByEvent,
14476
14513
  'CodeGenerator.accept': codeGeneratorAccept,
@@ -14535,6 +14572,7 @@ const commandMap = {
14535
14572
  'Editor.deleteWordRight': wrapCommand(deleteWordRight),
14536
14573
  'Editor.diff2': diff2,
14537
14574
  'Editor.dispose': disposeEditor,
14575
+ 'Editor.executeViewletCommand': executeViewletCommand,
14538
14576
  'Editor.executeWidgetCommand': wrapCommand(executeWidgetCommand),
14539
14577
  'Editor.findAllReferences': wrapCommand(findAllReferences$1),
14540
14578
  'Editor.fold': wrapCommand(fold$1),
@@ -14557,6 +14595,7 @@ const commandMap = {
14557
14595
  'Editor.getSourceActions': getSourceActions,
14558
14596
  'Editor.getText': getText,
14559
14597
  'Editor.getUri': getUri,
14598
+ 'Editor.getVisibleLineRange': getVisibleLineRange,
14560
14599
  'Editor.getWordAt': getWordAt$1,
14561
14600
  'Editor.getWordAt2': getWordAt,
14562
14601
  'Editor.getWordAtOffset2': getWordAtOffset2,
@@ -14629,6 +14668,7 @@ const commandMap = {
14629
14668
  'Editor.resize': wrapCommand(resize),
14630
14669
  'Editor.save': wrapCommand(save),
14631
14670
  'Editor.saveState': wrapGetter(saveState),
14671
+ 'Editor.scrollByLines': wrapCommand(scrollByLines),
14632
14672
  'Editor.selectAll': wrapCommand(selectAll),
14633
14673
  'Editor.selectAllLeft': wrapCommand(editorSelectAllLeft),
14634
14674
  'Editor.selectAllOccurrences': wrapCommand(selectAllOccurrences),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.30.13",
3
+ "version": "19.32.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"