@lvce-editor/editor-worker 19.70.1 → 19.70.3

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
@@ -16930,8 +16985,8 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
16930
16985
  return dom;
16931
16986
  };
16932
16987
 
16933
- const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1) => {
16934
- const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow);
16988
+ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, unnecessaryDiagnostics = []) => {
16989
+ const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics);
16935
16990
  return [{
16936
16991
  childCount: visibleViewLineIndices.length || textInfos.length,
16937
16992
  className: 'EditorRows',
@@ -17028,8 +17083,8 @@ const editorLayersNode = {
17028
17083
  className: 'EditorLayers',
17029
17084
  type: Div
17030
17085
  };
17031
- const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1, roundedSelection = false) => {
17032
- return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused, roundedSelection), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow), ...getEditorCursorsVirtualDom(cursorInfos, focused), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
17086
+ const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1, roundedSelection = false, unnecessaryDiagnostics = []) => {
17087
+ return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused, roundedSelection), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics), ...getEditorCursorsVirtualDom(cursorInfos, focused), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
17033
17088
  };
17034
17089
 
17035
17090
  const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
@@ -17110,13 +17165,14 @@ const getEditorContentVirtualDom = ({
17110
17165
  scrollBarWidth = 0,
17111
17166
  selectionInfos = [],
17112
17167
  textInfos,
17168
+ unnecessaryDiagnostics = [],
17113
17169
  visibleLineIndices = [],
17114
17170
  visibleViewLineIndices = []
17115
17171
  }) => {
17116
17172
  return [{
17117
17173
  ...editorContentNode,
17118
17174
  className: breadcrumbsEnabled ? 'EditorContent EditorBreadcrumbsOffset' : 'EditorContent'
17119
- }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
17175
+ }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
17120
17176
  };
17121
17177
 
17122
17178
  const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
@@ -17288,6 +17344,7 @@ const getEditorVirtualDom = ({
17288
17344
  selections = new Uint32Array(),
17289
17345
  textInfos,
17290
17346
  uid,
17347
+ unnecessaryDiagnostics = [],
17291
17348
  uri = '',
17292
17349
  visibleLineIndices,
17293
17350
  visibleViewLineIndices = [],
@@ -17345,6 +17402,7 @@ const getEditorVirtualDom = ({
17345
17402
  scrollBarWidth,
17346
17403
  selectionInfos,
17347
17404
  textInfos: combineWhitespaceTokens$1 ? textInfos.map(combineWhitespaceTokens) : textInfos,
17405
+ unnecessaryDiagnostics,
17348
17406
  visibleLineIndices: visibleLineIndices || [],
17349
17407
  visibleViewLineIndices
17350
17408
  }), ...minimapDom];
@@ -17520,7 +17578,8 @@ const getDom = state => {
17520
17578
  ...state,
17521
17579
  diagnostics: visualDecorations,
17522
17580
  scrollBarDiagnostics: getScrollBarDiagnostics(state, diagnostics),
17523
- scrollBarWidth: getScrollBarSize(width, longestLineWidth, minimumSliderSize)
17581
+ scrollBarWidth: getScrollBarSize(width, longestLineWidth, minimumSliderSize),
17582
+ unnecessaryDiagnostics: diagnostics
17524
17583
  });
17525
17584
  };
17526
17585
  const mergeConflictsEqual = (oldState, newState) => {
@@ -17699,7 +17758,7 @@ const renderLines = {
17699
17758
  const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow, diagnostics || []);
17700
17759
  return [/* method */'setText', dom];
17701
17760
  },
17702
- isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
17761
+ isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.diagnostics === newState.diagnostics && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
17703
17762
  };
17704
17763
  const renderSelections = {
17705
17764
  apply: (oldState, newState) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.70.1",
3
+ "version": "19.70.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"