@lvce-editor/editor-worker 19.70.2 → 19.70.4

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.
@@ -8785,9 +8785,64 @@ const cursorDown = editor => {
8785
8785
  return scheduleSelections(editor, newSelections);
8786
8786
  };
8787
8787
 
8788
+ const getSelectionsAtLineEnd = (selections, lines) => {
8789
+ const newSelections = new Uint32Array(selections.length);
8790
+ for (let i = 0; i < selections.length; i += 4) {
8791
+ const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
8792
+ const rowIndex = selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn ? selectionStartRow : selectionEndRow;
8793
+ const columnIndex = selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn ? getLineLength(lines[rowIndex]) : selectionEndColumn;
8794
+ newSelections[i] = rowIndex;
8795
+ newSelections[i + 1] = columnIndex;
8796
+ newSelections[i + 2] = rowIndex;
8797
+ newSelections[i + 3] = columnIndex;
8798
+ }
8799
+ return newSelections;
8800
+ };
8801
+ const removeDuplicateSelections = (editor, selections) => {
8802
+ const uniqueSelections = new Uint32Array(selections.length);
8803
+ const selectionIndices = new Map();
8804
+ const primarySelectionIndex = editor.primarySelectionIndex || 0;
8805
+ let uniqueSelectionCount = 0;
8806
+ let newPrimarySelectionIndex = 0;
8807
+ for (let i = 0; i < selections.length; i += 4) {
8808
+ const rowIndex = selections[i + 2];
8809
+ const columnIndex = selections[i + 3];
8810
+ const key = `${rowIndex}:${columnIndex}`;
8811
+ const existingSelectionIndex = selectionIndices.get(key);
8812
+ if (existingSelectionIndex !== undefined) {
8813
+ if (i === primarySelectionIndex) {
8814
+ newPrimarySelectionIndex = existingSelectionIndex * 4;
8815
+ }
8816
+ continue;
8817
+ }
8818
+ selectionIndices.set(key, uniqueSelectionCount);
8819
+ uniqueSelections.set(selections.subarray(i, i + 4), uniqueSelectionCount * 4);
8820
+ if (i === primarySelectionIndex) {
8821
+ newPrimarySelectionIndex = uniqueSelectionCount * 4;
8822
+ }
8823
+ uniqueSelectionCount++;
8824
+ }
8825
+ return {
8826
+ primarySelectionIndex: newPrimarySelectionIndex,
8827
+ selections: uniqueSelections.slice(0, uniqueSelectionCount * 4)
8828
+ };
8829
+ };
8830
+
8788
8831
  // @ts-ignore
8789
8832
  const cursorEnd = editor => {
8790
- return editorCursorHorizontalRight(editor, lineEnd);
8833
+ const {
8834
+ lines,
8835
+ selections: oldSelections
8836
+ } = editor;
8837
+ const movedSelections = getSelectionsAtLineEnd(oldSelections, lines);
8838
+ const {
8839
+ primarySelectionIndex,
8840
+ selections
8841
+ } = removeDuplicateSelections(editor, movedSelections);
8842
+ return scheduleSelections({
8843
+ ...editor,
8844
+ primarySelectionIndex
8845
+ }, selections);
8791
8846
  };
8792
8847
 
8793
8848
  // @ts-ignore
@@ -16100,7 +16155,7 @@ const getSavedLanguageId = (savedState, languages) => {
16100
16155
  }
16101
16156
  return explicitLanguageId;
16102
16157
  };
16103
- const loadContent = async (state, savedState, largeFile = false) => {
16158
+ const loadContent = async (state, savedState, largeFile = false, focus = true) => {
16104
16159
  const {
16105
16160
  assetDir,
16106
16161
  height,
@@ -16199,7 +16254,7 @@ const loadContent = async (state, savedState, largeFile = false) => {
16199
16254
  ...newEditor1,
16200
16255
  differences: [],
16201
16256
  focus: FocusEditorText$1,
16202
- focused: true,
16257
+ focused: focus,
16203
16258
  initial: false,
16204
16259
  loadError: getErrorMessage(error),
16205
16260
  textInfos: []
@@ -16261,7 +16316,7 @@ const loadContent = async (state, savedState, largeFile = false) => {
16261
16316
  ...newEditor3WithBreadcrumbs,
16262
16317
  differences,
16263
16318
  focus: FocusEditorText$1,
16264
- focused: true,
16319
+ focused: focus,
16265
16320
  textInfos
16266
16321
  };
16267
16322
  const completionsOnTypeRaw = await get$3('editor.completionsOnType');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.70.2",
3
+ "version": "19.70.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"