@lvce-editor/editor-worker 19.75.0 → 19.75.1

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.
@@ -543,7 +543,7 @@ class CommandNotFoundError extends Error {
543
543
  }
544
544
  }
545
545
  const commands = Object.create(null);
546
- const register = commandMap => {
546
+ const register$1 = commandMap => {
547
547
  Object.assign(commands, commandMap);
548
548
  };
549
549
  const getCommand = key => {
@@ -1102,7 +1102,7 @@ const create$h = async ({
1102
1102
  messagePort
1103
1103
  }) => {
1104
1104
  // TODO create a commandMap per rpc instance
1105
- register(commandMap);
1105
+ register$1(commandMap);
1106
1106
  const rawIpc = await IpcParentWithMessagePort$1.create({
1107
1107
  isMessagePortOpen,
1108
1108
  messagePort
@@ -1159,7 +1159,7 @@ const create$d = async ({
1159
1159
  commandMap
1160
1160
  }) => {
1161
1161
  // TODO create a commandMap per rpc instance
1162
- register(commandMap);
1162
+ register$1(commandMap);
1163
1163
  const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
1164
1164
  handleIpc(ipc);
1165
1165
  const rpc = createRpc(ipc);
@@ -1187,7 +1187,7 @@ const createMockRpc = ({
1187
1187
  };
1188
1188
 
1189
1189
  const rpcs = Object.create(null);
1190
- const set$k = (id, rpc) => {
1190
+ const set$j = (id, rpc) => {
1191
1191
  rpcs[id] = rpc;
1192
1192
  };
1193
1193
  const get$9 = id => {
@@ -1220,7 +1220,7 @@ const create$c = rpcId => {
1220
1220
  const mockRpc = createMockRpc({
1221
1221
  commandMap
1222
1222
  });
1223
- set$k(rpcId, mockRpc);
1223
+ set$j(rpcId, mockRpc);
1224
1224
  // @ts-ignore
1225
1225
  mockRpc[Symbol.dispose] = () => {
1226
1226
  remove$8(rpcId);
@@ -1229,7 +1229,7 @@ const create$c = rpcId => {
1229
1229
  return mockRpc;
1230
1230
  },
1231
1231
  set(rpc) {
1232
- set$k(rpcId, rpc);
1232
+ set$j(rpcId, rpc);
1233
1233
  }
1234
1234
  };
1235
1235
  };
@@ -1328,23 +1328,23 @@ const FocusEditorText$1 = 12;
1328
1328
 
1329
1329
  const {
1330
1330
  invoke: invoke$k,
1331
- set: set$j
1331
+ set: set$i
1332
1332
  } = create$c(DialogWorker);
1333
1333
 
1334
1334
  const {
1335
1335
  invoke: invoke$j,
1336
- set: set$i
1336
+ set: set$h
1337
1337
  } = create$c(DragAndDropWorker);
1338
1338
 
1339
1339
  const {
1340
1340
  invoke: invoke$i,
1341
- set: set$h
1341
+ set: set$g
1342
1342
  } = create$c(ErrorWorker);
1343
1343
 
1344
1344
  const {
1345
1345
  invoke: invoke$h,
1346
1346
  invokeAndTransfer: invokeAndTransfer$2,
1347
- set: set$g
1347
+ set: set$f
1348
1348
  } = create$c(ExtensionManagementWorker);
1349
1349
  const getLanguages$1 = (platform, assetDir) => {
1350
1350
  return invoke$h('Extensions.getLanguages', platform, assetDir);
@@ -1363,7 +1363,7 @@ const createLazyRpc = rpcId => {
1363
1363
  throw new Error('Lazy RPC launch was superseded');
1364
1364
  }
1365
1365
  activeRpc = rpc;
1366
- set$k(rpcId, rpc);
1366
+ set$j(rpcId, rpc);
1367
1367
  return rpc;
1368
1368
  };
1369
1369
  const ensureRpc = async () => {
@@ -1425,7 +1425,7 @@ const createLazyRpc = rpcId => {
1425
1425
 
1426
1426
  const {
1427
1427
  invoke: invoke$g,
1428
- set: set$f
1428
+ set: set$e
1429
1429
  } = create$c(OpenerWorker);
1430
1430
  const openUrl = async (url, platform) => {
1431
1431
  return invoke$g('Open.openUrl', url, platform);
@@ -1433,13 +1433,13 @@ const openUrl = async (url, platform) => {
1433
1433
 
1434
1434
  const {
1435
1435
  invoke: invoke$f,
1436
- set: set$e
1436
+ set: set$d
1437
1437
  } = create$c(TextMeasurementWorker);
1438
1438
 
1439
1439
  const {
1440
1440
  invoke: invoke$e,
1441
1441
  invokeAndTransfer: invokeAndTransfer$1,
1442
- set: set$d
1442
+ set: set$c
1443
1443
  } = create$c(RendererWorker);
1444
1444
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1445
1445
  number(uid);
@@ -1494,7 +1494,7 @@ const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
1494
1494
 
1495
1495
  const {
1496
1496
  invoke: invoke$d,
1497
- set: set$c
1497
+ set: set$b
1498
1498
  } = create$c(MarkdownWorker);
1499
1499
 
1500
1500
  const toCommandId = key => {
@@ -1805,7 +1805,7 @@ const getKeys$2 = () => {
1805
1805
  const keys = editorStates.getKeys();
1806
1806
  return keys.map(String);
1807
1807
  };
1808
- const set$b = (id, oldEditor, newEditor) => {
1808
+ const set$a = (id, oldEditor, newEditor) => {
1809
1809
  editorStates.set(id, oldEditor, newEditor);
1810
1810
  };
1811
1811
 
@@ -1856,7 +1856,7 @@ const ToggleBlockComment$1 = 'toggleBlockComment';
1856
1856
  const Unknown$2 = 'unknown';
1857
1857
 
1858
1858
  const map$1 = Object.create(null);
1859
- const set$a = (id, widget) => {
1859
+ const set$9 = (id, widget) => {
1860
1860
  map$1[id] = widget;
1861
1861
  };
1862
1862
  const get$7 = id => {
@@ -2728,7 +2728,7 @@ const getEnabled$1 = () => {
2728
2728
  };
2729
2729
 
2730
2730
  const invoke$c = (...args) => invoke$d(...args);
2731
- const set$9 = (...args) => set$c(...args);
2731
+ const set$8 = (...args) => set$b(...args);
2732
2732
 
2733
2733
  const state$d = {
2734
2734
  pending: Object.create(null),
@@ -2738,7 +2738,7 @@ const state$d = {
2738
2738
  const has = languageId => {
2739
2739
  return Object.hasOwn(state$d.tokenizers, languageId);
2740
2740
  };
2741
- const set$8 = (languageId, tokenizer) => {
2741
+ const set$7 = (languageId, tokenizer) => {
2742
2742
  state$d.tokenizers[languageId] = tokenizer;
2743
2743
  };
2744
2744
  const get$6 = languageId => {
@@ -2762,7 +2762,7 @@ const isPending = languageId => {
2762
2762
  };
2763
2763
 
2764
2764
  const tokenMaps = Object.create(null);
2765
- const set$7 = (languageId, tokenMap) => {
2765
+ const set$6 = (languageId, tokenMap) => {
2766
2766
  tokenMaps[languageId] = tokenMap;
2767
2767
  };
2768
2768
  const get$5 = languageId => {
@@ -2778,7 +2778,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2778
2778
  if (getEnabled$1()) {
2779
2779
  // @ts-ignore
2780
2780
  const tokenMap = await invoke$c('Tokenizer.load', languageId, tokenizePath);
2781
- set$7(languageId, tokenMap);
2781
+ set$6(languageId, tokenMap);
2782
2782
  return;
2783
2783
  }
2784
2784
  try {
@@ -2794,8 +2794,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2794
2794
  console.warn(`tokenizer.TokenMap should be an object in "${tokenizePath}"`);
2795
2795
  return;
2796
2796
  }
2797
- set$7(languageId, tokenizer.TokenMap);
2798
- set$8(languageId, tokenizer);
2797
+ set$6(languageId, tokenizer.TokenMap);
2798
+ set$7(languageId, tokenizer);
2799
2799
  } catch (error) {
2800
2800
  // TODO better error handling
2801
2801
  console.error(error);
@@ -2811,13 +2811,18 @@ const getTokenizer = languageId => {
2811
2811
  return TokenizePlainText;
2812
2812
  };
2813
2813
 
2814
- const tokenizers = Object.create(null);
2815
- const set$6 = (id, value) => {
2816
- tokenizers[id] = value;
2817
- };
2814
+ const tokenizers = [TokenizePlainText];
2818
2815
  const get$4 = id => {
2819
2816
  return tokenizers[id] || TokenizePlainText;
2820
2817
  };
2818
+ const register = tokenizer => {
2819
+ const existingId = tokenizers.indexOf(tokenizer);
2820
+ if (existingId !== -1) {
2821
+ return existingId;
2822
+ }
2823
+ tokenizers.push(tokenizer);
2824
+ return tokenizers.length - 1;
2825
+ };
2821
2826
 
2822
2827
  const getEmbeddedTokenization = (langageId, line, embeddedLanguage, embeddedLanguageStart, embeddedLanguageEnd, topContexts, tokenizersToLoad) => {
2823
2828
  const embeddedTokenizer = getTokenizer(embeddedLanguage);
@@ -4583,7 +4588,7 @@ const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) =>
4583
4588
  return latest.newState;
4584
4589
  }
4585
4590
  const newEditor = mergeDiagnostics(latest.newState, editorWithDiagnostics);
4586
- set$b(editor.id, latest.oldState, newEditor);
4591
+ set$a(editor.id, latest.oldState, newEditor);
4587
4592
  requestDiagnosticSnapshots.set(editor.id, diagnostics);
4588
4593
  onAccepted?.();
4589
4594
  await invoke$8('Editor.renderPending', newEditor.id);
@@ -5230,7 +5235,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
5230
5235
  ...newEditor,
5231
5236
  decorations: linkDecorations
5232
5237
  };
5233
- set$b(editor.uid, editor, newEditorWithDecorations);
5238
+ set$a(editor.uid, editor, newEditorWithDecorations);
5234
5239
 
5235
5240
  // Notify main-area-worker about modified status change
5236
5241
  if (!editor.modified) {
@@ -6288,7 +6293,7 @@ const updateColorPickerValue = async (editorUid, value) => {
6288
6293
  return;
6289
6294
  }
6290
6295
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
6291
- set$b(editorUid, editor, newEditorWithDerivedState);
6296
+ set$a(editorUid, editor, newEditorWithDerivedState);
6292
6297
  };
6293
6298
 
6294
6299
  const getColorPickerWorkerCommandMap = () => ({
@@ -6500,7 +6505,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir, _langua
6500
6505
  x,
6501
6506
  y
6502
6507
  };
6503
- set$b(id, editor, editor);
6508
+ set$a(id, editor, editor);
6504
6509
  };
6505
6510
 
6506
6511
  const emptyEditor = {
@@ -6843,16 +6848,17 @@ const createEditor = async ({
6843
6848
  focused: true,
6844
6849
  textInfos
6845
6850
  };
6846
- set$b(id, emptyEditor, newEditor4);
6851
+ set$a(id, emptyEditor, newEditor4);
6847
6852
  const completionsOnTypeRaw = await get$3('editor.completionsOnType');
6848
6853
  const completionsOnType = Boolean(completionsOnTypeRaw);
6849
- set$b(id, emptyEditor, {
6854
+ set$a(id, emptyEditor, {
6850
6855
  ...newEditor4,
6851
6856
  completionsOnType
6852
6857
  });
6853
6858
  };
6854
6859
 
6855
6860
  const createStandaloneEditor = async ({
6861
+ applicationId,
6856
6862
  assetDir,
6857
6863
  charWidth,
6858
6864
  content,
@@ -6873,11 +6879,10 @@ const createStandaloneEditor = async ({
6873
6879
  x,
6874
6880
  y
6875
6881
  }) => {
6876
- createEditor2(id, uri, x, y, width, height, platform, assetDir);
6882
+ createEditor2(id, uri, x, y, width, height, platform, assetDir, undefined, undefined, undefined, applicationId);
6877
6883
  const createdEditor = get$8(id).newState;
6878
6884
  await loadTokenizer(languageId, tokenizePath);
6879
- const tokenizerId = createdEditor.tokenizerId + 1;
6880
- set$6(tokenizerId, getTokenizer(languageId));
6885
+ const tokenizerId = register(getTokenizer(languageId));
6881
6886
  const configuredEditor = {
6882
6887
  ...createdEditor,
6883
6888
  charWidth,
@@ -6922,7 +6927,7 @@ const createStandaloneEditor = async ({
6922
6927
  selectionInfos
6923
6928
  };
6924
6929
  if (!createdEditor.lifecycle?.disposed) {
6925
- set$b(id, createdEditor, finalEditor);
6930
+ set$a(id, createdEditor, finalEditor);
6926
6931
  }
6927
6932
  };
6928
6933
 
@@ -7425,7 +7430,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
7425
7430
  };
7426
7431
  if (fullFocus) {
7427
7432
  // Staging changes pending state; only rendering may advance the mounted baseline.
7428
- set$b(editor.uid, get$8(editor.uid)?.oldState || editor, stagedEditor);
7433
+ set$a(editor.uid, get$8(editor.uid)?.oldState || editor, stagedEditor);
7429
7434
  }
7430
7435
  const newState = await newStateGenerator(initialState, editor.uid);
7431
7436
  if (!newState) {
@@ -7435,7 +7440,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
7435
7440
  if (fullFocus) {
7436
7441
  const latestEditor = getLatestEditor(editor.uid, stagedEditor);
7437
7442
  if (latestEditor === stagedEditor) {
7438
- set$b(editor.uid, get$8(editor.uid)?.oldState || editor, editor);
7443
+ set$a(editor.uid, get$8(editor.uid)?.oldState || editor, editor);
7439
7444
  }
7440
7445
  return latestEditor === stagedEditor ? editor : latestEditor;
7441
7446
  }
@@ -7456,7 +7461,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
7456
7461
  } : currentEditor;
7457
7462
  const hydratedEditor = hydrateWidget(latestEditor, widgetId, widgetUid, latestState);
7458
7463
  if (hydratedEditor !== latestEditor) {
7459
- set$b(editor.uid, get$8(editor.uid)?.oldState || editor, hydratedEditor);
7464
+ set$a(editor.uid, get$8(editor.uid)?.oldState || editor, hydratedEditor);
7460
7465
  }
7461
7466
  return hydratedEditor;
7462
7467
  }
@@ -8562,7 +8567,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, _isErro
8562
8567
  widgetRevision: next(editor.uid),
8563
8568
  widgets: removeEditorWidget(latestEditor.widgets, Message)
8564
8569
  };
8565
- set$b(editor.uid, latestEditor, editorWithoutMessage);
8570
+ set$a(editor.uid, latestEditor, editorWithoutMessage);
8566
8571
  await invoke$e('Editor.renderPending', editor.uid);
8567
8572
  }, editor.messageDelay ?? defaultMessageDelay);
8568
8573
  set$3(editor.uid, {
@@ -8756,7 +8761,7 @@ const refresh = async request => {
8756
8761
  if (!isCurrent(latest?.newState, snapshot)) {
8757
8762
  return false;
8758
8763
  }
8759
- set$b(snapshot.uid, latest.oldState, next);
8764
+ set$a(snapshot.uid, latest.oldState, next);
8760
8765
  return true;
8761
8766
  });
8762
8767
  if (changed) {
@@ -8838,107 +8843,110 @@ const saveAfterDelay = async (uid, token) => {
8838
8843
  // TODO wrap commands globally, not per editor
8839
8844
  // TODO only store editor state in editor worker, not in renderer worker also
8840
8845
 
8841
- const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true) => async (uid, ...args) => {
8842
- return enqueue(uid, async () => {
8843
- const oldInstance = get$8(uid);
8844
- if (!oldInstance) {
8845
- return undefined;
8846
- }
8847
- const state = oldInstance.newState;
8848
- const {
8849
- cursorUndoStack,
8850
- endOfLine,
8851
- initial,
8852
- insertSpaces,
8853
- isSelecting,
8854
- lifecycle,
8855
- lines,
8856
- modified,
8857
- redoStack,
8858
- selections,
8859
- undoStack,
8860
- uri
8861
- } = state;
8862
- const commandResult = await fn(state, ...args);
8863
- let newEditor = !preservesTypingCoalescing && commandResult.canCoalesceTyping ? {
8864
- ...commandResult,
8865
- canCoalesceTyping: false
8866
- } : commandResult;
8867
- if (lines !== newEditor.lines && newEditor.cursorUndoStack?.length) {
8868
- newEditor = {
8869
- ...newEditor,
8870
- cursorUndoStack: []
8871
- };
8872
- } else if (selections && newEditor.selections && !isSelecting && newEditor.cursorUndoStack === cursorUndoStack && (!selectionsEqual(selections, newEditor.selections) || newEditor.isSelecting)) {
8873
- const previousCursorUndoStack = cursorUndoStack || [];
8874
- newEditor = {
8875
- ...newEditor,
8876
- cursorUndoStack: [...previousCursorUndoStack.slice(1 - cursorUndoLimit), new Uint32Array(selections)]
8877
- };
8878
- }
8879
- if (state === newEditor || !get$8(uid) || lifecycle?.disposed || get$8(uid).newState.lifecycle !== lifecycle) {
8880
- return returnState ? newEditor : undefined;
8881
- }
8882
- const deferGutterDecorations = !initial && uri === newEditor.uri && lines !== newEditor.lines && Boolean(newEditor.lifecycle);
8883
- const newEditorWithDerivedState = await updateDerivedState(state, newEditor, deferGutterDecorations);
8884
- if (!get$8(uid) || lifecycle?.disposed || get$8(uid).newState.lifecycle !== lifecycle) {
8885
- return returnState ? newEditorWithDerivedState : undefined;
8886
- }
8887
- // Another command can commit before the renderer consumes this edit.
8888
- // Keep its last rendered baseline, including renders completed while we awaited derived state.
8889
- const renderedState = get$8(uid)?.oldState ?? oldInstance.oldState;
8890
- set$b(uid, renderedState, newEditorWithDerivedState);
8891
- await dispose$3();
8892
- if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
8893
- void editorDiagnosticEffect.apply(newEditorWithDerivedState);
8894
- }
8895
- const finalEditor = newEditorWithDerivedState;
8896
- if (deferGutterDecorations) {
8897
- schedule(finalEditor);
8898
- }
8899
- await notifyEditorStatusChange(state, finalEditor);
8900
- if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
8901
- for (const key of getKeys$2()) {
8902
- const otherUid = Number(key);
8903
- const instance = get$8(otherUid);
8904
- const editor = instance?.newState;
8905
- if (otherUid === uid || !instance || !editor || editor.initial || editor.uri !== finalEditor.uri || editor.applicationId !== finalEditor.applicationId) {
8906
- continue;
8907
- }
8908
- const synchronizedEditor = await updateDerivedState(editor, {
8909
- ...editor,
8910
- decorations: finalEditor.decorations,
8911
- diagnostics: finalEditor.diagnostics,
8912
- endOfLine: finalEditor.endOfLine,
8913
- incrementalEdits: emptyIncrementalEdits,
8914
- insertSpaces: finalEditor.insertSpaces,
8915
- invalidStartIndex: Math.min(editor.invalidStartIndex, finalEditor.invalidStartIndex),
8916
- lines: finalEditor.lines,
8917
- modified: finalEditor.modified,
8918
- redoStack: finalEditor.redoStack,
8919
- undoStack: finalEditor.undoStack,
8920
- visualDecorations: finalEditor.visualDecorations
8921
- }, deferGutterDecorations);
8922
- const latest = get$8(otherUid);
8923
- if (!latest || editor.lifecycle?.disposed || latest.newState.lifecycle !== editor.lifecycle) {
8924
- continue;
8925
- }
8926
- set$b(otherUid, latest.oldState, synchronizedEditor);
8927
- if (deferGutterDecorations) {
8928
- schedule(synchronizedEditor);
8929
- }
8930
- if (editorDiagnosticEffect.isActive(editor, synchronizedEditor)) {
8931
- void editorDiagnosticEffect.apply(synchronizedEditor);
8846
+ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true) => {
8847
+ const command = async (uid, ...args) => {
8848
+ return enqueue(uid, async () => {
8849
+ const oldInstance = get$8(uid);
8850
+ if (!oldInstance) {
8851
+ return undefined;
8852
+ }
8853
+ const state = oldInstance.newState;
8854
+ const {
8855
+ cursorUndoStack,
8856
+ endOfLine,
8857
+ initial,
8858
+ insertSpaces,
8859
+ isSelecting,
8860
+ lifecycle,
8861
+ lines,
8862
+ modified,
8863
+ redoStack,
8864
+ selections,
8865
+ undoStack,
8866
+ uri
8867
+ } = state;
8868
+ const commandResult = await fn(state, ...args);
8869
+ let newEditor = !preservesTypingCoalescing && commandResult.canCoalesceTyping ? {
8870
+ ...commandResult,
8871
+ canCoalesceTyping: false
8872
+ } : commandResult;
8873
+ if (lines !== newEditor.lines && newEditor.cursorUndoStack?.length) {
8874
+ newEditor = {
8875
+ ...newEditor,
8876
+ cursorUndoStack: []
8877
+ };
8878
+ } else if (selections && newEditor.selections && !isSelecting && newEditor.cursorUndoStack === cursorUndoStack && (!selectionsEqual(selections, newEditor.selections) || newEditor.isSelecting)) {
8879
+ const previousCursorUndoStack = cursorUndoStack || [];
8880
+ newEditor = {
8881
+ ...newEditor,
8882
+ cursorUndoStack: [...previousCursorUndoStack.slice(1 - cursorUndoLimit), new Uint32Array(selections)]
8883
+ };
8884
+ }
8885
+ if (state === newEditor || !get$8(uid) || lifecycle?.disposed || get$8(uid).newState.lifecycle !== lifecycle) {
8886
+ return returnState ? newEditor : undefined;
8887
+ }
8888
+ const deferGutterDecorations = !initial && uri === newEditor.uri && lines !== newEditor.lines && Boolean(newEditor.lifecycle);
8889
+ const newEditorWithDerivedState = await updateDerivedState(state, newEditor, deferGutterDecorations);
8890
+ if (!get$8(uid) || lifecycle?.disposed || get$8(uid).newState.lifecycle !== lifecycle) {
8891
+ return returnState ? newEditorWithDerivedState : undefined;
8892
+ }
8893
+ // Another command can commit before the renderer consumes this edit.
8894
+ // Keep its last rendered baseline, including renders completed while we awaited derived state.
8895
+ const renderedState = get$8(uid)?.oldState ?? oldInstance.oldState;
8896
+ set$a(uid, renderedState, newEditorWithDerivedState);
8897
+ await dispose$3();
8898
+ if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
8899
+ void editorDiagnosticEffect.apply(newEditorWithDerivedState);
8900
+ }
8901
+ const finalEditor = newEditorWithDerivedState;
8902
+ if (deferGutterDecorations) {
8903
+ schedule(finalEditor);
8904
+ }
8905
+ await notifyEditorStatusChange(state, finalEditor);
8906
+ if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
8907
+ for (const key of getKeys$2()) {
8908
+ const otherUid = Number(key);
8909
+ const instance = get$8(otherUid);
8910
+ const editor = instance?.newState;
8911
+ if (otherUid === uid || !instance || !editor || editor.initial || editor.uri !== finalEditor.uri || editor.applicationId !== finalEditor.applicationId) {
8912
+ continue;
8913
+ }
8914
+ const synchronizedEditor = await updateDerivedState(editor, {
8915
+ ...editor,
8916
+ decorations: finalEditor.decorations,
8917
+ diagnostics: finalEditor.diagnostics,
8918
+ endOfLine: finalEditor.endOfLine,
8919
+ incrementalEdits: emptyIncrementalEdits,
8920
+ insertSpaces: finalEditor.insertSpaces,
8921
+ invalidStartIndex: Math.min(editor.invalidStartIndex, finalEditor.invalidStartIndex),
8922
+ lines: finalEditor.lines,
8923
+ modified: finalEditor.modified,
8924
+ redoStack: finalEditor.redoStack,
8925
+ undoStack: finalEditor.undoStack,
8926
+ visualDecorations: finalEditor.visualDecorations
8927
+ }, deferGutterDecorations);
8928
+ const latest = get$8(otherUid);
8929
+ if (!latest || editor.lifecycle?.disposed || latest.newState.lifecycle !== editor.lifecycle) {
8930
+ continue;
8931
+ }
8932
+ set$a(otherUid, latest.oldState, synchronizedEditor);
8933
+ if (deferGutterDecorations) {
8934
+ schedule(synchronizedEditor);
8935
+ }
8936
+ if (editorDiagnosticEffect.isActive(editor, synchronizedEditor)) {
8937
+ void editorDiagnosticEffect.apply(synchronizedEditor);
8938
+ }
8932
8939
  }
8933
8940
  }
8934
- }
8935
- if (lines !== finalEditor.lines && !isUntitledFile(finalEditor.uri)) {
8936
- schedule$1(uid, token => saveAfterDelay(uid, token));
8937
- } else if (modified && !finalEditor.modified) {
8938
- dispose$4(uid);
8939
- }
8940
- return returnState ? finalEditor : undefined;
8941
- });
8941
+ if (lines !== finalEditor.lines && !isUntitledFile(finalEditor.uri)) {
8942
+ schedule$1(uid, token => saveAfterDelay(uid, token));
8943
+ } else if (modified && !finalEditor.modified) {
8944
+ dispose$4(uid);
8945
+ }
8946
+ return returnState ? finalEditor : undefined;
8947
+ });
8948
+ };
8949
+ return command;
8942
8950
  };
8943
8951
  const wrapFocusCommand$1 = (fn, returnState = true) => {
8944
8952
  const command = wrapCommand$1((editor, widgetRevision) => {
@@ -8947,18 +8955,19 @@ const wrapFocusCommand$1 = (fn, returnState = true) => {
8947
8955
  }
8948
8956
  return fn(editor);
8949
8957
  }, false, returnState);
8950
- return uid => {
8958
+ const focusCommand = uid => {
8951
8959
  // DOM focus events can arrive while a queued command is still opening a widget.
8952
8960
  const widgetRevision = get$8(uid)?.newState.widgetRevision;
8953
8961
  return command(uid, widgetRevision);
8954
8962
  };
8963
+ return focusCommand;
8955
8964
  };
8956
8965
 
8957
8966
  // Mouse positions are replaceable; edits and explicit navigation remain ordered.
8958
8967
  // Check before starting provider work and again before committing its result.
8959
8968
  const wrapLatestCommand$1 = (fn, returnState = true) => {
8960
8969
  const latest = new Map();
8961
- return async (uid, ...args) => {
8970
+ const latestCommand = async (uid, ...args) => {
8962
8971
  const token = {};
8963
8972
  latest.set(uid, token);
8964
8973
  const command = wrapCommand$1(async editor => {
@@ -8972,12 +8981,13 @@ const wrapLatestCommand$1 = (fn, returnState = true) => {
8972
8981
  if (latest.get(uid) === token) latest.delete(uid);
8973
8982
  }
8974
8983
  };
8984
+ return latestCommand;
8975
8985
  };
8976
8986
 
8977
8987
  // Optional provider work must not hold the editing queue while another worker responds.
8978
8988
  const wrapDeferredCommand$1 = (fn, returnState = true) => {
8979
8989
  const apply = wrapCommand$1((editor, snapshot, result) => merge(editor, snapshot, result), false, returnState);
8980
- return async (uid, ...args) => {
8990
+ const deferredCommand = async (uid, ...args) => {
8981
8991
  const snapshot = await enqueue(uid, async () => get$8(uid)?.newState);
8982
8992
  if (!snapshot) {
8983
8993
  return undefined;
@@ -8985,6 +8995,7 @@ const wrapDeferredCommand$1 = (fn, returnState = true) => {
8985
8995
  const result = await fn(snapshot, ...args);
8986
8996
  return apply(uid, snapshot, result);
8987
8997
  };
8998
+ return deferredCommand;
8988
8999
  };
8989
9000
 
8990
9001
  // TODO maybe use a separate worker for bulk edits and bulk edit history
@@ -11584,7 +11595,7 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
11584
11595
  widgetRevision: next(editorUid),
11585
11596
  widgets: removeEditorWidget(latestEditor.widgets, Hover)
11586
11597
  };
11587
- set$b(editorUid, latestEditor, newEditor);
11598
+ set$a(editorUid, latestEditor, newEditor);
11588
11599
  await invoke$e('Editor.renderPending', editorUid);
11589
11600
  }, editorHoverDismissDelay);
11590
11601
  set$5(editorUid, {
@@ -11994,7 +12005,7 @@ const showHover = async (editor, position, token) => {
11994
12005
  if (latestEditor === newEditor || !latestInstance || latestInstance.newState !== latestEditor || get$2().token !== token) {
11995
12006
  return;
11996
12007
  }
11997
- set$b(editor.uid, latestInstance.oldState, newEditor);
12008
+ set$a(editor.uid, latestInstance.oldState, newEditor);
11998
12009
  await invoke$e('Editor.renderPending', editor.uid);
11999
12010
  };
12000
12011
 
@@ -12256,7 +12267,7 @@ const continueScrollingAndMovingSelection = async editorUid => {
12256
12267
  }
12257
12268
  return;
12258
12269
  }
12259
- set$b(editor.uid, editor, derivedEditor);
12270
+ set$a(editor.uid, editor, derivedEditor);
12260
12271
  await invoke$e('Editor.renderPending', editor.uid);
12261
12272
  if (derivedEditor.hasListener) {
12262
12273
  requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
@@ -12969,7 +12980,7 @@ const updateEditor = async (editorUid, editor, newEditor) => {
12969
12980
  return;
12970
12981
  }
12971
12982
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
12972
- set$b(editorUid, editor, newEditorWithDerivedState);
12983
+ set$a(editorUid, editor, newEditorWithDerivedState);
12973
12984
  };
12974
12985
  const applyDocumentEdits = async (editorUid, edits) => {
12975
12986
  const editor = getEditor$1(editorUid);
@@ -13019,7 +13030,7 @@ const launch = async () => {
13019
13030
  return;
13020
13031
  }
13021
13032
  const rpc = await launchFindWidgetWorker();
13022
- set$k(rpcId, rpc);
13033
+ set$j(rpcId, rpc);
13023
13034
  };
13024
13035
  const invoke$4 = async (method, ...params) => {
13025
13036
  const rpc = get$9(rpcId);
@@ -13150,7 +13161,7 @@ const createFn = (key, name, widgetId) => {
13150
13161
  const latestAfterInvoke = get$8(editor.uid).newState;
13151
13162
  const latestChildIndex = latestAfterInvoke.widgets.findIndex(isWidget);
13152
13163
  if (latestChildIndex === -1) {
13153
- set$b(editor.uid, editor, latestAfterInvoke);
13164
+ set$a(editor.uid, editor, latestAfterInvoke);
13154
13165
  await dispose$3();
13155
13166
  return latestAfterInvoke;
13156
13167
  }
@@ -13164,7 +13175,7 @@ const createFn = (key, name, widgetId) => {
13164
13175
  widgetRevision,
13165
13176
  widgets: removeEditorWidget(latest.widgets, widgetId)
13166
13177
  };
13167
- set$b(editor.uid, latest, newEditor);
13178
+ set$a(editor.uid, latest, newEditor);
13168
13179
  return newEditor;
13169
13180
  }
13170
13181
  const newState = {
@@ -13172,7 +13183,7 @@ const createFn = (key, name, widgetId) => {
13172
13183
  commands
13173
13184
  };
13174
13185
  const newEditor = updateWidget(latest, widgetId, newState);
13175
- set$b(editor.uid, editor, newEditor);
13186
+ set$a(editor.uid, editor, newEditor);
13176
13187
  return newEditor;
13177
13188
  };
13178
13189
  return fn;
@@ -14230,13 +14241,9 @@ const setLanguageId = async (editor, languageId, tokenizePath, isExplicit = fals
14230
14241
  languageId
14231
14242
  };
14232
14243
  }
14233
- const {
14234
- tokenizerId
14235
- } = editor;
14236
14244
  await loadTokenizer(languageId, tokenizePath);
14237
14245
  const tokenizer = getTokenizer(languageId);
14238
- const newTokenizerId = tokenizerId + 1;
14239
- set$6(newTokenizerId, tokenizer);
14246
+ const newTokenizerId = register(tokenizer);
14240
14247
  return {
14241
14248
  ...editor,
14242
14249
  explicitLanguageId: isExplicit ? languageId : editor.explicitLanguageId,
@@ -16262,7 +16269,7 @@ const setSelections2 = async (editorUid, selections) => {
16262
16269
  if (!current || lifecycle?.disposed || current.newState.lifecycle !== lifecycle) {
16263
16270
  return;
16264
16271
  }
16265
- set$b(editorUid, current.oldState, newEditorWithDerivedState);
16272
+ set$a(editorUid, current.oldState, newEditorWithDerivedState);
16266
16273
  });
16267
16274
  };
16268
16275
  const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
@@ -16287,7 +16294,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
16287
16294
  widgets: newWidgets
16288
16295
  };
16289
16296
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
16290
- set$b(editorUid, editor, newEditorWithDerivedState);
16297
+ set$a(editorUid, editor, newEditorWithDerivedState);
16291
16298
  await setFocus(FocusEditorText);
16292
16299
  if (unsetAdditionalFocus$1) {
16293
16300
  await unsetAdditionalFocus(unsetAdditionalFocus$1);
@@ -16972,7 +16979,7 @@ const handleBeforeInput = (editor, inputType, data) => {
16972
16979
  };
16973
16980
 
16974
16981
  // These commands have renderer-owned effects in addition to editor state updates.
16975
- const rendererCommands = new Set(['ColorPicker.handleSliderKeyDown', 'handleFocus', 'handleUriChange', 'handleWorkspaceRefresh', 'hotReload', 'loadContent', 'loadContentLater', 'refreshGutterDecorationsAll', 'renderPending', 'setLanguageId', 'showOverlayMessage', 'updateDiagnostics']);
16982
+ const rendererCommands = new Set(['ColorPicker.handleSliderKeyDown', 'handleFocus', 'handleMouseDown', 'handleUriChange', 'handleWorkspaceRefresh', 'hotReload', 'loadContent', 'loadContentLater', 'refreshGutterDecorationsAll', 'renderPending', 'setLanguageId', 'showOverlayMessage', 'updateDiagnostics']);
16976
16983
  const createCommandMap = commands => ({
16977
16984
  async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
16978
16985
  if (rendererCommands.has(command)) {
@@ -17022,7 +17029,7 @@ const handleMessagePort = async (port, rpcId) => {
17022
17029
  messagePort: port
17023
17030
  });
17024
17031
  if (rpcId) {
17025
- set$k(rpcId, rpc);
17032
+ set$j(rpcId, rpc);
17026
17033
  await initializeListener(rpcId);
17027
17034
  }
17028
17035
  };
@@ -17461,7 +17468,7 @@ const hotReload = async () => {
17461
17468
  await relaunchWorkers();
17462
17469
  const newEditors = await restoreWidgetState(keys, savedStates);
17463
17470
  for (const editor of newEditors) {
17464
- set$b(editor.newState.uid, editor.oldState, editor.newState);
17471
+ set$a(editor.newState.uid, editor.oldState, editor.newState);
17465
17472
  }
17466
17473
 
17467
17474
  // TODO ask renderer worker to rerender all editors
@@ -17499,7 +17506,7 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
17499
17506
  if (syntaxHighlightingEnabled) {
17500
17507
  setEnabled$1(true);
17501
17508
  const syntaxRpc = await createSyntaxHighlightingWorkerRpc();
17502
- set$9(syntaxRpc);
17509
+ set$8(syntaxRpc);
17503
17510
  }
17504
17511
  if (syncIncremental) {
17505
17512
  setEnabled(true);
@@ -17807,8 +17814,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
17807
17814
  const tokenizePath = getTokenizePath(languages, computedLanguageId);
17808
17815
  await loadTokenizer(computedLanguageId, tokenizePath);
17809
17816
  const tokenizer = getTokenizer(computedLanguageId);
17810
- const newTokenizerId = state.tokenizerId + 1;
17811
- set$6(newTokenizerId, tokenizer);
17817
+ const newTokenizerId = register(tokenizer);
17812
17818
  effectiveEditor.tokenizerId = newTokenizerId;
17813
17819
  }
17814
17820
  const savedHistory = existingEditor ? undefined : getSavedHistory(savedState, content);
@@ -17954,7 +17960,7 @@ const refreshGutterDecorationsAll = async () => {
17954
17960
  if (!latest) {
17955
17961
  continue;
17956
17962
  }
17957
- set$b(editor.id, latest.oldState, {
17963
+ set$a(editor.id, latest.oldState, {
17958
17964
  ...latest.newState,
17959
17965
  gutterDecorations: refreshedEditor.gutterDecorations
17960
17966
  });
@@ -19288,7 +19294,7 @@ const render2 = (uid, _diffResult) => {
19288
19294
  } = editor;
19289
19295
  // Diagnostics can change after the caller calculated its diff in a separate RPC.
19290
19296
  const diffResult = diff(oldState, newState);
19291
- set$b(uid, newState, newState);
19297
+ set$a(uid, newState, newState);
19292
19298
  const commands = applyRender(oldState, newState, diffResult);
19293
19299
  return commands;
19294
19300
  };
@@ -19323,7 +19329,7 @@ const renderDirect = async (uid, preserveFocus) => {
19323
19329
  const latest = get$8(uid);
19324
19330
  if (latest?.newState.lifecycle === newState.lifecycle && latest.oldState === newState) {
19325
19331
  // A rejected queue RPC must not acknowledge patches that never arrived.
19326
- set$b(uid, oldState, latest.newState);
19332
+ set$a(uid, oldState, latest.newState);
19327
19333
  if (oldDom) set$2(uid, oldDom, oldPaths);else dispose$2(uid);
19328
19334
  }
19329
19335
  throw error;
@@ -19453,7 +19459,7 @@ const renderEditor = async id => {
19453
19459
  oldState
19454
19460
  } = instance;
19455
19461
  const commands = [];
19456
- set$b(id, newState, newState);
19462
+ set$a(id, newState, newState);
19457
19463
  for (const item of render$7) {
19458
19464
  if (item.isEqual(oldState, newState)) {
19459
19465
  continue;
@@ -19730,7 +19736,7 @@ const updateDebugInfo = async debugId => {
19730
19736
  ...newState,
19731
19737
  highlightedLine: newInfo.rowIndex
19732
19738
  };
19733
- set$b(key, oldState, newEditor);
19739
+ set$a(key, oldState, newEditor);
19734
19740
  // @ts-ignore
19735
19741
  await invoke$e('Editor.rerender', key);
19736
19742
  };
@@ -19777,7 +19783,7 @@ const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preserv
19777
19783
  const newEditor = await fn(editor, ...args);
19778
19784
  return shouldDismissHover(...args) ? removeHoverFromEditor(newEditor) : newEditor;
19779
19785
  }, preservesTypingCoalescing);
19780
- return async (uid, ...args) => {
19786
+ const typingCommand = async (uid, ...args) => {
19781
19787
  const dismissHover = shouldDismissHover(...args);
19782
19788
  if (dismissHover) {
19783
19789
  clear$2(uid);
@@ -19789,6 +19795,7 @@ const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preserv
19789
19795
  void updateAutomaticCompletionDeferred(uid).then(() => invoke$e('Editor.renderPending', uid)).catch(error => handleError$1(error, 'Failed to open completion widget: '));
19790
19796
  }
19791
19797
  };
19798
+ return typingCommand;
19792
19799
  };
19793
19800
  const deleteLeftCommand = wrapTypingCommand(deleteCharacterLeft, () => false, () => false);
19794
19801
  const typeCommand = wrapTypingCommand(type, () => true, Boolean);
@@ -20120,7 +20127,7 @@ const initializeDragAndDropWorker = async () => {
20120
20127
  commandMap: {},
20121
20128
  send: sendMessagePortToDragAndDropWorker
20122
20129
  });
20123
- set$i(rpc);
20130
+ set$h(rpc);
20124
20131
  };
20125
20132
 
20126
20133
  const initializeErrorWorker = async () => {
@@ -20130,7 +20137,7 @@ const initializeErrorWorker = async () => {
20130
20137
  return sendMessagePortToErrorWorker(port, EditorWorker);
20131
20138
  }
20132
20139
  });
20133
- set$h(rpc);
20140
+ set$g(rpc);
20134
20141
  };
20135
20142
 
20136
20143
  const createExtensionManagementWorkerRpc = async () => {
@@ -20146,7 +20153,7 @@ const createExtensionManagementWorkerRpc = async () => {
20146
20153
  const initializeExtensionManagementWorker = async () => {
20147
20154
  try {
20148
20155
  const rpc = await createExtensionManagementWorkerRpc();
20149
- set$g(rpc);
20156
+ set$f(rpc);
20150
20157
  } catch {
20151
20158
  // ignore
20152
20159
  }
@@ -20161,14 +20168,14 @@ const initializeOpenerWorker = async () => {
20161
20168
  commandMap: {},
20162
20169
  send: send$1
20163
20170
  });
20164
- set$f(rpc);
20171
+ set$e(rpc);
20165
20172
  };
20166
20173
 
20167
20174
  const initializeRendererWorker = async () => {
20168
20175
  const rpc = await create$d({
20169
20176
  commandMap: commandMap
20170
20177
  });
20171
- set$d(rpc);
20178
+ set$c(rpc);
20172
20179
  };
20173
20180
 
20174
20181
  const send = port => {
@@ -20179,7 +20186,7 @@ const initializeTextMeasurementWorker = async () => {
20179
20186
  commandMap: {},
20180
20187
  send
20181
20188
  });
20182
- set$e(rpc);
20189
+ set$d(rpc);
20183
20190
  };
20184
20191
 
20185
20192
  const listen = async () => {
@@ -20189,7 +20196,7 @@ const listen = async () => {
20189
20196
  commandMap: {},
20190
20197
  send: sendMessagePortToDialogWorker
20191
20198
  });
20192
- set$j(dialogRpc);
20199
+ set$i(dialogRpc);
20193
20200
  };
20194
20201
 
20195
20202
  const CodeGeneratorInput = 'CodeGeneratorInput';
@@ -20511,15 +20518,15 @@ const EditorMessageWidget = {
20511
20518
  };
20512
20519
 
20513
20520
  const registerWidgets = () => {
20514
- set$a(ColorPicker$2, EditorColorPickerWidget);
20515
- set$a(Completion, EditorCompletionWidget);
20516
- set$a(CompletionDetail, EditorCompletionDetailWidget);
20517
- set$a(Find, EditorFindWidget);
20518
- set$a(Hover, EditorHoverWidget);
20519
- set$a(Message, EditorMessageWidget);
20520
- set$a(Rename$1, EditorRenameWidget);
20521
- set$a(SourceAction$1, EditorSourceActionWidget);
20522
- set$a(CodeGenerator, EditorCodeGeneratorWidget);
20521
+ set$9(ColorPicker$2, EditorColorPickerWidget);
20522
+ set$9(Completion, EditorCompletionWidget);
20523
+ set$9(CompletionDetail, EditorCompletionDetailWidget);
20524
+ set$9(Find, EditorFindWidget);
20525
+ set$9(Hover, EditorHoverWidget);
20526
+ set$9(Message, EditorMessageWidget);
20527
+ set$9(Rename$1, EditorRenameWidget);
20528
+ set$9(SourceAction$1, EditorSourceActionWidget);
20529
+ set$9(CodeGenerator, EditorCodeGeneratorWidget);
20523
20530
  };
20524
20531
 
20525
20532
  const handleUnhandledRejection = event => {