@lvce-editor/editor-worker 19.75.4 → 19.75.5

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
@@ -4869,7 +4869,12 @@ const updateTransformedDiagnostics = async (editor, changes) => {
4869
4869
  return addDiagnostics(editor, diagnostics);
4870
4870
  };
4871
4871
  const scheduleSelections = (editor, selectionEdits) => {
4872
- return setSelections$2(editor, selectionEdits);
4872
+ return {
4873
+ ...setSelections$2(editor, selectionEdits),
4874
+ ...(editor.snippetTabStops && {
4875
+ snippetTabStops: undefined
4876
+ })
4877
+ };
4873
4878
  };
4874
4879
  const updateLines = (editor, lines) => {
4875
4880
  const newEditor = {
@@ -4930,6 +4935,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
4930
4935
  modified: true,
4931
4936
  redoStack: [],
4932
4937
  selections: newSelections,
4938
+ snippetTabStops: changes.every(change => change.origin === EditorType || change.origin === EditorTypeWithAutoClosing) ? editor.snippetTabStops : undefined,
4933
4939
  undoStack
4934
4940
  };
4935
4941
  // Update link decorations after text changes
@@ -4992,7 +4998,8 @@ const scheduleDocumentAndCursorsSelectionIsUndo = async (editor, changes, select
4992
4998
  // undoStack: [...editor.undoStack.slice(0, -2)],
4993
4999
  invalidStartIndex,
4994
5000
  lines: newLines,
4995
- selections: newSelections
5001
+ selections: newSelections,
5002
+ snippetTabStops: undefined
4996
5003
  };
4997
5004
  const incrementalEdits = await getIncrementalEdits(editor, newEditor);
4998
5005
 
@@ -14213,24 +14220,38 @@ const getTabCompletion = async editor => {
14213
14220
  return completions;
14214
14221
  };
14215
14222
 
14223
+ const getSnippetLines = inserted => {
14224
+ return splitLines$2(inserted).map(line => {
14225
+ const tabStops = [];
14226
+ let text = '';
14227
+ for (let i = 0; i < line.length; i++) {
14228
+ if (line[i] === '$' && line[i + 1] >= '0' && line[i + 1] <= '9' && line[i - 1] !== '\\') {
14229
+ tabStops.push({
14230
+ index: Number(line[i + 1]),
14231
+ position: text.length
14232
+ });
14233
+ i++;
14234
+ } else {
14235
+ text += line[i];
14236
+ }
14237
+ }
14238
+ return {
14239
+ tabStops,
14240
+ text
14241
+ };
14242
+ });
14243
+ };
14216
14244
  const getSnippetChanges = (lines, selections, snippet) => {
14217
14245
  // TODO verify that deleted fits in the line
14218
- const insertedLines = splitLines$2(snippet.inserted);
14246
+ const parsedLines = getSnippetLines(snippet.inserted);
14247
+ const insertedLines = parsedLines.map(line => line.text);
14219
14248
  const changes = [];
14220
14249
  const selectionChanges = [];
14250
+ const tabStops = [];
14221
14251
  for (let i = 0; i < selections.length; i += 4) {
14222
14252
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
14223
14253
  if (insertedLines.length > 1) {
14224
- let placeholderRow = -1;
14225
- let placeholderColumn = -1;
14226
- const insertedLinesWithoutPlaceholder = insertedLines.map((line, rowIndex) => {
14227
- const index = line.indexOf('$0');
14228
- if (index !== -1 && placeholderRow === -1) {
14229
- placeholderRow = rowIndex;
14230
- placeholderColumn = index;
14231
- }
14232
- return line.replace('$0', '');
14233
- });
14254
+ const insertedLinesWithoutPlaceholder = insertedLines;
14234
14255
  const line = getLine$1({
14235
14256
  lines
14236
14257
  }, selectionStartRow);
@@ -14251,32 +14272,45 @@ const getSnippetChanges = (lines, selections, snippet) => {
14251
14272
  }
14252
14273
  });
14253
14274
  const lastInsertedLine = insertedLines.at(-1);
14254
- if (placeholderRow === -1) {
14275
+ const stops = parsedLines.flatMap((line, rowIndex) => line.tabStops.map(stop => ({
14276
+ ...stop,
14277
+ rowIndex
14278
+ })));
14279
+ const initialStop = stops.find(stop => stop.index === 0) ?? stops.filter(stop => stop.index > 0).toSorted((a, b) => a.index - b.index)[0];
14280
+ if (initialStop) {
14281
+ const cursorRow = selectionStartRow + initialStop.rowIndex;
14282
+ const cursorColumn = initialStop.position + (initialStop.rowIndex === 0 ? selectionStartColumn - snippet.deleted : indent.length);
14283
+ selectionChanges.push(cursorRow, cursorColumn, cursorRow, cursorColumn);
14284
+ } else {
14255
14285
  selectionChanges.push(selectionEndRow + insertedLines.length - deleted.length,
14256
14286
  // @ts-ignore
14257
14287
  selectionEndColumn + lastInsertedLine.length, selectionEndRow + insertedLines.length - deleted.length,
14258
14288
  // @ts-ignore
14259
14289
  selectionEndColumn + lastInsertedLine.length);
14260
- } else {
14261
- const cursorRow = selectionStartRow + placeholderRow;
14262
- const cursorColumn = placeholderColumn + (placeholderRow === 0 ? selectionStartColumn - snippet.deleted : indent.length);
14263
- selectionChanges.push(cursorRow, cursorColumn, cursorRow, cursorColumn);
14290
+ }
14291
+ for (const stop of stops) {
14292
+ const columnIndex = stop.position + (stop.rowIndex === 0 ? selectionStartColumn - snippet.deleted : indent.length);
14293
+ tabStops.push({
14294
+ columnIndex,
14295
+ index: stop.index,
14296
+ rowIndex: selectionStartRow + stop.rowIndex
14297
+ });
14264
14298
  }
14265
14299
  } else {
14266
14300
  const line = insertedLines[0];
14267
- const placeholderIndex = line.indexOf('$0');
14268
- if (placeholderIndex === -1) {
14269
- const cursorColumnIndex = selectionStartColumn - snippet.deleted;
14270
- // @ts-ignore
14301
+ const stops = parsedLines[0].tabStops;
14302
+ const initialStop = stops.find(stop => stop.index === 0) ?? stops.filter(stop => stop.index > 0).toSorted((a, b) => a.index - b.index)[0];
14303
+ if (initialStop) {
14304
+ const inserted = line;
14305
+ const cursorColumnIndex = selectionStartColumn - snippet.deleted + initialStop.position;
14271
14306
  selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
14272
- // @ts-ignore
14273
14307
  changes.push({
14274
14308
  deleted: [''],
14275
14309
  end: {
14276
14310
  columnIndex: selectionEndColumn,
14277
14311
  rowIndex: selectionEndRow
14278
14312
  },
14279
- inserted: insertedLines,
14313
+ inserted: [inserted],
14280
14314
  origin: EditorSnippet,
14281
14315
  start: {
14282
14316
  columnIndex: selectionStartColumn - snippet.deleted,
@@ -14284,16 +14318,17 @@ const getSnippetChanges = (lines, selections, snippet) => {
14284
14318
  }
14285
14319
  });
14286
14320
  } else {
14287
- const inserted = line.replace('$0', '');
14288
- const cursorColumnIndex = selectionStartColumn - snippet.deleted + placeholderIndex;
14321
+ const cursorColumnIndex = selectionStartColumn - snippet.deleted;
14322
+ // @ts-ignore
14289
14323
  selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
14324
+ // @ts-ignore
14290
14325
  changes.push({
14291
14326
  deleted: [''],
14292
14327
  end: {
14293
14328
  columnIndex: selectionEndColumn,
14294
14329
  rowIndex: selectionEndRow
14295
14330
  },
14296
- inserted: [inserted],
14331
+ inserted: insertedLines,
14297
14332
  origin: EditorSnippet,
14298
14333
  start: {
14299
14334
  columnIndex: selectionStartColumn - snippet.deleted,
@@ -14301,18 +14336,26 @@ const getSnippetChanges = (lines, selections, snippet) => {
14301
14336
  }
14302
14337
  });
14303
14338
  }
14339
+ for (const stop of stops) {
14340
+ tabStops.push({
14341
+ columnIndex: selectionStartColumn - snippet.deleted + stop.position,
14342
+ index: stop.index,
14343
+ rowIndex: selectionStartRow
14344
+ });
14345
+ }
14304
14346
  }
14305
14347
  }
14306
14348
  return {
14307
14349
  changes,
14308
- selectionChanges: new Uint32Array(selectionChanges)
14350
+ selectionChanges: new Uint32Array(selectionChanges),
14351
+ tabStops
14309
14352
  };
14310
14353
  };
14311
14354
 
14312
14355
  // const getIndent =
14313
14356
  // TODO rename to insertSnippet
14314
14357
  // TODO handle snippet tabstops and cursors $0 -> becomes cursor
14315
- const editorSnippet = (editor, snippet) => {
14358
+ const editorSnippet = async (editor, snippet) => {
14316
14359
  // TODO verify that deleted fits in the line
14317
14360
  const {
14318
14361
  lines,
@@ -14320,9 +14363,27 @@ const editorSnippet = (editor, snippet) => {
14320
14363
  } = editor;
14321
14364
  const {
14322
14365
  changes,
14323
- selectionChanges
14366
+ selectionChanges,
14367
+ tabStops
14324
14368
  } = getSnippetChanges(lines, selections, snippet);
14325
- return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
14369
+ const newEditor = await scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
14370
+ if (selections.length !== 4 || tabStops.length < 2) {
14371
+ return newEditor;
14372
+ }
14373
+ const initialStop = tabStops.find(stop => stop.index === 0) ?? tabStops.filter(stop => stop.index > 0).toSorted((a, b) => a.index - b.index)[0];
14374
+ const remainingStops = tabStops.filter(stop => stop !== initialStop && stop.index > 0).toSorted((a, b) => a.index - b.index).map(stop => ({
14375
+ offset: offsetAt(newEditor, stop.rowIndex, stop.columnIndex)
14376
+ }));
14377
+ if (remainingStops.length === 0) {
14378
+ return newEditor;
14379
+ }
14380
+ return {
14381
+ ...newEditor,
14382
+ snippetTabStops: {
14383
+ activeOffset: offsetAt(newEditor, initialStop.rowIndex, initialStop.columnIndex),
14384
+ stops: remainingStops
14385
+ }
14386
+ };
14326
14387
  };
14327
14388
 
14328
14389
  const getErrorMessage$1 = String;
@@ -14519,6 +14580,19 @@ const getBlockCommentEdits = (editor, blockComment) => {
14519
14580
  };
14520
14581
 
14521
14582
  const getLineComment = async editor => {
14583
+ try {
14584
+ const lineComment = await execute({
14585
+ args: [],
14586
+ editor,
14587
+ kind: 'comment',
14588
+ method: 'provideComment'
14589
+ });
14590
+ if (Array.isArray(lineComment) && lineComment[1] === '') {
14591
+ return lineComment[0];
14592
+ }
14593
+ } catch {
14594
+ // ignore
14595
+ }
14522
14596
  const languageConfiguration = await getLanguageConfiguration(editor);
14523
14597
  if (!languageConfiguration?.comments?.lineComment) {
14524
14598
  return undefined;
@@ -16972,6 +17046,34 @@ const handleTab = async editor => {
16972
17046
  if (!isEverySelectionEmpty(editor.selections)) {
16973
17047
  return indentMore(editor);
16974
17048
  }
17049
+ if (editor.snippetTabStops) {
17050
+ const {
17051
+ activeOffset,
17052
+ stops
17053
+ } = editor.snippetTabStops;
17054
+ if (stops.length > 0 && editor.selections.length === 4) {
17055
+ const offset = offsetAt(editor, editor.selections[2], editor.selections[3]);
17056
+ const delta = offset - activeOffset;
17057
+ if (delta >= 0) {
17058
+ const [nextStop, ...remainingStops] = stops;
17059
+ const position = positionAt(editor, nextStop.offset + delta);
17060
+ const newEditor = scheduleSelections(editor, new Uint32Array([position.rowIndex, position.columnIndex, position.rowIndex, position.columnIndex]));
17061
+ return {
17062
+ ...newEditor,
17063
+ snippetTabStops: remainingStops.length > 0 ? {
17064
+ activeOffset: nextStop.offset + delta,
17065
+ stops: remainingStops.map(stop => ({
17066
+ offset: stop.offset + delta
17067
+ }))
17068
+ } : undefined
17069
+ };
17070
+ }
17071
+ }
17072
+ editor = {
17073
+ ...editor,
17074
+ snippetTabStops: undefined
17075
+ };
17076
+ }
16975
17077
  try {
16976
17078
  const result = await getTabCompletion(editor);
16977
17079
  if (!result) {
@@ -5282,7 +5282,12 @@ const updateTransformedDiagnostics = async (editor, changes) => {
5282
5282
  return addDiagnostics(editor, diagnostics);
5283
5283
  };
5284
5284
  const scheduleSelections = (editor, selectionEdits) => {
5285
- return setSelections$2(editor, selectionEdits);
5285
+ return {
5286
+ ...setSelections$2(editor, selectionEdits),
5287
+ ...(editor.snippetTabStops && {
5288
+ snippetTabStops: undefined
5289
+ })
5290
+ };
5286
5291
  };
5287
5292
  const updateLines = (editor, lines) => {
5288
5293
  const newEditor = {
@@ -5343,6 +5348,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
5343
5348
  modified: true,
5344
5349
  redoStack: [],
5345
5350
  selections: newSelections,
5351
+ snippetTabStops: changes.every(change => change.origin === EditorType || change.origin === EditorTypeWithAutoClosing) ? editor.snippetTabStops : undefined,
5346
5352
  undoStack
5347
5353
  };
5348
5354
  // Update link decorations after text changes
@@ -5405,7 +5411,8 @@ const scheduleDocumentAndCursorsSelectionIsUndo = async (editor, changes, select
5405
5411
  // undoStack: [...editor.undoStack.slice(0, -2)],
5406
5412
  invalidStartIndex,
5407
5413
  lines: newLines,
5408
- selections: newSelections
5414
+ selections: newSelections,
5415
+ snippetTabStops: undefined
5409
5416
  };
5410
5417
  const incrementalEdits = await getIncrementalEdits(editor, newEditor);
5411
5418
 
@@ -14617,24 +14624,38 @@ const getTabCompletion = async editor => {
14617
14624
  return completions;
14618
14625
  };
14619
14626
 
14627
+ const getSnippetLines = inserted => {
14628
+ return splitLines(inserted).map(line => {
14629
+ const tabStops = [];
14630
+ let text = '';
14631
+ for (let i = 0; i < line.length; i++) {
14632
+ if (line[i] === '$' && line[i + 1] >= '0' && line[i + 1] <= '9' && line[i - 1] !== '\\') {
14633
+ tabStops.push({
14634
+ index: Number(line[i + 1]),
14635
+ position: text.length
14636
+ });
14637
+ i++;
14638
+ } else {
14639
+ text += line[i];
14640
+ }
14641
+ }
14642
+ return {
14643
+ tabStops,
14644
+ text
14645
+ };
14646
+ });
14647
+ };
14620
14648
  const getSnippetChanges = (lines, selections, snippet) => {
14621
14649
  // TODO verify that deleted fits in the line
14622
- const insertedLines = splitLines(snippet.inserted);
14650
+ const parsedLines = getSnippetLines(snippet.inserted);
14651
+ const insertedLines = parsedLines.map(line => line.text);
14623
14652
  const changes = [];
14624
14653
  const selectionChanges = [];
14654
+ const tabStops = [];
14625
14655
  for (let i = 0; i < selections.length; i += 4) {
14626
14656
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
14627
14657
  if (insertedLines.length > 1) {
14628
- let placeholderRow = -1;
14629
- let placeholderColumn = -1;
14630
- const insertedLinesWithoutPlaceholder = insertedLines.map((line, rowIndex) => {
14631
- const index = line.indexOf('$0');
14632
- if (index !== -1 && placeholderRow === -1) {
14633
- placeholderRow = rowIndex;
14634
- placeholderColumn = index;
14635
- }
14636
- return line.replace('$0', '');
14637
- });
14658
+ const insertedLinesWithoutPlaceholder = insertedLines;
14638
14659
  const line = getLine$1({
14639
14660
  lines
14640
14661
  }, selectionStartRow);
@@ -14655,32 +14676,45 @@ const getSnippetChanges = (lines, selections, snippet) => {
14655
14676
  }
14656
14677
  });
14657
14678
  const lastInsertedLine = insertedLines.at(-1);
14658
- if (placeholderRow === -1) {
14679
+ const stops = parsedLines.flatMap((line, rowIndex) => line.tabStops.map(stop => ({
14680
+ ...stop,
14681
+ rowIndex
14682
+ })));
14683
+ const initialStop = stops.find(stop => stop.index === 0) ?? stops.filter(stop => stop.index > 0).toSorted((a, b) => a.index - b.index)[0];
14684
+ if (initialStop) {
14685
+ const cursorRow = selectionStartRow + initialStop.rowIndex;
14686
+ const cursorColumn = initialStop.position + (initialStop.rowIndex === 0 ? selectionStartColumn - snippet.deleted : indent.length);
14687
+ selectionChanges.push(cursorRow, cursorColumn, cursorRow, cursorColumn);
14688
+ } else {
14659
14689
  selectionChanges.push(selectionEndRow + insertedLines.length - deleted.length,
14660
14690
  // @ts-ignore
14661
14691
  selectionEndColumn + lastInsertedLine.length, selectionEndRow + insertedLines.length - deleted.length,
14662
14692
  // @ts-ignore
14663
14693
  selectionEndColumn + lastInsertedLine.length);
14664
- } else {
14665
- const cursorRow = selectionStartRow + placeholderRow;
14666
- const cursorColumn = placeholderColumn + (placeholderRow === 0 ? selectionStartColumn - snippet.deleted : indent.length);
14667
- selectionChanges.push(cursorRow, cursorColumn, cursorRow, cursorColumn);
14694
+ }
14695
+ for (const stop of stops) {
14696
+ const columnIndex = stop.position + (stop.rowIndex === 0 ? selectionStartColumn - snippet.deleted : indent.length);
14697
+ tabStops.push({
14698
+ columnIndex,
14699
+ index: stop.index,
14700
+ rowIndex: selectionStartRow + stop.rowIndex
14701
+ });
14668
14702
  }
14669
14703
  } else {
14670
14704
  const line = insertedLines[0];
14671
- const placeholderIndex = line.indexOf('$0');
14672
- if (placeholderIndex === -1) {
14673
- const cursorColumnIndex = selectionStartColumn - snippet.deleted;
14674
- // @ts-ignore
14705
+ const stops = parsedLines[0].tabStops;
14706
+ const initialStop = stops.find(stop => stop.index === 0) ?? stops.filter(stop => stop.index > 0).toSorted((a, b) => a.index - b.index)[0];
14707
+ if (initialStop) {
14708
+ const inserted = line;
14709
+ const cursorColumnIndex = selectionStartColumn - snippet.deleted + initialStop.position;
14675
14710
  selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
14676
- // @ts-ignore
14677
14711
  changes.push({
14678
14712
  deleted: [''],
14679
14713
  end: {
14680
14714
  columnIndex: selectionEndColumn,
14681
14715
  rowIndex: selectionEndRow
14682
14716
  },
14683
- inserted: insertedLines,
14717
+ inserted: [inserted],
14684
14718
  origin: EditorSnippet,
14685
14719
  start: {
14686
14720
  columnIndex: selectionStartColumn - snippet.deleted,
@@ -14688,16 +14722,17 @@ const getSnippetChanges = (lines, selections, snippet) => {
14688
14722
  }
14689
14723
  });
14690
14724
  } else {
14691
- const inserted = line.replace('$0', '');
14692
- const cursorColumnIndex = selectionStartColumn - snippet.deleted + placeholderIndex;
14725
+ const cursorColumnIndex = selectionStartColumn - snippet.deleted;
14726
+ // @ts-ignore
14693
14727
  selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
14728
+ // @ts-ignore
14694
14729
  changes.push({
14695
14730
  deleted: [''],
14696
14731
  end: {
14697
14732
  columnIndex: selectionEndColumn,
14698
14733
  rowIndex: selectionEndRow
14699
14734
  },
14700
- inserted: [inserted],
14735
+ inserted: insertedLines,
14701
14736
  origin: EditorSnippet,
14702
14737
  start: {
14703
14738
  columnIndex: selectionStartColumn - snippet.deleted,
@@ -14705,18 +14740,26 @@ const getSnippetChanges = (lines, selections, snippet) => {
14705
14740
  }
14706
14741
  });
14707
14742
  }
14743
+ for (const stop of stops) {
14744
+ tabStops.push({
14745
+ columnIndex: selectionStartColumn - snippet.deleted + stop.position,
14746
+ index: stop.index,
14747
+ rowIndex: selectionStartRow
14748
+ });
14749
+ }
14708
14750
  }
14709
14751
  }
14710
14752
  return {
14711
14753
  changes,
14712
- selectionChanges: new Uint32Array(selectionChanges)
14754
+ selectionChanges: new Uint32Array(selectionChanges),
14755
+ tabStops
14713
14756
  };
14714
14757
  };
14715
14758
 
14716
14759
  // const getIndent =
14717
14760
  // TODO rename to insertSnippet
14718
14761
  // TODO handle snippet tabstops and cursors $0 -> becomes cursor
14719
- const editorSnippet = (editor, snippet) => {
14762
+ const editorSnippet = async (editor, snippet) => {
14720
14763
  // TODO verify that deleted fits in the line
14721
14764
  const {
14722
14765
  lines,
@@ -14724,9 +14767,27 @@ const editorSnippet = (editor, snippet) => {
14724
14767
  } = editor;
14725
14768
  const {
14726
14769
  changes,
14727
- selectionChanges
14770
+ selectionChanges,
14771
+ tabStops
14728
14772
  } = getSnippetChanges(lines, selections, snippet);
14729
- return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
14773
+ const newEditor = await scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
14774
+ if (selections.length !== 4 || tabStops.length < 2) {
14775
+ return newEditor;
14776
+ }
14777
+ const initialStop = tabStops.find(stop => stop.index === 0) ?? tabStops.filter(stop => stop.index > 0).toSorted((a, b) => a.index - b.index)[0];
14778
+ const remainingStops = tabStops.filter(stop => stop !== initialStop && stop.index > 0).toSorted((a, b) => a.index - b.index).map(stop => ({
14779
+ offset: offsetAt(newEditor, stop.rowIndex, stop.columnIndex)
14780
+ }));
14781
+ if (remainingStops.length === 0) {
14782
+ return newEditor;
14783
+ }
14784
+ return {
14785
+ ...newEditor,
14786
+ snippetTabStops: {
14787
+ activeOffset: offsetAt(newEditor, initialStop.rowIndex, initialStop.columnIndex),
14788
+ stops: remainingStops
14789
+ }
14790
+ };
14730
14791
  };
14731
14792
 
14732
14793
  const getErrorMessage$1 = String;
@@ -14923,6 +14984,19 @@ const getBlockCommentEdits = (editor, blockComment) => {
14923
14984
  };
14924
14985
 
14925
14986
  const getLineComment = async editor => {
14987
+ try {
14988
+ const lineComment = await execute({
14989
+ args: [],
14990
+ editor,
14991
+ kind: 'comment',
14992
+ method: 'provideComment'
14993
+ });
14994
+ if (Array.isArray(lineComment) && lineComment[1] === '') {
14995
+ return lineComment[0];
14996
+ }
14997
+ } catch {
14998
+ // ignore
14999
+ }
14926
15000
  const languageConfiguration = await getLanguageConfiguration(editor);
14927
15001
  if (!languageConfiguration?.comments?.lineComment) {
14928
15002
  return undefined;
@@ -17376,6 +17450,34 @@ const handleTab = async editor => {
17376
17450
  if (!isEverySelectionEmpty(editor.selections)) {
17377
17451
  return indentMore(editor);
17378
17452
  }
17453
+ if (editor.snippetTabStops) {
17454
+ const {
17455
+ activeOffset,
17456
+ stops
17457
+ } = editor.snippetTabStops;
17458
+ if (stops.length > 0 && editor.selections.length === 4) {
17459
+ const offset = offsetAt(editor, editor.selections[2], editor.selections[3]);
17460
+ const delta = offset - activeOffset;
17461
+ if (delta >= 0) {
17462
+ const [nextStop, ...remainingStops] = stops;
17463
+ const position = positionAt(editor, nextStop.offset + delta);
17464
+ const newEditor = scheduleSelections(editor, new Uint32Array([position.rowIndex, position.columnIndex, position.rowIndex, position.columnIndex]));
17465
+ return {
17466
+ ...newEditor,
17467
+ snippetTabStops: remainingStops.length > 0 ? {
17468
+ activeOffset: nextStop.offset + delta,
17469
+ stops: remainingStops.map(stop => ({
17470
+ offset: stop.offset + delta
17471
+ }))
17472
+ } : undefined
17473
+ };
17474
+ }
17475
+ }
17476
+ editor = {
17477
+ ...editor,
17478
+ snippetTabStops: undefined
17479
+ };
17480
+ }
17379
17481
  try {
17380
17482
  const result = await getTabCompletion(editor);
17381
17483
  if (!result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.75.4",
3
+ "version": "19.75.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"