@lvce-editor/editor-worker 19.78.13 → 19.78.15

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/diff-sdk.js CHANGED
@@ -2823,6 +2823,14 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
2823
2823
  };
2824
2824
  };
2825
2825
 
2826
+ const isDefaultPlainText = editor => {
2827
+ const tokenizePath = getTokenizePath$1(editor.languageId);
2828
+ // The bundled plaintext extension has the same state-free Text token as the
2829
+ // fallback. Only its exact application asset URI may bypass the worker.
2830
+ const builtinPath = editor.assetDir ? `${editor.assetDir}/extensions/builtin.language-basics-plaintext/src/tokenizePlaintext.js` : undefined;
2831
+ return editor.languageId === 'plaintext' && (!tokenizePath || tokenizePath === builtinPath) && get$6(editor.tokenizerId) === TokenizePlainText;
2832
+ };
2833
+
2826
2834
  const normalizeLine = line => {
2827
2835
  if (line.startsWith('Error: ')) {
2828
2836
  return line.slice('Error: '.length);
@@ -10854,6 +10862,20 @@ const getTokensViewport2 = async (editor, start, end, syncIncremental) => {
10854
10862
  tokens: []
10855
10863
  };
10856
10864
  }
10865
+ if (isDefaultPlainText(editor)) {
10866
+ // Plain text has no continuation state. If a contributed tokenizer is loaded
10867
+ // later, it must receive all lines and rebuild its own state from the start.
10868
+ editor.invalidStartIndex = 0;
10869
+ editor.lineCache = [];
10870
+ if (editor.lifecycle) {
10871
+ delete editor.lifecycle.sentLines;
10872
+ }
10873
+ return {
10874
+ embeddedResults: [],
10875
+ tokenizersToLoad: [],
10876
+ tokens: editor.lines.slice(start, end).map(line => tokenizeLine(line, initialLineState))
10877
+ };
10878
+ }
10857
10879
  // Preserve the original request/disposal ordering when caching is disabled.
10858
10880
  if (editor.syntaxHighlightingCacheEnabled !== true) {
10859
10881
  return getFreshTokensViewport(editor, start, end, syncIncremental);
@@ -11708,6 +11730,15 @@ const getIncrementalEdits = async (oldState, newState) => {
11708
11730
  if (newState.deltaX !== 0 || oldLine.length > threshold || newLine.length > threshold) {
11709
11731
  return emptyIncrementalEdits;
11710
11732
  }
11733
+ if (isDefaultPlainText(newState)) {
11734
+ // Match the worker's single Text-token edit, keeping visible-text work
11735
+ // in the same phase as syntax-worker incremental responses.
11736
+ return oldLine.length === newLine.length ? emptyIncrementalEdits : [{
11737
+ columnIndex: 0,
11738
+ rowIndex: rowIndex - newState.minLineY,
11739
+ text: newLine
11740
+ }];
11741
+ }
11711
11742
  // @ts-ignore
11712
11743
  const incrementalEdits = await invoke$c(
11713
11744
  // @ts-ignore
@@ -15046,7 +15077,7 @@ const isEqual$5 = (oldState, newState) => {
15046
15077
  };
15047
15078
 
15048
15079
  const isEqual$4 = (oldState, newState) => {
15049
- return oldState.rowHeight === newState.rowHeight && oldState.textDecorations === newState.textDecorations && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.deltaX === newState.deltaX && oldState.gutterWidth === newState.gutterWidth && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.width === newState.width && oldState.scrollBarHeight === newState.scrollBarHeight;
15080
+ return oldState.rowHeight === newState.rowHeight && oldState.textDecorations === newState.textDecorations && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.gutterWidth === newState.gutterWidth && oldState.scrollBarHeight === newState.scrollBarHeight;
15050
15081
  };
15051
15082
 
15052
15083
  const isEqual$3 = (oldState, newState) => {
@@ -15063,7 +15094,7 @@ const isEqual$3 = (oldState, newState) => {
15063
15094
  };
15064
15095
 
15065
15096
  const isEqual$2 = (oldState, newState) => {
15066
- return oldState.textDecorationDom === newState.textDecorationDom && oldState.breadcrumbFileIcon === newState.breadcrumbFileIcon && oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.focused === newState.focused && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.width === newState.width && oldState.gutterWidth === newState.gutterWidth && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
15097
+ return oldState.textDecorationDom === newState.textDecorationDom && oldState.breadcrumbFileIcon === newState.breadcrumbFileIcon && oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.focused === newState.focused && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.gutterWidth === newState.gutterWidth && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
15067
15098
  };
15068
15099
 
15069
15100
  const isEqual$1 = (oldState, newState) => {
@@ -15652,8 +15683,8 @@ const {
15652
15683
  setFactory
15653
15684
  } = createLazyRpc(RpcId.CompletionWorker);
15654
15685
 
15655
- // These commits preserve the document, selection, layout, widgets and lifecycle.
15656
- const diagnosticFields = new Set(['decorations', 'diagnostics', 'lightBulbRowIndex', 'visualDecorations']);
15686
+ // Diagnostic updates and undo grouping preserve the document, selection, layout, widgets and lifecycle.
15687
+ const independentFields = new Set(['canCoalesceTyping', 'decorations', 'diagnostics', 'lightBulbRowIndex', 'visualDecorations']);
15657
15688
  const isCurrent$1 = (snapshot, current) => {
15658
15689
  if (!current || current.lifecycle?.disposed) {
15659
15690
  return false;
@@ -15663,7 +15694,7 @@ const isCurrent$1 = (snapshot, current) => {
15663
15694
  }
15664
15695
  const keys = new Set([...Object.keys(snapshot), ...Object.keys(current)]);
15665
15696
  for (const key of keys) {
15666
- if (diagnosticFields.has(key)) {
15697
+ if (independentFields.has(key)) {
15667
15698
  continue;
15668
15699
  }
15669
15700
  const field = key;
@@ -15682,6 +15713,7 @@ const merge = (current, snapshot, result) => {
15682
15713
  }
15683
15714
  return {
15684
15715
  ...result,
15716
+ canCoalesceTyping: current.canCoalesceTyping ?? false,
15685
15717
  decorations: current.decorations,
15686
15718
  diagnostics: current.diagnostics,
15687
15719
  lightBulbRowIndex: current.lightBulbRowIndex,
@@ -24669,28 +24701,31 @@ ${editorSelector} .ScrollBarThumbHorizontal {
24669
24701
  `;
24670
24702
  };
24671
24703
 
24672
- const renderCss$1 = (oldState, newState) => {
24704
+ const renderCss$1 = (oldState, newState, horizontalThumbInDom = true) => {
24673
24705
  const {
24674
- deltaX,
24675
24706
  deltaY,
24676
24707
  finalDeltaY,
24677
24708
  gutterWidth,
24678
24709
  height,
24679
- longestLineWidth,
24680
- minimumSliderSize,
24681
24710
  rowHeight,
24682
24711
  scrollBarHeight,
24683
24712
  uid
24684
24713
  } = newState;
24685
- const {
24686
- width
24687
- } = getHorizontalScrollDimensions(newState);
24688
24714
  const scrollBarTop = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
24689
- const scrollBarWidth = getScrollBarSize(width, longestLineWidth, minimumSliderSize);
24690
- const scrollBarLeft = getScrollBarOffset(deltaX, Math.max(0, longestLineWidth - width), width, scrollBarWidth);
24715
+ let scrollBarWidth = 0;
24716
+ let scrollBarLeft = 0;
24717
+ if (!horizontalThumbInDom) {
24718
+ const {
24719
+ width
24720
+ } = getHorizontalScrollDimensions(newState);
24721
+ scrollBarWidth = getScrollBarSize(width, newState.longestLineWidth, newState.minimumSliderSize);
24722
+ scrollBarLeft = getScrollBarOffset(newState.deltaX, Math.max(0, newState.longestLineWidth - width), width, scrollBarWidth);
24723
+ }
24691
24724
  const decorationCss = (newState.textDecorations || []).map(({
24692
24725
  color
24693
24726
  }, index) => `.Editor[data-uid="${uid}"] .EditorTextDecoration${index} { background-color: ${color}; }`).join('\n');
24727
+ // Horizontal thumb geometry is patched on the thumb itself. Keep the
24728
+ // editor stylesheet stable while typing into an overflowing line.
24694
24729
  const css = decorationCss + getCss(uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft, deltaY);
24695
24730
  return [SetCss$1, uid, gutterWidth ? `${css}\n.Editor[data-uid="${uid}"] .Gutter { width: ${gutterWidth}px; }\n` : css];
24696
24731
  };
@@ -25364,7 +25399,7 @@ const horizontalScrollBarThumbNode = {
25364
25399
  className: mergeClassNames('ScrollBarThumb', 'ScrollBarThumbHorizontal'),
25365
25400
  type: Div
25366
25401
  };
25367
- const getScrollBarVirtualDom = (scrollBarHeight, scrollBarWidth) => {
25402
+ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarWidth, scrollBarLeft = 0) => {
25368
25403
  const hasVerticalThumb = scrollBarHeight > 0;
25369
25404
  const hasHorizontalThumb = scrollBarWidth > 0;
25370
25405
  return [{
@@ -25373,7 +25408,10 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarWidth) => {
25373
25408
  }, ...(hasVerticalThumb ? [verticalScrollBarThumbNode] : []), {
25374
25409
  ...horizontalScrollBarNode,
25375
25410
  childCount: hasHorizontalThumb ? 1 : 0
25376
- }, ...(hasHorizontalThumb ? [horizontalScrollBarThumbNode] : [])];
25411
+ }, ...(hasHorizontalThumb ? [{
25412
+ ...horizontalScrollBarThumbNode,
25413
+ style: `width:${scrollBarWidth}px;translate:${scrollBarLeft}px 0px`
25414
+ }] : [])];
25377
25415
  };
25378
25416
 
25379
25417
  const editorContentNode = {
@@ -25401,6 +25439,7 @@ const getEditorContentVirtualDom = ({
25401
25439
  rtl = false,
25402
25440
  scrollBarDiagnostics = [],
25403
25441
  scrollBarHeight = 0,
25442
+ scrollBarLeft = 0,
25404
25443
  scrollBarWidth = 0,
25405
25444
  selectionInfos = [],
25406
25445
  tabSize = 2,
@@ -25413,7 +25452,7 @@ const getEditorContentVirtualDom = ({
25413
25452
  return [{
25414
25453
  ...editorContentNode,
25415
25454
  className: breadcrumbsEnabled ? 'EditorContent EditorBreadcrumbsOffset' : 'EditorContent'
25416
- }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, textDecorationDom, rtl), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
25455
+ }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, textDecorationDom, rtl), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth, scrollBarLeft)];
25417
25456
  };
25418
25457
 
25419
25458
  const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
@@ -25597,6 +25636,7 @@ const getEditorVirtualDom = ({
25597
25636
  }, {
25598
25637
  diagnostics = fallbackDiagnostics,
25599
25638
  scrollBarDiagnostics = fallbackScrollBarDiagnostics,
25639
+ scrollBarLeft = 0,
25600
25640
  scrollBarWidth = fallbackScrollBarWidth,
25601
25641
  unnecessaryDiagnostics = fallbackUnnecessaryDiagnostics
25602
25642
  } = {}) => {
@@ -25652,6 +25692,7 @@ const getEditorVirtualDom = ({
25652
25692
  rtl,
25653
25693
  scrollBarDiagnostics,
25654
25694
  scrollBarHeight,
25695
+ scrollBarLeft,
25655
25696
  scrollBarWidth,
25656
25697
  selectionInfos,
25657
25698
  tabSize,
@@ -25763,7 +25804,7 @@ const canRenderPlainTextAppend = (oldState, newState) => {
25763
25804
  if (oldState.initial || newState.initial || !oldState.focused || !newState.focused || oldState.uid !== newState.uid || oldTextInfos[0][1] !== newTextInfos[0][1] || oldState.cursorInfos.length !== 1 || newState.cursorInfos.length !== 1 || oldState.selectionInfos.length > 0 || newState.selectionInfos.length > 0 || oldState.selections.length !== 4 || newState.selections.length !== 4 || oldState.selections[0] !== 0 || oldState.selections[1] !== oldLine.length || oldState.selections[2] !== 0 || oldState.selections[3] !== oldLine.length || newState.selections[0] !== 0 || newState.selections[1] !== newLine.length || newState.selections[2] !== 0 || newState.selections[3] !== newLine.length) {
25764
25805
  return false;
25765
25806
  }
25766
- if (oldState.breadcrumbsEnabled || newState.breadcrumbsEnabled || oldState.minimapEnabled || newState.minimapEnabled || oldState.lineNumbers !== newState.lineNumbers || oldState.highlightActiveLineNumber !== newState.highlightActiveLineNumber || oldState.highlightedLine !== newState.highlightedLine || oldState.problemsHighlightedRow !== newState.problemsHighlightedRow || oldState.focused !== newState.focused || oldState.roundedSelection !== newState.roundedSelection || oldState.width !== newState.width || oldState.height !== newState.height || oldState.minimumSliderSize !== newState.minimumSliderSize || getScrollBarSize(oldState.width, oldState.longestLineWidth, oldState.minimumSliderSize) !== getScrollBarSize(newState.width, newState.longestLineWidth, newState.minimumSliderSize) || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || !sameValues(oldState.visibleLineIndices, newState.visibleLineIndices) || !sameValues(oldState.visibleViewLineIndices, newState.visibleViewLineIndices) || oldState.differences !== newState.differences && !sameValues(oldState.differences, newState.differences) || oldState.scrollBarHeight !== newState.scrollBarHeight || oldState.uri !== newState.uri || oldState.workspaceUri !== newState.workspaceUri || oldState.assetDir !== newState.assetDir || oldState.loadError !== newState.loadError || oldState.combineWhitespaceTokens !== newState.combineWhitespaceTokens || oldState.widgets?.length > 0 || newState.widgets?.length > 0 || oldState.mergeConflicts.length > 0 || newState.mergeConflicts.length > 0 || !isEmpty(oldState.diagnostics) || !isEmpty(newState.diagnostics) || !isEmpty(oldState.textDecorationDom) || !isEmpty(newState.textDecorationDom) || !isEmpty(oldState.visualDecorations) || !isEmpty(newState.visualDecorations) || !isEmpty(oldState.bracketMatchInfos) || !isEmpty(newState.bracketMatchInfos) || !isEmpty(oldState.endOfLineDecorations) || !isEmpty(newState.endOfLineDecorations) || !isEmpty(oldState.gutterDecorations) || !isEmpty(newState.gutterDecorations) || !isEmpty(oldState.breakPoints) || !isEmpty(newState.breakPoints)) {
25807
+ if (oldState.breadcrumbsEnabled || newState.breadcrumbsEnabled || oldState.minimapEnabled || newState.minimapEnabled || oldState.lineNumbers !== newState.lineNumbers || oldState.highlightActiveLineNumber !== newState.highlightActiveLineNumber || oldState.highlightedLine !== newState.highlightedLine || oldState.problemsHighlightedRow !== newState.problemsHighlightedRow || oldState.focused !== newState.focused || oldState.roundedSelection !== newState.roundedSelection || oldState.deltaX !== newState.deltaX || oldState.gutterWidth !== newState.gutterWidth || (newState.deltaX ?? 0) !== 0 && oldState.longestLineWidth !== newState.longestLineWidth || oldState.width !== newState.width || oldState.height !== newState.height || oldState.minimumSliderSize !== newState.minimumSliderSize || getScrollBarSize(getHorizontalScrollDimensions(oldState).width, oldState.longestLineWidth, oldState.minimumSliderSize) !== getScrollBarSize(getHorizontalScrollDimensions(newState).width, newState.longestLineWidth, newState.minimumSliderSize) || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || !sameValues(oldState.visibleLineIndices, newState.visibleLineIndices) || !sameValues(oldState.visibleViewLineIndices, newState.visibleViewLineIndices) || oldState.differences !== newState.differences && !sameValues(oldState.differences, newState.differences) || oldState.scrollBarHeight !== newState.scrollBarHeight || oldState.uri !== newState.uri || oldState.workspaceUri !== newState.workspaceUri || oldState.assetDir !== newState.assetDir || oldState.loadError !== newState.loadError || oldState.combineWhitespaceTokens !== newState.combineWhitespaceTokens || oldState.widgets?.length > 0 || newState.widgets?.length > 0 || oldState.mergeConflicts.length > 0 || newState.mergeConflicts.length > 0 || !isEmpty(oldState.diagnostics) || !isEmpty(newState.diagnostics) || !isEmpty(oldState.textDecorationDom) || !isEmpty(newState.textDecorationDom) || !isEmpty(oldState.visualDecorations) || !isEmpty(newState.visualDecorations) || !isEmpty(oldState.bracketMatchInfos) || !isEmpty(newState.bracketMatchInfos) || !isEmpty(oldState.endOfLineDecorations) || !isEmpty(newState.endOfLineDecorations) || !isEmpty(oldState.gutterDecorations) || !isEmpty(newState.gutterDecorations) || !isEmpty(oldState.breakPoints) || !isEmpty(newState.breakPoints)) {
25767
25808
  return false;
25768
25809
  }
25769
25810
  return true;
@@ -25821,6 +25862,7 @@ const updateTextAppendDom = (oldDom, state, paths) => {
25821
25862
 
25822
25863
  const getDom = state => {
25823
25864
  const {
25865
+ deltaX = 0,
25824
25866
  diagnostics = [],
25825
25867
  initial,
25826
25868
  longestLineWidth,
@@ -25834,10 +25876,13 @@ const getDom = state => {
25834
25876
  const {
25835
25877
  width
25836
25878
  } = getHorizontalScrollDimensions(state);
25879
+ const scrollBarWidth = getScrollBarSize(width, longestLineWidth, minimumSliderSize);
25880
+ const scrollBarLeft = getScrollBarOffset(deltaX, Math.max(0, longestLineWidth - width), width, scrollBarWidth);
25837
25881
  return getEditorVirtualDom(state, {
25838
25882
  diagnostics: visualDecorations,
25839
25883
  scrollBarDiagnostics: getScrollBarDiagnostics(state, diagnostics),
25840
- scrollBarWidth: getScrollBarSize(width, longestLineWidth, minimumSliderSize),
25884
+ scrollBarLeft,
25885
+ scrollBarWidth,
25841
25886
  unnecessaryDiagnostics: diagnostics
25842
25887
  });
25843
25888
  };
@@ -28028,8 +28073,8 @@ const renderSelections = {
28028
28073
  isEqual: (oldState, newState) => oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos && oldState.focused === newState.focused && oldState.roundedSelection === newState.roundedSelection
28029
28074
  };
28030
28075
  const renderCss = {
28031
- apply: renderCss$1,
28032
- isEqual: isEqual$4
28076
+ apply: (oldState, newState) => renderCss$1(oldState, newState, false),
28077
+ isEqual: (oldState, newState) => isEqual$4(oldState, newState) && oldState.deltaX === newState.deltaX && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.width === newState.width
28033
28078
  };
28034
28079
  const renderFocus$1 = {
28035
28080
  apply: (oldState, newState) => [/* method */'setFocused', newState.focused],
@@ -4224,6 +4224,14 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
4224
4224
  };
4225
4225
  };
4226
4226
 
4227
+ const isDefaultPlainText = editor => {
4228
+ const tokenizePath = getTokenizePath$1(editor.languageId);
4229
+ // The bundled plaintext extension has the same state-free Text token as the
4230
+ // fallback. Only its exact application asset URI may bypass the worker.
4231
+ const builtinPath = editor.assetDir ? `${editor.assetDir}/extensions/builtin.language-basics-plaintext/src/tokenizePlaintext.js` : undefined;
4232
+ return editor.languageId === 'plaintext' && (!tokenizePath || tokenizePath === builtinPath) && get$5(editor.tokenizerId) === TokenizePlainText;
4233
+ };
4234
+
4227
4235
  const state$c = {};
4228
4236
  const create$a = () => create$g({
4229
4237
  commandMap: {},
@@ -11314,6 +11322,20 @@ const getTokensViewport2 = async (editor, start, end, syncIncremental) => {
11314
11322
  tokens: []
11315
11323
  };
11316
11324
  }
11325
+ if (isDefaultPlainText(editor)) {
11326
+ // Plain text has no continuation state. If a contributed tokenizer is loaded
11327
+ // later, it must receive all lines and rebuild its own state from the start.
11328
+ editor.invalidStartIndex = 0;
11329
+ editor.lineCache = [];
11330
+ if (editor.lifecycle) {
11331
+ delete editor.lifecycle.sentLines;
11332
+ }
11333
+ return {
11334
+ embeddedResults: [],
11335
+ tokenizersToLoad: [],
11336
+ tokens: editor.lines.slice(start, end).map(line => tokenizeLine(line, initialLineState))
11337
+ };
11338
+ }
11317
11339
  // Preserve the original request/disposal ordering when caching is disabled.
11318
11340
  if (editor.syntaxHighlightingCacheEnabled !== true) {
11319
11341
  return getFreshTokensViewport(editor, start, end, syncIncremental);
@@ -12168,6 +12190,15 @@ const getIncrementalEdits = async (oldState, newState) => {
12168
12190
  if (newState.deltaX !== 0 || oldLine.length > threshold || newLine.length > threshold) {
12169
12191
  return emptyIncrementalEdits;
12170
12192
  }
12193
+ if (isDefaultPlainText(newState)) {
12194
+ // Match the worker's single Text-token edit, keeping visible-text work
12195
+ // in the same phase as syntax-worker incremental responses.
12196
+ return oldLine.length === newLine.length ? emptyIncrementalEdits : [{
12197
+ columnIndex: 0,
12198
+ rowIndex: rowIndex - newState.minLineY,
12199
+ text: newLine
12200
+ }];
12201
+ }
12171
12202
  // @ts-ignore
12172
12203
  const incrementalEdits = await invoke$c(
12173
12204
  // @ts-ignore
@@ -15506,7 +15537,7 @@ const isEqual$5 = (oldState, newState) => {
15506
15537
  };
15507
15538
 
15508
15539
  const isEqual$4 = (oldState, newState) => {
15509
- return oldState.rowHeight === newState.rowHeight && oldState.textDecorations === newState.textDecorations && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.deltaX === newState.deltaX && oldState.gutterWidth === newState.gutterWidth && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.width === newState.width && oldState.scrollBarHeight === newState.scrollBarHeight;
15540
+ return oldState.rowHeight === newState.rowHeight && oldState.textDecorations === newState.textDecorations && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.gutterWidth === newState.gutterWidth && oldState.scrollBarHeight === newState.scrollBarHeight;
15510
15541
  };
15511
15542
 
15512
15543
  const isEqual$3 = (oldState, newState) => {
@@ -15523,7 +15554,7 @@ const isEqual$3 = (oldState, newState) => {
15523
15554
  };
15524
15555
 
15525
15556
  const isEqual$2 = (oldState, newState) => {
15526
- return oldState.textDecorationDom === newState.textDecorationDom && oldState.breadcrumbFileIcon === newState.breadcrumbFileIcon && oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.focused === newState.focused && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.width === newState.width && oldState.gutterWidth === newState.gutterWidth && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
15557
+ return oldState.textDecorationDom === newState.textDecorationDom && oldState.breadcrumbFileIcon === newState.breadcrumbFileIcon && oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.bracketMatchInfos === newState.bracketMatchInfos && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.focused === newState.focused && oldState.gutterDecorations === newState.gutterDecorations && oldState.highlightActiveLineNumber === newState.highlightActiveLineNumber && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.gutterWidth === newState.gutterWidth && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
15527
15558
  };
15528
15559
 
15529
15560
  const isEqual$1 = (oldState, newState) => {
@@ -16112,8 +16143,8 @@ const {
16112
16143
  setFactory
16113
16144
  } = createLazyRpc(CompletionWorker);
16114
16145
 
16115
- // These commits preserve the document, selection, layout, widgets and lifecycle.
16116
- const diagnosticFields = new Set(['decorations', 'diagnostics', 'lightBulbRowIndex', 'visualDecorations']);
16146
+ // Diagnostic updates and undo grouping preserve the document, selection, layout, widgets and lifecycle.
16147
+ const independentFields = new Set(['canCoalesceTyping', 'decorations', 'diagnostics', 'lightBulbRowIndex', 'visualDecorations']);
16117
16148
  const isCurrent$1 = (snapshot, current) => {
16118
16149
  if (!current || current.lifecycle?.disposed) {
16119
16150
  return false;
@@ -16123,7 +16154,7 @@ const isCurrent$1 = (snapshot, current) => {
16123
16154
  }
16124
16155
  const keys = new Set([...Object.keys(snapshot), ...Object.keys(current)]);
16125
16156
  for (const key of keys) {
16126
- if (diagnosticFields.has(key)) {
16157
+ if (independentFields.has(key)) {
16127
16158
  continue;
16128
16159
  }
16129
16160
  const field = key;
@@ -16142,6 +16173,7 @@ const merge = (current, snapshot, result) => {
16142
16173
  }
16143
16174
  return {
16144
16175
  ...result,
16176
+ canCoalesceTyping: current.canCoalesceTyping ?? false,
16145
16177
  decorations: current.decorations,
16146
16178
  diagnostics: current.diagnostics,
16147
16179
  lightBulbRowIndex: current.lightBulbRowIndex,
@@ -25120,28 +25152,31 @@ ${editorSelector} .ScrollBarThumbHorizontal {
25120
25152
  `;
25121
25153
  };
25122
25154
 
25123
- const renderCss$1 = (oldState, newState) => {
25155
+ const renderCss$1 = (oldState, newState, horizontalThumbInDom = true) => {
25124
25156
  const {
25125
- deltaX,
25126
25157
  deltaY,
25127
25158
  finalDeltaY,
25128
25159
  gutterWidth,
25129
25160
  height,
25130
- longestLineWidth,
25131
- minimumSliderSize,
25132
25161
  rowHeight,
25133
25162
  scrollBarHeight,
25134
25163
  uid
25135
25164
  } = newState;
25136
- const {
25137
- width
25138
- } = getHorizontalScrollDimensions(newState);
25139
25165
  const scrollBarTop = getScrollBarY(deltaY, finalDeltaY, height, scrollBarHeight);
25140
- const scrollBarWidth = getScrollBarSize(width, longestLineWidth, minimumSliderSize);
25141
- const scrollBarLeft = getScrollBarOffset(deltaX, Math.max(0, longestLineWidth - width), width, scrollBarWidth);
25166
+ let scrollBarWidth = 0;
25167
+ let scrollBarLeft = 0;
25168
+ if (!horizontalThumbInDom) {
25169
+ const {
25170
+ width
25171
+ } = getHorizontalScrollDimensions(newState);
25172
+ scrollBarWidth = getScrollBarSize(width, newState.longestLineWidth, newState.minimumSliderSize);
25173
+ scrollBarLeft = getScrollBarOffset(newState.deltaX, Math.max(0, newState.longestLineWidth - width), width, scrollBarWidth);
25174
+ }
25142
25175
  const decorationCss = (newState.textDecorations || []).map(({
25143
25176
  color
25144
25177
  }, index) => `.Editor[data-uid="${uid}"] .EditorTextDecoration${index} { background-color: ${color}; }`).join('\n');
25178
+ // Horizontal thumb geometry is patched on the thumb itself. Keep the
25179
+ // editor stylesheet stable while typing into an overflowing line.
25145
25180
  const css = decorationCss + getCss(uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, scrollBarLeft, deltaY);
25146
25181
  return [SetCss$1, uid, gutterWidth ? `${css}\n.Editor[data-uid="${uid}"] .Gutter { width: ${gutterWidth}px; }\n` : css];
25147
25182
  };
@@ -25815,7 +25850,7 @@ const horizontalScrollBarThumbNode = {
25815
25850
  className: mergeClassNames('ScrollBarThumb', 'ScrollBarThumbHorizontal'),
25816
25851
  type: Div
25817
25852
  };
25818
- const getScrollBarVirtualDom = (scrollBarHeight, scrollBarWidth) => {
25853
+ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarWidth, scrollBarLeft = 0) => {
25819
25854
  const hasVerticalThumb = scrollBarHeight > 0;
25820
25855
  const hasHorizontalThumb = scrollBarWidth > 0;
25821
25856
  return [{
@@ -25824,7 +25859,10 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarWidth) => {
25824
25859
  }, ...(hasVerticalThumb ? [verticalScrollBarThumbNode] : []), {
25825
25860
  ...horizontalScrollBarNode,
25826
25861
  childCount: hasHorizontalThumb ? 1 : 0
25827
- }, ...(hasHorizontalThumb ? [horizontalScrollBarThumbNode] : [])];
25862
+ }, ...(hasHorizontalThumb ? [{
25863
+ ...horizontalScrollBarThumbNode,
25864
+ style: `width:${scrollBarWidth}px;translate:${scrollBarLeft}px 0px`
25865
+ }] : [])];
25828
25866
  };
25829
25867
 
25830
25868
  const editorContentNode = {
@@ -25852,6 +25890,7 @@ const getEditorContentVirtualDom = ({
25852
25890
  rtl = false,
25853
25891
  scrollBarDiagnostics = [],
25854
25892
  scrollBarHeight = 0,
25893
+ scrollBarLeft = 0,
25855
25894
  scrollBarWidth = 0,
25856
25895
  selectionInfos = [],
25857
25896
  tabSize = 2,
@@ -25864,7 +25903,7 @@ const getEditorContentVirtualDom = ({
25864
25903
  return [{
25865
25904
  ...editorContentNode,
25866
25905
  className: breadcrumbsEnabled ? 'EditorContent EditorBreadcrumbsOffset' : 'EditorContent'
25867
- }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, textDecorationDom, rtl), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
25906
+ }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, textDecorationDom, rtl), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth, scrollBarLeft)];
25868
25907
  };
25869
25908
 
25870
25909
  const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
@@ -26048,6 +26087,7 @@ const getEditorVirtualDom = ({
26048
26087
  }, {
26049
26088
  diagnostics = fallbackDiagnostics,
26050
26089
  scrollBarDiagnostics = fallbackScrollBarDiagnostics,
26090
+ scrollBarLeft = 0,
26051
26091
  scrollBarWidth = fallbackScrollBarWidth,
26052
26092
  unnecessaryDiagnostics = fallbackUnnecessaryDiagnostics
26053
26093
  } = {}) => {
@@ -26103,6 +26143,7 @@ const getEditorVirtualDom = ({
26103
26143
  rtl,
26104
26144
  scrollBarDiagnostics,
26105
26145
  scrollBarHeight,
26146
+ scrollBarLeft,
26106
26147
  scrollBarWidth,
26107
26148
  selectionInfos,
26108
26149
  tabSize,
@@ -26214,7 +26255,7 @@ const canRenderPlainTextAppend = (oldState, newState) => {
26214
26255
  if (oldState.initial || newState.initial || !oldState.focused || !newState.focused || oldState.uid !== newState.uid || oldTextInfos[0][1] !== newTextInfos[0][1] || oldState.cursorInfos.length !== 1 || newState.cursorInfos.length !== 1 || oldState.selectionInfos.length > 0 || newState.selectionInfos.length > 0 || oldState.selections.length !== 4 || newState.selections.length !== 4 || oldState.selections[0] !== 0 || oldState.selections[1] !== oldLine.length || oldState.selections[2] !== 0 || oldState.selections[3] !== oldLine.length || newState.selections[0] !== 0 || newState.selections[1] !== newLine.length || newState.selections[2] !== 0 || newState.selections[3] !== newLine.length) {
26215
26256
  return false;
26216
26257
  }
26217
- if (oldState.breadcrumbsEnabled || newState.breadcrumbsEnabled || oldState.minimapEnabled || newState.minimapEnabled || oldState.lineNumbers !== newState.lineNumbers || oldState.highlightActiveLineNumber !== newState.highlightActiveLineNumber || oldState.highlightedLine !== newState.highlightedLine || oldState.problemsHighlightedRow !== newState.problemsHighlightedRow || oldState.focused !== newState.focused || oldState.roundedSelection !== newState.roundedSelection || oldState.width !== newState.width || oldState.height !== newState.height || oldState.minimumSliderSize !== newState.minimumSliderSize || getScrollBarSize(oldState.width, oldState.longestLineWidth, oldState.minimumSliderSize) !== getScrollBarSize(newState.width, newState.longestLineWidth, newState.minimumSliderSize) || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || !sameValues(oldState.visibleLineIndices, newState.visibleLineIndices) || !sameValues(oldState.visibleViewLineIndices, newState.visibleViewLineIndices) || oldState.differences !== newState.differences && !sameValues(oldState.differences, newState.differences) || oldState.scrollBarHeight !== newState.scrollBarHeight || oldState.uri !== newState.uri || oldState.workspaceUri !== newState.workspaceUri || oldState.assetDir !== newState.assetDir || oldState.loadError !== newState.loadError || oldState.combineWhitespaceTokens !== newState.combineWhitespaceTokens || oldState.widgets?.length > 0 || newState.widgets?.length > 0 || oldState.mergeConflicts.length > 0 || newState.mergeConflicts.length > 0 || !isEmpty(oldState.diagnostics) || !isEmpty(newState.diagnostics) || !isEmpty(oldState.textDecorationDom) || !isEmpty(newState.textDecorationDom) || !isEmpty(oldState.visualDecorations) || !isEmpty(newState.visualDecorations) || !isEmpty(oldState.bracketMatchInfos) || !isEmpty(newState.bracketMatchInfos) || !isEmpty(oldState.endOfLineDecorations) || !isEmpty(newState.endOfLineDecorations) || !isEmpty(oldState.gutterDecorations) || !isEmpty(newState.gutterDecorations) || !isEmpty(oldState.breakPoints) || !isEmpty(newState.breakPoints)) {
26258
+ if (oldState.breadcrumbsEnabled || newState.breadcrumbsEnabled || oldState.minimapEnabled || newState.minimapEnabled || oldState.lineNumbers !== newState.lineNumbers || oldState.highlightActiveLineNumber !== newState.highlightActiveLineNumber || oldState.highlightedLine !== newState.highlightedLine || oldState.problemsHighlightedRow !== newState.problemsHighlightedRow || oldState.focused !== newState.focused || oldState.roundedSelection !== newState.roundedSelection || oldState.deltaX !== newState.deltaX || oldState.gutterWidth !== newState.gutterWidth || (newState.deltaX ?? 0) !== 0 && oldState.longestLineWidth !== newState.longestLineWidth || oldState.width !== newState.width || oldState.height !== newState.height || oldState.minimumSliderSize !== newState.minimumSliderSize || getScrollBarSize(getHorizontalScrollDimensions(oldState).width, oldState.longestLineWidth, oldState.minimumSliderSize) !== getScrollBarSize(getHorizontalScrollDimensions(newState).width, newState.longestLineWidth, newState.minimumSliderSize) || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || !sameValues(oldState.visibleLineIndices, newState.visibleLineIndices) || !sameValues(oldState.visibleViewLineIndices, newState.visibleViewLineIndices) || oldState.differences !== newState.differences && !sameValues(oldState.differences, newState.differences) || oldState.scrollBarHeight !== newState.scrollBarHeight || oldState.uri !== newState.uri || oldState.workspaceUri !== newState.workspaceUri || oldState.assetDir !== newState.assetDir || oldState.loadError !== newState.loadError || oldState.combineWhitespaceTokens !== newState.combineWhitespaceTokens || oldState.widgets?.length > 0 || newState.widgets?.length > 0 || oldState.mergeConflicts.length > 0 || newState.mergeConflicts.length > 0 || !isEmpty(oldState.diagnostics) || !isEmpty(newState.diagnostics) || !isEmpty(oldState.textDecorationDom) || !isEmpty(newState.textDecorationDom) || !isEmpty(oldState.visualDecorations) || !isEmpty(newState.visualDecorations) || !isEmpty(oldState.bracketMatchInfos) || !isEmpty(newState.bracketMatchInfos) || !isEmpty(oldState.endOfLineDecorations) || !isEmpty(newState.endOfLineDecorations) || !isEmpty(oldState.gutterDecorations) || !isEmpty(newState.gutterDecorations) || !isEmpty(oldState.breakPoints) || !isEmpty(newState.breakPoints)) {
26218
26259
  return false;
26219
26260
  }
26220
26261
  return true;
@@ -26272,6 +26313,7 @@ const updateTextAppendDom = (oldDom, state, paths) => {
26272
26313
 
26273
26314
  const getDom = state => {
26274
26315
  const {
26316
+ deltaX = 0,
26275
26317
  diagnostics = [],
26276
26318
  initial,
26277
26319
  longestLineWidth,
@@ -26285,10 +26327,13 @@ const getDom = state => {
26285
26327
  const {
26286
26328
  width
26287
26329
  } = getHorizontalScrollDimensions(state);
26330
+ const scrollBarWidth = getScrollBarSize(width, longestLineWidth, minimumSliderSize);
26331
+ const scrollBarLeft = getScrollBarOffset(deltaX, Math.max(0, longestLineWidth - width), width, scrollBarWidth);
26288
26332
  return getEditorVirtualDom(state, {
26289
26333
  diagnostics: visualDecorations,
26290
26334
  scrollBarDiagnostics: getScrollBarDiagnostics(state, diagnostics),
26291
- scrollBarWidth: getScrollBarSize(width, longestLineWidth, minimumSliderSize),
26335
+ scrollBarLeft,
26336
+ scrollBarWidth,
26292
26337
  unnecessaryDiagnostics: diagnostics
26293
26338
  });
26294
26339
  };
@@ -28479,8 +28524,8 @@ const renderSelections = {
28479
28524
  isEqual: (oldState, newState) => oldState.cursorInfos === newState.cursorInfos && oldState.selectionInfos === newState.selectionInfos && oldState.focused === newState.focused && oldState.roundedSelection === newState.roundedSelection
28480
28525
  };
28481
28526
  const renderCss = {
28482
- apply: renderCss$1,
28483
- isEqual: isEqual$4
28527
+ apply: (oldState, newState) => renderCss$1(oldState, newState, false),
28528
+ isEqual: (oldState, newState) => isEqual$4(oldState, newState) && oldState.deltaX === newState.deltaX && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.width === newState.width
28484
28529
  };
28485
28530
  const renderFocus$1 = {
28486
28531
  apply: (oldState, newState) => [/* method */'setFocused', newState.focused],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.78.13",
3
+ "version": "19.78.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"