@lvce-editor/editor-worker 19.78.10 → 19.78.12

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
@@ -19592,8 +19592,8 @@ const handleContextMenu = async (editor, button, x, y) => {
19592
19592
  /* eslint-disable sonarjs/super-linear-regex */
19593
19593
 
19594
19594
  // match all words, including umlauts, see https://stackoverflow.com/questions/5436824/matching-accented-characters-with-javascript-regexes/#answer-11550799
19595
- const RE_WORD_START = /^[a-zA-Z\u{C0}-\u{17F}\d]+/u;
19596
- const RE_WORD_END = /[a-zA-Z\u{C0}-\u{17F}\d]+$/u;
19595
+ const RE_WORD_START = /^[a-zA-Z\u{C0}-\u{17F}\d_]+/u;
19596
+ const RE_WORD_END = /[a-zA-Z\u{C0}-\u{17F}\d_]+$/u;
19597
19597
 
19598
19598
  // @ts-ignore
19599
19599
  const getNewSelections$7 = (line, rowIndex, columnIndex) => {
@@ -21238,22 +21238,31 @@ const handleWheel$2 = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
21238
21238
  return setDelta(editor, deltaMode, eventDeltaX, eventDeltaY);
21239
21239
  };
21240
21240
 
21241
- // @ts-ignore
21242
- const getChanges$2 = selections => {
21241
+ const getChanges$2 = editor => {
21242
+ const {
21243
+ lines,
21244
+ selections
21245
+ } = editor;
21243
21246
  const changes = [];
21244
- const rowsToIndentLess = [];
21247
+ const rowsToIndentLess = new Set();
21245
21248
  for (let i = 0; i < selections.length; i += 4) {
21246
21249
  const selectionStartRow = selections[i];
21247
21250
  const selectionEndRow = selections[i + 2];
21248
21251
  for (let i = selectionStartRow; i <= selectionEndRow; i++) {
21249
- rowsToIndentLess.push(i);
21252
+ rowsToIndentLess.add(i);
21250
21253
  }
21251
21254
  }
21252
21255
  for (const rowToIndent of rowsToIndentLess) {
21256
+ const line = lines[rowToIndent];
21257
+ const leadingWhitespace = line.match(/^[\t ]+/)?.[0] ?? '';
21258
+ const whitespaceToRemove = leadingWhitespace.startsWith('\t') ? '\t' : leadingWhitespace.slice(0, editor.tabSize || 2);
21259
+ if (!whitespaceToRemove) {
21260
+ continue;
21261
+ }
21253
21262
  changes.push({
21254
- deleted: [' '],
21263
+ deleted: [whitespaceToRemove],
21255
21264
  end: {
21256
- columnIndex: 2,
21265
+ columnIndex: whitespaceToRemove.length,
21257
21266
  rowIndex: rowToIndent
21258
21267
  },
21259
21268
  inserted: [''],
@@ -21269,10 +21278,7 @@ const getChanges$2 = selections => {
21269
21278
 
21270
21279
  // @ts-ignore
21271
21280
  const indentLess = editor => {
21272
- const {
21273
- selections
21274
- } = editor;
21275
- const changes = getChanges$2(selections);
21281
+ const changes = getChanges$2(editor);
21276
21282
  return scheduleDocumentAndCursorsSelections(editor, changes);
21277
21283
  };
21278
21284
 
@@ -28647,7 +28653,7 @@ const commandMap = {
28647
28653
  'Editor.hasCachedCharacterWidth': has$1,
28648
28654
  'Editor.hotReload': hotReload,
28649
28655
  'Editor.incrementSelection': wrapCommand(incrementSelection),
28650
- 'Editor.indendLess': wrapCommand(indentLess),
28656
+ 'Editor.indentLess': wrapCommand(indentLess),
28651
28657
  'Editor.indentMore': wrapCommand(indentMore),
28652
28658
  'Editor.insertLineBreak': wrapCommand(insertLineBreak),
28653
28659
  'Editor.loadContent': wrapCommand(loadContent),
@@ -1461,6 +1461,12 @@ const {
1461
1461
  invokeAndTransfer: invokeAndTransfer$1,
1462
1462
  set: set$e
1463
1463
  } = create$c(RendererWorker);
1464
+ const initializeRendererWorkerForWorker = async commandMap => {
1465
+ const rpc = await create$d({
1466
+ commandMap
1467
+ });
1468
+ set$e(rpc);
1469
+ };
1464
1470
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1465
1471
  number(uid);
1466
1472
  number(menuId);
@@ -1515,6 +1521,26 @@ const openUri = async (uri, focus, options) => {
1515
1521
  const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
1516
1522
  await invokeAndTransfer$1('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
1517
1523
  };
1524
+ const send$1 = async (port, sourceId = 0) => {
1525
+ await sendMessagePortToOpenerWorker(port, sourceId);
1526
+ };
1527
+ const initializeOpenerWorker = async () => {
1528
+ const rpc = await create$f({
1529
+ commandMap: {},
1530
+ send: send$1
1531
+ });
1532
+ set$g(rpc);
1533
+ };
1534
+ const send3 = port => {
1535
+ return sendMessagePortToTextMeasurementWorker(port);
1536
+ };
1537
+ const initializeTextMeasurementWorker = async () => {
1538
+ const rpc = await create$f({
1539
+ commandMap: {},
1540
+ send: send3
1541
+ });
1542
+ set$f(rpc);
1543
+ };
1518
1544
 
1519
1545
  const {
1520
1546
  invoke: invoke$d,
@@ -12370,7 +12396,7 @@ const dispose$5 = rpcId => {
12370
12396
  deliveries.delete(rpcId);
12371
12397
  }
12372
12398
  };
12373
- const send$2 = (rpcId, rpc, status) => {
12399
+ const send = (rpcId, rpc, status) => {
12374
12400
  let delivery = deliveries.get(rpcId);
12375
12401
  if (!delivery || delivery.rpc !== rpc) {
12376
12402
  dispose$5(rpcId);
@@ -15683,7 +15709,7 @@ const getEditorStatus = editor => {
15683
15709
  const sendToListener = async (rpcId, status) => {
15684
15710
  const rpc = get$b(rpcId);
15685
15711
  if (rpc) {
15686
- await send$2(rpcId, rpc, status);
15712
+ await send(rpcId, rpc, status);
15687
15713
  }
15688
15714
  };
15689
15715
  const initializeListener = async rpcId => {
@@ -20017,8 +20043,8 @@ const handleContextMenu = async (editor, button, x, y) => {
20017
20043
  /* eslint-disable sonarjs/super-linear-regex */
20018
20044
 
20019
20045
  // match all words, including umlauts, see https://stackoverflow.com/questions/5436824/matching-accented-characters-with-javascript-regexes/#answer-11550799
20020
- const RE_WORD_START = /^[a-zA-Z\u{C0}-\u{17F}\d]+/u;
20021
- const RE_WORD_END = /[a-zA-Z\u{C0}-\u{17F}\d]+$/u;
20046
+ const RE_WORD_START = /^[a-zA-Z\u{C0}-\u{17F}\d_]+/u;
20047
+ const RE_WORD_END = /[a-zA-Z\u{C0}-\u{17F}\d_]+$/u;
20022
20048
 
20023
20049
  // @ts-ignore
20024
20050
  const getNewSelections$7 = (line, rowIndex, columnIndex) => {
@@ -21663,22 +21689,31 @@ const handleWheel$2 = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
21663
21689
  return setDelta(editor, deltaMode, eventDeltaX, eventDeltaY);
21664
21690
  };
21665
21691
 
21666
- // @ts-ignore
21667
- const getChanges$2 = selections => {
21692
+ const getChanges$2 = editor => {
21693
+ const {
21694
+ lines,
21695
+ selections
21696
+ } = editor;
21668
21697
  const changes = [];
21669
- const rowsToIndentLess = [];
21698
+ const rowsToIndentLess = new Set();
21670
21699
  for (let i = 0; i < selections.length; i += 4) {
21671
21700
  const selectionStartRow = selections[i];
21672
21701
  const selectionEndRow = selections[i + 2];
21673
21702
  for (let i = selectionStartRow; i <= selectionEndRow; i++) {
21674
- rowsToIndentLess.push(i);
21703
+ rowsToIndentLess.add(i);
21675
21704
  }
21676
21705
  }
21677
21706
  for (const rowToIndent of rowsToIndentLess) {
21707
+ const line = lines[rowToIndent];
21708
+ const leadingWhitespace = line.match(/^[\t ]+/)?.[0] ?? '';
21709
+ const whitespaceToRemove = leadingWhitespace.startsWith('\t') ? '\t' : leadingWhitespace.slice(0, editor.tabSize || 2);
21710
+ if (!whitespaceToRemove) {
21711
+ continue;
21712
+ }
21678
21713
  changes.push({
21679
- deleted: [' '],
21714
+ deleted: [whitespaceToRemove],
21680
21715
  end: {
21681
- columnIndex: 2,
21716
+ columnIndex: whitespaceToRemove.length,
21682
21717
  rowIndex: rowToIndent
21683
21718
  },
21684
21719
  inserted: [''],
@@ -21694,10 +21729,7 @@ const getChanges$2 = selections => {
21694
21729
 
21695
21730
  // @ts-ignore
21696
21731
  const indentLess = editor => {
21697
- const {
21698
- selections
21699
- } = editor;
21700
- const changes = getChanges$2(selections);
21732
+ const changes = getChanges$2(editor);
21701
21733
  return scheduleDocumentAndCursorsSelections(editor, changes);
21702
21734
  };
21703
21735
 
@@ -29069,7 +29101,7 @@ const commandMap = {
29069
29101
  'Editor.hasCachedCharacterWidth': has$1,
29070
29102
  'Editor.hotReload': hotReload,
29071
29103
  'Editor.incrementSelection': wrapCommand(incrementSelection),
29072
- 'Editor.indendLess': wrapCommand(indentLess),
29104
+ 'Editor.indentLess': wrapCommand(indentLess),
29073
29105
  'Editor.indentMore': wrapCommand(indentMore),
29074
29106
  'Editor.insertLineBreak': wrapCommand(insertLineBreak),
29075
29107
  'Editor.loadContent': wrapCommand(loadContent),
@@ -29307,39 +29339,9 @@ const initializeExtensionManagementWorker = async () => {
29307
29339
  }
29308
29340
  };
29309
29341
 
29310
- const send$1 = port => {
29311
- // @ts-ignore
29312
- return sendMessagePortToOpenerWorker(port);
29313
- };
29314
- const initializeOpenerWorker = async () => {
29315
- const rpc = await create$f({
29316
- commandMap: {},
29317
- send: send$1
29318
- });
29319
- set$g(rpc);
29320
- };
29321
-
29322
- const initializeRendererWorker = async () => {
29323
- const rpc = await create$d({
29324
- commandMap: commandMap
29325
- });
29326
- set$e(rpc);
29327
- };
29328
-
29329
- const send = port => {
29330
- return sendMessagePortToTextMeasurementWorker(port);
29331
- };
29332
- const initializeTextMeasurementWorker = async () => {
29333
- const rpc = await create$f({
29334
- commandMap: {},
29335
- send
29336
- });
29337
- set$f(rpc);
29338
- };
29339
-
29340
29342
  const listen = async () => {
29341
29343
  registerCommands(commandMap);
29342
- await Promise.all([initializeRendererWorker(), initializeDragAndDropWorker(), initializeErrorWorker(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeCacheWorker(), initializeOpenerWorker()]);
29344
+ await Promise.all([initializeRendererWorkerForWorker(commandMap), initializeDragAndDropWorker(), initializeErrorWorker(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeCacheWorker(), initializeOpenerWorker()]);
29343
29345
  const dialogRpc = await create$f({
29344
29346
  commandMap: {},
29345
29347
  send: sendMessagePortToDialogWorker
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.78.10",
3
+ "version": "19.78.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"