@lvce-editor/editor-worker 19.17.3 → 19.18.0

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.
@@ -1225,7 +1225,7 @@ const createMockRpc = ({
1225
1225
  };
1226
1226
 
1227
1227
  const rpcs = Object.create(null);
1228
- const set$f = (id, rpc) => {
1228
+ const set$h = (id, rpc) => {
1229
1229
  rpcs[id] = rpc;
1230
1230
  };
1231
1231
  const get$8 = id => {
@@ -1258,7 +1258,7 @@ const create$9 = rpcId => {
1258
1258
  const mockRpc = createMockRpc({
1259
1259
  commandMap
1260
1260
  });
1261
- set$f(rpcId, mockRpc);
1261
+ set$h(rpcId, mockRpc);
1262
1262
  // @ts-ignore
1263
1263
  mockRpc[Symbol.dispose] = () => {
1264
1264
  remove$8(rpcId);
@@ -1267,7 +1267,7 @@ const create$9 = rpcId => {
1267
1267
  return mockRpc;
1268
1268
  },
1269
1269
  set(rpc) {
1270
- set$f(rpcId, rpc);
1270
+ set$h(rpcId, rpc);
1271
1271
  }
1272
1272
  };
1273
1273
  };
@@ -1281,6 +1281,7 @@ const ClientX = 'event.clientX';
1281
1281
  const ClientY = 'event.clientY';
1282
1282
  const DeltaMode = 'event.deltaMode';
1283
1283
  const DeltaY = 'event.deltaY';
1284
+ const Key = 'event.key';
1284
1285
 
1285
1286
  const Backspace = 1;
1286
1287
  const Tab$1 = 2;
@@ -1339,6 +1340,7 @@ const Electron = 2;
1339
1340
  const CompletionWorker = 301;
1340
1341
  const DebugWorker = 55;
1341
1342
  const EditorWorker = 99;
1343
+ const ErrorWorker = 3308;
1342
1344
  const ExtensionHostWorker = 44;
1343
1345
  const ExtensionManagementWorker = 9006;
1344
1346
  const IconThemeWorker = 7009;
@@ -1346,27 +1348,32 @@ const MarkdownWorker = 300;
1346
1348
  const OpenerWorker = 4561;
1347
1349
  const RendererWorker$1 = 1;
1348
1350
 
1349
- const FocusSelector = 'Viewlet.focusSelector';
1351
+ const FocusSelector$1 = 'Viewlet.focusSelector';
1350
1352
  const SetCss$1 = 'Viewlet.setCss';
1351
1353
  const SetFocusContext$1 = 'Viewlet.setFocusContext';
1352
1354
  const SetPatches = 'Viewlet.setPatches';
1353
1355
 
1354
1356
  const FocusEditorText$1 = 12;
1355
1357
 
1358
+ const {
1359
+ invoke: invoke$g,
1360
+ set: set$g
1361
+ } = create$9(ErrorWorker);
1362
+
1356
1363
  const {
1357
1364
  invoke: invoke$f,
1358
- set: set$e
1365
+ set: set$f
1359
1366
  } = create$9(ExtensionHostWorker);
1360
1367
 
1361
1368
  const ExtensionHost = {
1362
1369
  __proto__: null,
1363
1370
  invoke: invoke$f,
1364
- set: set$e
1371
+ set: set$f
1365
1372
  };
1366
1373
 
1367
1374
  const {
1368
1375
  invoke: invoke$e,
1369
- set: set$d
1376
+ set: set$e
1370
1377
  } = create$9(ExtensionManagementWorker);
1371
1378
  const getLanguages$1 = (platform, assetDir) => {
1372
1379
  return invoke$e('Extensions.getLanguages', platform, assetDir);
@@ -1374,7 +1381,7 @@ const getLanguages$1 = (platform, assetDir) => {
1374
1381
 
1375
1382
  const {
1376
1383
  invoke: invoke$d,
1377
- set: set$c
1384
+ set: set$d
1378
1385
  } = create$9(OpenerWorker);
1379
1386
  const openUrl = async (url, platform) => {
1380
1387
  return invoke$d('Open.openUrl', url, platform);
@@ -1382,13 +1389,13 @@ const openUrl = async (url, platform) => {
1382
1389
 
1383
1390
  const {
1384
1391
  invoke: invoke$c,
1385
- set: set$b
1392
+ set: set$c
1386
1393
  } = create$9(IconThemeWorker);
1387
1394
 
1388
1395
  const {
1389
1396
  invoke: invoke$b,
1390
1397
  invokeAndTransfer,
1391
- set: set$a
1398
+ set: set$b
1392
1399
  } = create$9(RendererWorker$1);
1393
1400
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1394
1401
  number(uid);
@@ -1401,6 +1408,10 @@ const sendMessagePortToOpenerWorker = async (port, rpcId) => {
1401
1408
  const command = 'HandleMessagePort.handleMessagePort';
1402
1409
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
1403
1410
  };
1411
+ const sendMessagePortToErrorWorker = async (port, rpcId) => {
1412
+ const command = 'Errors.handleMessagePort';
1413
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
1414
+ };
1404
1415
  const readFile = async uri => {
1405
1416
  return invoke$b('FileSystem.readFile', uri);
1406
1417
  };
@@ -1448,25 +1459,26 @@ const RendererWorker = {
1448
1459
  openUri,
1449
1460
  readClipBoardText,
1450
1461
  readFile,
1462
+ sendMessagePortToErrorWorker,
1451
1463
  sendMessagePortToExtensionHostWorker,
1452
1464
  sendMessagePortToExtensionManagementWorker: sendMessagePortToExtensionManagementWorker$1,
1453
1465
  sendMessagePortToOpenerWorker,
1454
1466
  sendMessagePortToSyntaxHighlightingWorker: sendMessagePortToSyntaxHighlightingWorker$1,
1455
1467
  sendMessagePortToTextMeasurementWorker,
1456
- set: set$a,
1468
+ set: set$b,
1457
1469
  showContextMenu2,
1458
1470
  writeClipBoardText
1459
1471
  };
1460
1472
 
1461
1473
  const {
1462
1474
  invoke: invoke$a,
1463
- set: set$9
1475
+ set: set$a
1464
1476
  } = create$9(MarkdownWorker);
1465
1477
 
1466
1478
  const SyntaxHighlightingWorker = {
1467
1479
  __proto__: null,
1468
1480
  invoke: invoke$a,
1469
- set: set$9
1481
+ set: set$a
1470
1482
  };
1471
1483
 
1472
1484
  const createLazyRpc = rpcId => {
@@ -1474,7 +1486,7 @@ const createLazyRpc = rpcId => {
1474
1486
  let factory;
1475
1487
  const createRpc = async () => {
1476
1488
  const rpc = await factory();
1477
- set$f(rpcId, rpc);
1489
+ set$h(rpcId, rpc);
1478
1490
  };
1479
1491
  const ensureRpc = async () => {
1480
1492
  if (!rpcPromise) {
@@ -1540,12 +1552,12 @@ const launchColorPickerWorker = async () => {
1540
1552
  return launchWorker(name, url);
1541
1553
  };
1542
1554
 
1543
- const state$d = {};
1555
+ const state$c = {};
1544
1556
  const getOrCreate$3 = () => {
1545
- if (!state$d.workerPromise) {
1546
- state$d.workerPromise = launchColorPickerWorker();
1557
+ if (!state$c.workerPromise) {
1558
+ state$c.workerPromise = launchColorPickerWorker();
1547
1559
  }
1548
- return state$d.workerPromise;
1560
+ return state$c.workerPromise;
1549
1561
  };
1550
1562
  const invoke$9 = async (method, ...params) => {
1551
1563
  const worker = await getOrCreate$3();
@@ -1572,6 +1584,7 @@ const loadContent$3 = async (state, parentUid) => {
1572
1584
 
1573
1585
  const editorStates = create$j();
1574
1586
  const {
1587
+ dispose: dispose$1,
1575
1588
  getCommandIds,
1576
1589
  registerCommands,
1577
1590
  wrapGetter
@@ -1583,7 +1596,7 @@ const getKeys$2 = () => {
1583
1596
  const keys = editorStates.getKeys();
1584
1597
  return keys.map(String);
1585
1598
  };
1586
- const set$8 = (id, oldEditor, newEditor) => {
1599
+ const set$9 = (id, oldEditor, newEditor) => {
1587
1600
  editorStates.set(id, oldEditor, newEditor);
1588
1601
  };
1589
1602
 
@@ -1684,7 +1697,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
1684
1697
  x,
1685
1698
  y
1686
1699
  };
1687
- set$8(id, editor, editor);
1700
+ set$9(id, editor, editor);
1688
1701
  };
1689
1702
 
1690
1703
  // TODO use numeric enum
@@ -1707,7 +1720,7 @@ const Rename = 'rename';
1707
1720
  const ToggleBlockComment$1 = 'toggleBlockComment';
1708
1721
 
1709
1722
  const map$1 = Object.create(null);
1710
- const set$7 = (id, widget) => {
1723
+ const set$8 = (id, widget) => {
1711
1724
  map$1[id] = widget;
1712
1725
  };
1713
1726
  const get$6 = id => {
@@ -1755,6 +1768,7 @@ const clamp = (num, min, max) => {
1755
1768
  };
1756
1769
 
1757
1770
  const Link$1 = 'Link';
1771
+ const EditorGoToDefinitionLink = 'EditorGoToDefinitionLink';
1758
1772
  const Function = 'Function';
1759
1773
  const Parameter = 'Parameter';
1760
1774
  const Type = 'Type';
@@ -1762,6 +1776,7 @@ const VariableName = 'VariableName';
1762
1776
  const Class = 'Class';
1763
1777
 
1764
1778
  const Link = 1;
1779
+ const DefinitionLink = 2;
1765
1780
  const Ts2816 = 2816;
1766
1781
  const Ts2817 = 2817;
1767
1782
  const Ts2824 = 2824;
@@ -1802,6 +1817,8 @@ const Ts272 = 272;
1802
1817
 
1803
1818
  const getDecorationClassName = type => {
1804
1819
  switch (type) {
1820
+ case DefinitionLink:
1821
+ return EditorGoToDefinitionLink;
1805
1822
  case Link:
1806
1823
  return Link$1;
1807
1824
  case Ts1024:
@@ -1859,7 +1876,7 @@ const getInitialLineState = initialLineState => {
1859
1876
  return deepCopy(initialLineState);
1860
1877
  };
1861
1878
 
1862
- const state$c = {
1879
+ const state$b = {
1863
1880
  warned: []
1864
1881
  };
1865
1882
  const flattenTokensArray = tokens => {
@@ -1871,10 +1888,10 @@ const flattenTokensArray = tokens => {
1871
1888
  return flattened;
1872
1889
  };
1873
1890
  const warnDeprecatedArrayReturn = (languageId, fn) => {
1874
- if (state$c.warned.includes(fn)) {
1891
+ if (state$b.warned.includes(fn)) {
1875
1892
  return;
1876
1893
  }
1877
- state$c.warned.push(fn);
1894
+ state$b.warned.push(fn);
1878
1895
  console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
1879
1896
  };
1880
1897
  const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
@@ -1935,40 +1952,40 @@ const TokenizePlainText = {
1935
1952
  tokenizeLine
1936
1953
  };
1937
1954
 
1938
- const state$b = {
1955
+ const state$a = {
1939
1956
  enabled: false
1940
1957
  };
1941
1958
  const setEnabled$1 = value => {
1942
- state$b.enabled = value;
1959
+ state$a.enabled = value;
1943
1960
  };
1944
1961
  const getEnabled$1 = () => {
1945
- return state$b.enabled;
1962
+ return state$a.enabled;
1946
1963
  };
1947
1964
 
1948
1965
  const {
1949
1966
  invoke: invoke$8,
1950
- set: set$6
1967
+ set: set$7
1951
1968
  } = SyntaxHighlightingWorker;
1952
1969
 
1953
- const state$a = {
1970
+ const state$9 = {
1954
1971
  pending: Object.create(null),
1955
1972
  tokenizePaths: Object.create(null),
1956
1973
  tokenizers: Object.create(null)
1957
1974
  };
1958
1975
  const has = languageId => {
1959
- return Object.hasOwn(state$a.tokenizers, languageId);
1976
+ return Object.hasOwn(state$9.tokenizers, languageId);
1960
1977
  };
1961
- const set$5 = (languageId, tokenizer) => {
1962
- state$a.tokenizers[languageId] = tokenizer;
1978
+ const set$6 = (languageId, tokenizer) => {
1979
+ state$9.tokenizers[languageId] = tokenizer;
1963
1980
  };
1964
1981
  const get$5 = languageId => {
1965
- return state$a.tokenizers[languageId];
1982
+ return state$9.tokenizers[languageId];
1966
1983
  };
1967
1984
  const setTokenizePath = (languageId, tokenizePath) => {
1968
- state$a.tokenizePaths[languageId] = tokenizePath;
1985
+ state$9.tokenizePaths[languageId] = tokenizePath;
1969
1986
  };
1970
1987
  const getTokenizePath$1 = languageId => {
1971
- return state$a.tokenizePaths[languageId] || '';
1988
+ return state$9.tokenizePaths[languageId] || '';
1972
1989
  };
1973
1990
  const setTokenizePaths = languages => {
1974
1991
  for (const language of languages) {
@@ -1978,11 +1995,11 @@ const setTokenizePaths = languages => {
1978
1995
  }
1979
1996
  };
1980
1997
  const isPending = languageId => {
1981
- return Object.hasOwn(state$a.pending, languageId);
1998
+ return Object.hasOwn(state$9.pending, languageId);
1982
1999
  };
1983
2000
 
1984
2001
  const tokenMaps = Object.create(null);
1985
- const set$4 = (languageId, tokenMap) => {
2002
+ const set$5 = (languageId, tokenMap) => {
1986
2003
  tokenMaps[languageId] = tokenMap;
1987
2004
  };
1988
2005
  const get$4 = languageId => {
@@ -1998,7 +2015,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
1998
2015
  if (getEnabled$1()) {
1999
2016
  // @ts-ignore
2000
2017
  const tokenMap = await invoke$8('Tokenizer.load', languageId, tokenizePath);
2001
- set$4(languageId, tokenMap);
2018
+ set$5(languageId, tokenMap);
2002
2019
  return;
2003
2020
  }
2004
2021
  try {
@@ -2014,8 +2031,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2014
2031
  console.warn(`tokenizer.TokenMap should be an object in "${tokenizePath}"`);
2015
2032
  return;
2016
2033
  }
2017
- set$4(languageId, tokenizer.TokenMap);
2018
- set$5(languageId, tokenizer);
2034
+ set$5(languageId, tokenizer.TokenMap);
2035
+ set$6(languageId, tokenizer);
2019
2036
  } catch (error) {
2020
2037
  // TODO better error handling
2021
2038
  console.error(error);
@@ -2032,7 +2049,7 @@ const getTokenizer = languageId => {
2032
2049
  };
2033
2050
 
2034
2051
  const tokenizers = Object.create(null);
2035
- const set$3 = (id, value) => {
2052
+ const set$4 = (id, value) => {
2036
2053
  tokenizers[id] = value;
2037
2054
  };
2038
2055
  const get$3 = id => {
@@ -2811,14 +2828,14 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
2811
2828
  };
2812
2829
  };
2813
2830
 
2814
- const state$9 = {
2831
+ const state$8 = {
2815
2832
  enabled: false
2816
2833
  };
2817
2834
  const setEnabled = value => {
2818
- state$9.enabled = value;
2835
+ state$8.enabled = value;
2819
2836
  };
2820
2837
  const getEnabled = () => {
2821
- return state$9.enabled;
2838
+ return state$8.enabled;
2822
2839
  };
2823
2840
 
2824
2841
  // TODO this should be in a separate scrolling module
@@ -3036,7 +3053,7 @@ const getUrlAtOffset = (editor, offset) => {
3036
3053
 
3037
3054
  const EditorChange = 1;
3038
3055
 
3039
- const state$8 = Object.create(null);
3056
+ const state$7 = Object.create(null);
3040
3057
 
3041
3058
  /**
3042
3059
  * Register a listener for a specific event type
@@ -3046,13 +3063,13 @@ const state$8 = Object.create(null);
3046
3063
  const registerListener$1 = (listenerType, rpcId) => {
3047
3064
  number(listenerType);
3048
3065
  number(rpcId);
3049
- if (!Object.hasOwn(state$8, listenerType)) {
3050
- state$8[listenerType] = [];
3066
+ if (!Object.hasOwn(state$7, listenerType)) {
3067
+ state$7[listenerType] = [];
3051
3068
  }
3052
3069
 
3053
3070
  // Avoid duplicate registrations
3054
- if (!state$8[listenerType].includes(rpcId)) {
3055
- state$8[listenerType].push(rpcId);
3071
+ if (!state$7[listenerType].includes(rpcId)) {
3072
+ state$7[listenerType].push(rpcId);
3056
3073
  }
3057
3074
  };
3058
3075
 
@@ -3064,10 +3081,10 @@ const registerListener$1 = (listenerType, rpcId) => {
3064
3081
  const unregisterListener$1 = (listenerType, rpcId) => {
3065
3082
  number(listenerType);
3066
3083
  number(rpcId);
3067
- if (Object.hasOwn(state$8, listenerType)) {
3068
- const index = state$8[listenerType].indexOf(rpcId);
3084
+ if (Object.hasOwn(state$7, listenerType)) {
3085
+ const index = state$7[listenerType].indexOf(rpcId);
3069
3086
  if (index !== -1) {
3070
- state$8[listenerType].splice(index, 1);
3087
+ state$7[listenerType].splice(index, 1);
3071
3088
  }
3072
3089
  }
3073
3090
  };
@@ -3079,7 +3096,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
3079
3096
  */
3080
3097
  const getListeners = listenerType => {
3081
3098
  number(listenerType);
3082
- return state$8[listenerType] || [];
3099
+ return state$7[listenerType] || [];
3083
3100
  };
3084
3101
 
3085
3102
  /**
@@ -3556,7 +3573,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
3556
3573
  ...newEditor,
3557
3574
  decorations: linkDecorations
3558
3575
  };
3559
- set$8(editor.uid, editor, newEditorWithDecorations);
3576
+ set$9(editor.uid, editor, newEditorWithDecorations);
3560
3577
 
3561
3578
  // Notify main-area-worker about modified status change
3562
3579
  if (!editor.modified) {
@@ -3772,7 +3789,7 @@ const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
3772
3789
 
3773
3790
  const {
3774
3791
  invoke: invoke$6,
3775
- set: set$2
3792
+ set: set$3
3776
3793
  } = ExtensionHost;
3777
3794
 
3778
3795
  const getFileExtensionIndex = file => {
@@ -3843,6 +3860,26 @@ const get$2 = async key => {
3843
3860
  return value;
3844
3861
  };
3845
3862
 
3863
+ const logError = async (error, prefix) => {
3864
+ const prettyError = await invoke$g('Errors.prepare', error);
3865
+ await invoke$g('Errors.print', prettyError, prefix);
3866
+ };
3867
+ const logFallback = (error, prefix) => {
3868
+ if (prefix) {
3869
+ console.error(prefix, error);
3870
+ return;
3871
+ }
3872
+ console.error(error);
3873
+ };
3874
+ const handleError$1 = async (error, prefix = '') => {
3875
+ try {
3876
+ await logError(error, prefix);
3877
+ } catch (otherError) {
3878
+ console.warn('ErrorHandling error', otherError);
3879
+ logFallback(error, prefix);
3880
+ }
3881
+ };
3882
+
3846
3883
  const OnDiagnostic = 'onDiagnostic';
3847
3884
  const OnHover = 'onHover';
3848
3885
  const OnTabCompletion = 'onTabCompletion';
@@ -3985,11 +4022,11 @@ const addDiagnostics = async (editor, diagnostics) => {
3985
4022
  visualDecorations
3986
4023
  };
3987
4024
  };
3988
- const handleError$1 = (error, editor) => {
4025
+ const handleError = async (error, editor) => {
3989
4026
  if (error instanceof Error && error.message.includes('No diagnostic provider found')) {
3990
4027
  return editor;
3991
4028
  }
3992
- console.error(`Failed to update diagnostics: ${error}`);
4029
+ await handleError$1(error, 'Failed to update diagnostics: ');
3993
4030
  return editor;
3994
4031
  };
3995
4032
  const getEditorWithDiagnostics = async editor => {
@@ -4000,7 +4037,7 @@ const getEditorWithDiagnostics = async editor => {
4000
4037
  }
4001
4038
  return addDiagnostics(editor, diagnostics);
4002
4039
  } catch (error) {
4003
- return handleError$1(error, editor);
4040
+ return handleError(error, editor);
4004
4041
  }
4005
4042
  };
4006
4043
  const updateDiagnostics = async editor => {
@@ -4011,12 +4048,12 @@ const updateDiagnostics = async editor => {
4011
4048
  return editor;
4012
4049
  }
4013
4050
  const newEditor = await addDiagnostics(latest.newState, diagnostics);
4014
- set$8(editor.id, latest.oldState, newEditor);
4051
+ set$9(editor.id, latest.oldState, newEditor);
4015
4052
  // @ts-ignore
4016
4053
  await invoke$b('Editor.rerender', editor.id);
4017
4054
  return newEditor;
4018
4055
  } catch (error) {
4019
- return handleError$1(error, editor);
4056
+ return handleError(error, editor);
4020
4057
  }
4021
4058
  };
4022
4059
 
@@ -4169,7 +4206,7 @@ const createEditor = async ({
4169
4206
  focused: true,
4170
4207
  textInfos
4171
4208
  };
4172
- set$8(id, emptyEditor, newEditor4);
4209
+ set$9(id, emptyEditor, newEditor4);
4173
4210
 
4174
4211
  // TODO only sync when needed
4175
4212
  // e.g. it might not always be necessary to send text to extension host worker
@@ -4178,7 +4215,7 @@ const createEditor = async ({
4178
4215
  const editorWithDiagnostics = diagnosticsEnabled ? await updateDiagnostics(newEditor4) : newEditor4;
4179
4216
  const completionsOnTypeRaw = await get$2('editor.completionsOnType');
4180
4217
  const completionsOnType = Boolean(completionsOnTypeRaw);
4181
- set$8(id, emptyEditor, {
4218
+ set$9(id, emptyEditor, {
4182
4219
  ...editorWithDiagnostics,
4183
4220
  completionsOnType
4184
4221
  });
@@ -4189,13 +4226,16 @@ const isEqual$3 = (oldState, newState) => {
4189
4226
  };
4190
4227
 
4191
4228
  const isEqual$2 = (oldState, newState) => {
4229
+ if (oldState.focus !== newState.focus) {
4230
+ return false;
4231
+ }
4192
4232
  if (!newState.focused) {
4193
4233
  return true;
4194
4234
  }
4195
4235
  if (!oldState.isSelecting && newState.isSelecting) {
4196
4236
  return false;
4197
4237
  }
4198
- return oldState.focused === newState.focused && oldState.focus === newState.focus;
4238
+ return oldState.focused === newState.focused;
4199
4239
  };
4200
4240
 
4201
4241
  const isEqual$1 = (oldState, newState) => {
@@ -4235,6 +4275,96 @@ const diff2 = uid => {
4235
4275
  return result;
4236
4276
  };
4237
4277
 
4278
+ const addWidget$1 = widget => {
4279
+ const module = get$6(widget.id);
4280
+ if (!module) {
4281
+ throw new Error('unsupported widget');
4282
+ }
4283
+ return module.add(widget);
4284
+ };
4285
+ const renderWidget = widget => {
4286
+ const module = get$6(widget.id);
4287
+ if (!module) {
4288
+ throw new Error('unsupported widget');
4289
+ }
4290
+ return module.render(widget);
4291
+ };
4292
+ const removeWidget$1 = widget => {
4293
+ const module = get$6(widget.id);
4294
+ if (!module) {
4295
+ throw new Error('unsupported widget');
4296
+ }
4297
+ return module.remove(widget);
4298
+ };
4299
+
4300
+ const renderWidgets$1 = (oldState, newState) => {
4301
+ const addedWidgets = [];
4302
+ const changedWidgets = [];
4303
+ const removedWidgets = [];
4304
+ const oldWidgets = oldState.widgets || [];
4305
+ const newWidgets = newState.widgets || [];
4306
+ const oldWidgetMap = Object.create(null);
4307
+ const newWidgetMap = Object.create(null);
4308
+ for (const oldWidget of oldWidgets) {
4309
+ oldWidgetMap[oldWidget.id] = oldWidget;
4310
+ }
4311
+ for (const newWidget of newWidgets) {
4312
+ newWidgetMap[newWidget.id] = newWidget;
4313
+ }
4314
+ for (const oldWidget of oldWidgets) {
4315
+ if (Object.hasOwn(newWidgetMap, oldWidget.id)) {
4316
+ changedWidgets.push(newWidgetMap[oldWidget.id]);
4317
+ } else {
4318
+ removedWidgets.push(oldWidget);
4319
+ }
4320
+ }
4321
+ for (const newWidget of newWidgets) {
4322
+ if (Object.hasOwn(oldWidgetMap, newWidget.id)) ; else {
4323
+ addedWidgets.push(newWidget);
4324
+ }
4325
+ }
4326
+ const addCommands = [];
4327
+ for (const addedWidget of addedWidgets) {
4328
+ const childCommands = addWidget$1(addedWidget);
4329
+ if (childCommands.length > 0) {
4330
+ addCommands.push(...childCommands);
4331
+ }
4332
+ }
4333
+ const changeCommands = [];
4334
+ for (const changedWidget of changedWidgets) {
4335
+ const childCommands = renderWidget(changedWidget);
4336
+ if (childCommands.length > 0) {
4337
+ changeCommands.push(...childCommands);
4338
+ }
4339
+ }
4340
+ const removeCommands = [];
4341
+ for (const removedWidget of removedWidgets) {
4342
+ const childCommands = removeWidget$1(removedWidget);
4343
+ if (childCommands.length > 0) {
4344
+ removeCommands.push(...childCommands);
4345
+ }
4346
+ }
4347
+ const allCommands = [...addCommands, ...changeCommands, ...removeCommands];
4348
+ return allCommands.filter(item => item[0] !== 'Viewlet.setFocusContext');
4349
+ };
4350
+
4351
+ const disposeEditor = async editorUid => {
4352
+ const editor = get$7(editorUid)?.newState;
4353
+ if (!editor) {
4354
+ return [];
4355
+ }
4356
+ for (const widget of editor.widgets) {
4357
+ if (widget.id === ColorPicker$1) {
4358
+ await invoke$9('ColorPicker.dispose', widget.newState.uid);
4359
+ }
4360
+ }
4361
+ const commands = renderWidgets$1(editor, {
4362
+ widgets: []
4363
+ });
4364
+ dispose$1(editorUid);
4365
+ return commands;
4366
+ };
4367
+
4238
4368
  // @ts-ignore
4239
4369
  const getNewSelections$c = selections => {
4240
4370
  const newSelections = [];
@@ -4429,6 +4559,12 @@ const editorReplaceSelections = (editor, replacement, origin) => {
4429
4559
  return replaceRange(editor, selections, replacement, origin);
4430
4560
  };
4431
4561
 
4562
+ const create$8 = () => {
4563
+ return Math.random();
4564
+ };
4565
+
4566
+ const Message = 9;
4567
+
4432
4568
  const getAccurateColumnIndexAscii = async (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth) => {
4433
4569
  for (let i = guess; i < line.length; i++) {
4434
4570
  const width = await measureTextWidth(line.slice(0, i), fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth);
@@ -4442,7 +4578,7 @@ const getAccurateColumnIndexAscii = async (line, guess, averageCharWidth, eventX
4442
4578
  const supported = () => {
4443
4579
  return 'Segmenter' in Intl;
4444
4580
  };
4445
- const create$8 = () => {
4581
+ const create$7 = () => {
4446
4582
  // @ts-ignore
4447
4583
  const segmenter = new Intl.Segmenter();
4448
4584
  return {
@@ -4477,7 +4613,7 @@ const create$8 = () => {
4477
4613
  };
4478
4614
 
4479
4615
  const getAccurateColumnIndexUnicode = async (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
4480
- const segmenter = create$8();
4616
+ const segmenter = create$7();
4481
4617
  const segments = segmenter.getSegments(line);
4482
4618
  const isMonospaceFont = false;
4483
4619
  const charWidth = 0;
@@ -4592,10 +4728,6 @@ const y = (editor, rowIndex) => {
4592
4728
  return offsetY;
4593
4729
  };
4594
4730
 
4595
- const state$7 = {
4596
- timeout: -1
4597
- };
4598
-
4599
4731
  /**
4600
4732
  *
4601
4733
  * @param {any} editor
@@ -4606,26 +4738,29 @@ const state$7 = {
4606
4738
  * @returns
4607
4739
  */
4608
4740
  // @ts-ignore
4609
- const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError) => {
4741
+ const editorShowMessage = (editor, rowIndex, columnIndex, message, _isError) => {
4610
4742
  object(editor);
4611
4743
  number(rowIndex);
4612
4744
  number(columnIndex);
4613
4745
  string(message);
4614
4746
  const x$1 = x(editor, rowIndex, columnIndex);
4615
4747
  const y$1 = y(editor, rowIndex);
4616
- const displayErrorMessage = message;
4617
- // @ts-ignore
4618
- await invoke$b('Editor.showOverlayMessage', editor, 'Viewlet.send', editor.uid, 'showOverlayMessage', x$1, y$1, displayErrorMessage);
4619
- if (!isError) {
4620
- const handleTimeout = () => {
4621
- editorHideMessage(editor);
4622
- };
4623
-
4624
- // TODO use wrapper timing module instead of this
4625
- // @ts-ignore
4626
- state$7.timeout = setTimeout(handleTimeout, 3000);
4627
- }
4628
- return editor;
4748
+ const existingWidget = editor.widgets.find(widget => widget.id === Message);
4749
+ const uid = existingWidget?.newState.uid ?? create$8();
4750
+ const newState = {
4751
+ message,
4752
+ uid,
4753
+ x: x$1,
4754
+ y: y$1
4755
+ };
4756
+ const widget = {
4757
+ id: Message,
4758
+ newState
4759
+ };
4760
+ return {
4761
+ ...editor,
4762
+ widgets: [...editor.widgets.filter(item => item.id !== Message), widget]
4763
+ };
4629
4764
  };
4630
4765
 
4631
4766
  /**
@@ -4637,20 +4772,12 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
4637
4772
  * @returns
4638
4773
  */
4639
4774
  // @ts-ignore
4640
- const showErrorMessage = async (editor, rowIndex, columnIndex, message) => {
4641
- return editorShowMessage(editor, rowIndex, columnIndex, message, /* isError */true);
4775
+ const showErrorMessage = (editor, rowIndex, columnIndex, message) => {
4776
+ return editorShowMessage(editor, rowIndex, columnIndex, message);
4642
4777
  };
4643
4778
 
4644
4779
  // @ts-ignore
4645
- const editorHideMessage = async editor => {
4646
- clearTimeout(state$7.timeout);
4647
- state$7.timeout = -1;
4648
- // await RendererProcess.invoke(/* Viewlet.send */ 'Viewlet.send', /* id */ editor.uid, /* method */ 'hideOverlayMessage')
4649
- return editor;
4650
- };
4651
-
4652
- // @ts-ignore
4653
- const getErrorMessage$5 = String;
4780
+ const getErrorMessage$4 = String;
4654
4781
 
4655
4782
  // @ts-ignore
4656
4783
  const getMatchingClosingBrace$1 = brace => {
@@ -4683,7 +4810,7 @@ const braceCompletion = async (editor, text) => {
4683
4810
  // TODO cursor should always be of type object
4684
4811
  const position = Array.isArray(editor.cursor) ? editor.cursor[0] : editor.cursor;
4685
4812
  // @ts-ignore
4686
- return showErrorMessage(editor, position, getErrorMessage$5(error));
4813
+ return showErrorMessage(editor, position, getErrorMessage$4(error));
4687
4814
  }
4688
4815
  };
4689
4816
  const getCursorOffset = editor => {
@@ -4852,12 +4979,8 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
4852
4979
  return newEditor;
4853
4980
  };
4854
4981
 
4855
- const create$7 = () => {
4856
- return Math.random();
4857
- };
4858
-
4859
4982
  const create$6 = () => {
4860
- const completionUid = create$7();
4983
+ const completionUid = create$8();
4861
4984
  const widget = {
4862
4985
  id: ColorPicker$1,
4863
4986
  newState: {
@@ -4884,7 +5007,23 @@ const newStateGenerator$6 = (state, parentUid) => {
4884
5007
  return loadContent$3(state, parentUid);
4885
5008
  };
4886
5009
  const openColorPicker = async editor => {
4887
- return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$6);
5010
+ const fullFocus = true;
5011
+ return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$6, fullFocus);
5012
+ };
5013
+ const closeColorPicker = editor => {
5014
+ const {
5015
+ widgets
5016
+ } = editor;
5017
+ if (widgets.every(widget => widget.id !== ColorPicker$1)) {
5018
+ return editor;
5019
+ }
5020
+ return {
5021
+ ...editor,
5022
+ additionalFocus: 0,
5023
+ focus: FocusEditorText$1,
5024
+ focused: true,
5025
+ widgets: removeEditorWidget(widgets, ColorPicker$1)
5026
+ };
4888
5027
  };
4889
5028
 
4890
5029
  const state$5 = {
@@ -5148,7 +5287,7 @@ const characterLeft = (line, columnIndex) => {
5148
5287
  if (columnIndex > line.length) {
5149
5288
  return 1;
5150
5289
  }
5151
- const segmenter = create$8();
5290
+ const segmenter = create$7();
5152
5291
  const last = segmenter.at(line, columnIndex - 1);
5153
5292
  if (!last) {
5154
5293
  return 1;
@@ -5163,7 +5302,7 @@ const characterRight = (line, columnIndex) => {
5163
5302
  if (!supported()) {
5164
5303
  return 1;
5165
5304
  }
5166
- const segmenter = create$8();
5305
+ const segmenter = create$7();
5167
5306
  const next = segmenter.at(line, columnIndex);
5168
5307
  // @ts-ignore
5169
5308
  return next.segment.length;
@@ -5679,7 +5818,7 @@ const format = async editor => {
5679
5818
 
5680
5819
  // TODO configure editor message as widget
5681
5820
  const displayErrorMessage = String(error);
5682
- await editorShowMessage(editor, 0, 0, displayErrorMessage, true);
5821
+ await editorShowMessage(editor, 0, 0, displayErrorMessage);
5683
5822
  return editor;
5684
5823
  }
5685
5824
  };
@@ -5944,13 +6083,13 @@ const goTo = async ({
5944
6083
  // TODO if editor is already disposed at this point, do nothing
5945
6084
  if (isNoProviderFoundError(error)) {
5946
6085
  const displayErrorMessage = getErrorMessage(error);
5947
- await editorShowMessage(editor, rowIndex, columnIndex, displayErrorMessage, false);
6086
+ await editorShowMessage(editor, rowIndex, columnIndex, displayErrorMessage);
5948
6087
  return editor;
5949
6088
  }
5950
6089
  // @ts-ignore
5951
6090
  // ErrorHandling.handleError(error, false)
5952
6091
  const displayErrorMessage = getErrorMessage(error);
5953
- await editorShowMessage(editor, rowIndex, columnIndex, displayErrorMessage, true);
6092
+ await editorShowMessage(editor, rowIndex, columnIndex, displayErrorMessage);
5954
6093
  return editor;
5955
6094
  }
5956
6095
  };
@@ -5980,7 +6119,7 @@ const getNoLocationFoundMessage$1 = info => {
5980
6119
  }
5981
6120
  return noDefinitionFound();
5982
6121
  };
5983
- const getErrorMessage$4 = String;
6122
+ const getErrorMessage$3 = String;
5984
6123
 
5985
6124
  // @ts-ignore
5986
6125
  const isNoProviderFoundError$1 = error => {
@@ -5989,7 +6128,7 @@ const isNoProviderFoundError$1 = error => {
5989
6128
  const goToDefinition = async editor => {
5990
6129
  return goTo({
5991
6130
  editor,
5992
- getErrorMessage: getErrorMessage$4,
6131
+ getErrorMessage: getErrorMessage$3,
5993
6132
  getLocation: getLocation$1,
5994
6133
  getNoLocationFoundMessage: getNoLocationFoundMessage$1,
5995
6134
  isNoProviderFoundError: isNoProviderFoundError$1
@@ -6014,14 +6153,14 @@ const getLocation = async (editor, rowIndex, columnIndex) => {
6014
6153
  const definition = await getTypeDefinition(editor, offset);
6015
6154
  return definition;
6016
6155
  };
6017
- const getErrorMessage$3 = String;
6156
+ const getErrorMessage$2 = String;
6018
6157
  const isNoProviderFoundError = error => {
6019
6158
  return error?.message?.startsWith('Failed to execute type definition provider: No type definition provider found');
6020
6159
  };
6021
6160
  const goToTypeDefinition = async (editor, explicit = true) => {
6022
6161
  return goTo({
6023
6162
  editor,
6024
- getErrorMessage: getErrorMessage$3,
6163
+ getErrorMessage: getErrorMessage$2,
6025
6164
  getLocation,
6026
6165
  getNoLocationFoundMessage: getNoLocationFoundMessage,
6027
6166
  isNoProviderFoundError
@@ -6199,6 +6338,58 @@ const handleFocus$1 = editor => {
6199
6338
  };
6200
6339
  };
6201
6340
 
6341
+ const stride = 4;
6342
+ const isDefinitionLink = (decorations, index) => {
6343
+ return decorations[index + 2] === DefinitionLink;
6344
+ };
6345
+ const matches = (editor, offset, length) => {
6346
+ const {
6347
+ decorations
6348
+ } = editor;
6349
+ for (let i = 0; i < decorations.length; i += stride) {
6350
+ if (isDefinitionLink(decorations, i)) {
6351
+ return decorations[i] === offset && decorations[i + 1] === length;
6352
+ }
6353
+ }
6354
+ return false;
6355
+ };
6356
+ const clear = editor => {
6357
+ const {
6358
+ decorations
6359
+ } = editor;
6360
+ const filtered = [];
6361
+ for (let i = 0; i < decorations.length; i += stride) {
6362
+ if (!isDefinitionLink(decorations, i)) {
6363
+ filtered.push(decorations[i], decorations[i + 1], decorations[i + 2], decorations[i + 3]);
6364
+ }
6365
+ }
6366
+ if (filtered.length === decorations.length) {
6367
+ return editor;
6368
+ }
6369
+ return {
6370
+ ...editor,
6371
+ decorations: filtered
6372
+ };
6373
+ };
6374
+ const set$2 = (editor, offset, length) => {
6375
+ if (matches(editor, offset, length)) {
6376
+ return editor;
6377
+ }
6378
+ const editorWithoutDefinitionLink = clear(editor);
6379
+ return {
6380
+ ...editorWithoutDefinitionLink,
6381
+ decorations: [...editorWithoutDefinitionLink.decorations, offset, length, DefinitionLink, 0]
6382
+ };
6383
+ };
6384
+
6385
+ const altKey = 'Alt';
6386
+ const handleKeyUp = (editor, key) => {
6387
+ if (key !== altKey) {
6388
+ return editor;
6389
+ }
6390
+ return clear(editor);
6391
+ };
6392
+
6202
6393
  const Single = 1;
6203
6394
  const Double = 2;
6204
6395
  const Triple = 3;
@@ -6292,56 +6483,44 @@ const set$1 = (editor, timeout, x, y) => {
6292
6483
  state$4.y = y;
6293
6484
  };
6294
6485
 
6295
- const showHover$1 = async (editor, position) => {
6296
- // TODO race condition
6297
- // await Viewlet.closeWidget(ViewletModuleId.EditorHover)
6298
- // await Viewlet.openWidget(ViewletModuleId.EditorHover, position)
6486
+ const RE_ALPHA_NUMERIC = /[a-zA-Z\d]/;
6487
+ const isAlphaNumeric = char => {
6488
+ return RE_ALPHA_NUMERIC.test(char);
6299
6489
  };
6300
6490
 
6301
- // TODO several things can happen:
6302
- // 1. highlight link when alt key is pressed
6303
- // 2. show hover info
6304
- // 3. selection moves
6305
- // 4. highlight go to definition
6306
- // 5. show color picker
6307
- // 6. show error info
6308
-
6309
- const onHoverIdle = async () => {
6310
- const {
6311
- editor,
6312
- x,
6313
- y
6314
- } = get$1();
6315
- await at(editor, x, y);
6316
- await showHover$1();
6491
+ const isWordChar = char => {
6492
+ return isAlphaNumeric(char) || char === '_';
6317
6493
  };
6318
- const hoverDelay = 300;
6319
-
6320
- // @ts-ignore
6321
- const handleMouseMove = (editor, x, y) => {
6322
- if (!editor.hoverEnabled) {
6323
- return editor;
6324
- }
6325
- const oldState = get$1();
6326
- if (oldState.timeout !== -1) {
6327
- clearTimeout(oldState.timeout);
6494
+ const getWordStartIndex = (line, index) => {
6495
+ for (let i = index - 1; i >= 0; i--) {
6496
+ if (!isWordChar(line[i])) {
6497
+ return i + 1;
6498
+ }
6328
6499
  }
6329
- const timeout = setTimeout(onHoverIdle, hoverDelay);
6330
- set$1(editor, timeout, x, y);
6331
- return editor;
6500
+ return 0;
6332
6501
  };
6333
-
6334
- // @ts-ignore
6335
- const getTokenIndex = (tokens, offset) => {
6336
- let currentOffset = 0;
6337
- for (let i = 0; i < tokens.length; i++) {
6338
- const token = tokens[i];
6339
- currentOffset += token.length;
6340
- if (currentOffset >= offset) {
6502
+ const getWordEndIndex = (line, index) => {
6503
+ for (let i = index; i < line.length; i++) {
6504
+ if (!isWordChar(line[i])) {
6341
6505
  return i;
6342
6506
  }
6343
6507
  }
6344
- return -1;
6508
+ return line.length;
6509
+ };
6510
+ const getWordMatchAtPosition = (lines, rowIndex, columnIndex) => {
6511
+ const line = lines[rowIndex];
6512
+ const start = getWordStartIndex(line, columnIndex);
6513
+ const end = getWordEndIndex(line, columnIndex);
6514
+ const word = line.slice(start, end);
6515
+ return {
6516
+ end,
6517
+ start,
6518
+ word
6519
+ };
6520
+ };
6521
+
6522
+ const isNoDefinitionProviderFoundError = error => {
6523
+ return error instanceof Error && error.message.startsWith('Failed to execute definition provider: No definition provider found');
6345
6524
  };
6346
6525
 
6347
6526
  // @ts-ignore
@@ -6350,45 +6529,71 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
6350
6529
  number(x);
6351
6530
  number(y);
6352
6531
  const position = await at(editor, x, y);
6532
+ const wordMatch = getWordMatchAtPosition(editor.lines, position.rowIndex, position.columnIndex);
6533
+ if (!wordMatch.word) {
6534
+ return clear(editor);
6535
+ }
6536
+ const wordOffset = offsetAt(editor, position.rowIndex, wordMatch.start);
6537
+ const wordLength = wordMatch.end - wordMatch.start;
6538
+ if (matches(editor, wordOffset, wordLength)) {
6539
+ return editor;
6540
+ }
6353
6541
  const documentOffset = offsetAt(editor, position.rowIndex, position.columnIndex);
6354
6542
  try {
6355
6543
  const definition = await getDefinition(editor, documentOffset);
6356
6544
  if (!definition) {
6357
- return editor;
6545
+ return clear(editor);
6358
6546
  }
6359
-
6360
- // TODO make sure that editor is not disposed
6361
-
6362
- const definitionStartPosition = positionAt(editor, definition.startOffset);
6363
- positionAt(editor, definition.endOffset);
6364
- // const definitionRelativeY = definitionStartPosition.rowIndex - editor.minLineY
6365
-
6366
- const lineTokenMap = editor.lineCache[definitionStartPosition.rowIndex + 1];
6367
- if (!lineTokenMap) {
6368
- return editor;
6369
- }
6370
- const tokenIndex = getTokenIndex(lineTokenMap.tokens, definitionStartPosition.columnIndex);
6371
- if (tokenIndex === -1) {
6372
- return editor;
6373
- }
6374
- // .tokens
6375
- // await RendererProcess.invoke(
6376
- // /* Viewlet.invoke */ 'Viewlet.send',
6377
- // /* id */ ViewletModuleId.EditorText,
6378
- // /* method */ 'highlightAsLink',
6379
- // /* relativeY */ definitionRelativeY,
6380
- // /* tokenIndex */ tokenIndex,
6381
- // )
6382
- return editor;
6547
+ return set$2(editor, wordOffset, wordLength);
6383
6548
  } catch (error) {
6384
- // @ts-ignore
6385
- if (error && error.message.startsWith('Failed to execute definition provider: No definition provider found')) {
6386
- return editor;
6549
+ if (isNoDefinitionProviderFoundError(error)) {
6550
+ return clear(editor);
6387
6551
  }
6388
6552
  throw error;
6389
6553
  }
6390
6554
  };
6391
6555
 
6556
+ const showHover$1 = async (editor, position) => {
6557
+ // TODO race condition
6558
+ // await Viewlet.closeWidget(ViewletModuleId.EditorHover)
6559
+ // await Viewlet.openWidget(ViewletModuleId.EditorHover, position)
6560
+ };
6561
+
6562
+ // TODO several things can happen:
6563
+ // 1. highlight link when alt key is pressed
6564
+ // 2. show hover info
6565
+ // 3. selection moves
6566
+ // 4. highlight go to definition
6567
+ // 5. show color picker
6568
+ // 6. show error info
6569
+
6570
+ const onHoverIdle = async () => {
6571
+ const {
6572
+ editor,
6573
+ x,
6574
+ y
6575
+ } = get$1();
6576
+ await at(editor, x, y);
6577
+ await showHover$1();
6578
+ };
6579
+ const hoverDelay = 300;
6580
+ const handleMouseMove = async (editor, x, y, altKey) => {
6581
+ if (altKey) {
6582
+ return handleMouseMoveWithAltKey(editor, x, y);
6583
+ }
6584
+ const editorWithoutDefinitionLink = clear(editor);
6585
+ if (!editorWithoutDefinitionLink.hoverEnabled) {
6586
+ return editorWithoutDefinitionLink;
6587
+ }
6588
+ const oldState = get$1();
6589
+ if (oldState.timeout !== -1) {
6590
+ clearTimeout(oldState.timeout);
6591
+ }
6592
+ const timeout = setTimeout(onHoverIdle, hoverDelay);
6593
+ set$1(editorWithoutDefinitionLink, timeout, x, y);
6594
+ return editorWithoutDefinitionLink;
6595
+ };
6596
+
6392
6597
  // TODO adjust relative position
6393
6598
  // @ts-ignore
6394
6599
  const getSelectionFromNativeRange = (editor, range) => {
@@ -6643,7 +6848,7 @@ const continueScrollingAndMovingSelection = async editorUid => {
6643
6848
  }
6644
6849
  };
6645
6850
  const newEditorWithDerivedState = await updateDerivedState(editor, nextEditor);
6646
- set$8(editor.uid, editor, newEditorWithDerivedState);
6851
+ set$9(editor.uid, editor, newEditorWithDerivedState);
6647
6852
  requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
6648
6853
  };
6649
6854
 
@@ -7093,7 +7298,7 @@ const Script = 2;
7093
7298
  const Unknown$1 = 0;
7094
7299
 
7095
7300
  const create$5 = () => {
7096
- const completionUid = create$7();
7301
+ const completionUid = create$8();
7097
7302
  const widget = {
7098
7303
  id: CodeGenerator,
7099
7304
  newState: {
@@ -7136,7 +7341,7 @@ const openCodeGenerator = async editor => {
7136
7341
  };
7137
7342
 
7138
7343
  const create$4 = () => {
7139
- const completionUid = create$7();
7344
+ const completionUid = create$8();
7140
7345
  const completionWidget = {
7141
7346
  id: Completion,
7142
7347
  newState: {
@@ -7193,7 +7398,7 @@ const openCompletion = async editor => {
7193
7398
  };
7194
7399
 
7195
7400
  const create$3 = () => {
7196
- const uid = create$7();
7401
+ const uid = create$8();
7197
7402
  const widget = {
7198
7403
  id: Find,
7199
7404
  newState: {
@@ -7231,7 +7436,7 @@ const launch = async () => {
7231
7436
  return;
7232
7437
  }
7233
7438
  const rpc = await launchFindWidgetWorker();
7234
- set$f(rpcId, rpc);
7439
+ set$h(rpcId, rpc);
7235
7440
  };
7236
7441
  const invoke$3 = async (method, ...params) => {
7237
7442
  const rpc = get$8(rpcId);
@@ -7311,7 +7516,7 @@ const getPositionAtCursor$1 = editor => {
7311
7516
  };
7312
7517
 
7313
7518
  const create$2 = () => {
7314
- const completionUid = create$7();
7519
+ const completionUid = create$8();
7315
7520
  const renameWidget = {
7316
7521
  id: Rename$1,
7317
7522
  newState: {
@@ -7418,133 +7623,6 @@ const redo = state => {
7418
7623
  return scheduleDocumentAndCursorsSelectionIsUndo(newState, last);
7419
7624
  };
7420
7625
 
7421
- const getErrorMessage$2 = error => {
7422
- if (!error) {
7423
- return `Error: ${error}`;
7424
- }
7425
- let {
7426
- message
7427
- } = error;
7428
- while (error.cause) {
7429
- error = error.cause;
7430
- message += `: ${error}`;
7431
- }
7432
- return message;
7433
- };
7434
- const prepareErrorMessageWithCodeFrame = error => {
7435
- if (!error) {
7436
- return {
7437
- codeFrame: undefined,
7438
- message: error,
7439
- stack: undefined,
7440
- type: 'Error'
7441
- };
7442
- }
7443
- const message = getErrorMessage$2(error);
7444
- if (error.codeFrame) {
7445
- return {
7446
- codeFrame: error.codeFrame,
7447
- message,
7448
- stack: error.stack,
7449
- type: error.constructor.name
7450
- };
7451
- }
7452
- return {
7453
- category: error.category,
7454
- codeFrame: error.originalCodeFrame,
7455
- message,
7456
- stack: error.originalStack,
7457
- stderr: error.stderr
7458
- };
7459
- };
7460
-
7461
- /* eslint-disable sonarjs/super-linear-regex */
7462
-
7463
- const RE_PATH_1 = /\((.*):(\d+):(\d+)\)$/;
7464
- const RE_PATH_2 = /at (.*):(\d+):(\d+)$/;
7465
-
7466
- /**
7467
- *
7468
- * @param {readonly string[]} lines
7469
- * @returns
7470
- */
7471
- const getFile = lines => {
7472
- for (const line of lines) {
7473
- if (RE_PATH_1.test(line) || RE_PATH_2.test(line)) {
7474
- return line;
7475
- }
7476
- }
7477
- return '';
7478
- };
7479
- const prepareErrorMessageWithoutCodeFrame = async error => {
7480
- try {
7481
- const lines = splitLines(error.stack);
7482
- const file = getFile(lines);
7483
- let match = file.match(RE_PATH_1);
7484
- if (!match) {
7485
- match = file.match(RE_PATH_2);
7486
- }
7487
- if (!match) {
7488
- return error;
7489
- }
7490
- const relevantStack = joinLines(lines.slice(1));
7491
- const message = getErrorMessage$2(error);
7492
- return {
7493
- message,
7494
- stack: relevantStack,
7495
- type: error.constructor.name
7496
- };
7497
- } catch (otherError) {
7498
- console.warn('ErrorHandling Error');
7499
- console.warn(otherError);
7500
- return error;
7501
- }
7502
- };
7503
- const prepare = async error => {
7504
- if (error && error.message && error.codeFrame) {
7505
- return prepareErrorMessageWithCodeFrame(error);
7506
- }
7507
- if (error && error.stack) {
7508
- return prepareErrorMessageWithoutCodeFrame(error);
7509
- }
7510
- return error;
7511
- };
7512
- const print = error => {
7513
- if (error && error.type && error.message && error.codeFrame) {
7514
- return `${error.type}: ${error.message}\n\n${error.codeFrame}\n\n${error.stack}`;
7515
- }
7516
- if (error && error.message && error.codeFrame) {
7517
- return `${error.message}\n\n${error.codeFrame}\n\n${error.stack}`;
7518
- }
7519
- if (error && error.type && error.message) {
7520
- return `${error.type}: ${error.message}\n${error.stack}`;
7521
- }
7522
- if (error && error.stack) {
7523
- return error.stack;
7524
- }
7525
- if (error === null) {
7526
- return null;
7527
- }
7528
- return String(error);
7529
- };
7530
-
7531
- // @ts-nocheck
7532
- const logError = async error => {
7533
- const prettyError = await prepare(error);
7534
- const prettyErrorString = print(prettyError);
7535
- console.error(prettyErrorString);
7536
- return prettyError;
7537
- };
7538
- const handleError = async error => {
7539
- try {
7540
- await logError(error);
7541
- } catch (otherError) {
7542
- console.warn('ErrorHandling error');
7543
- console.warn(otherError);
7544
- console.error(error);
7545
- }
7546
- };
7547
-
7548
7626
  // @ts-ignore
7549
7627
  const getNewEditor = async editor => {
7550
7628
  return editor;
@@ -7633,12 +7711,12 @@ const save = async editor => {
7633
7711
  } catch (error) {
7634
7712
  // @ts-ignore
7635
7713
  const betterError = new VError(error, `Failed to save file "${editor.uri}"`);
7636
- await handleError(betterError);
7714
+ await handleError$1(betterError);
7637
7715
  if (editor.platform === Electron) {
7638
7716
  try {
7639
7717
  await showSaveErrorDialog(betterError);
7640
7718
  } catch (dialogError) {
7641
- await handleError(dialogError);
7719
+ await handleError$1(dialogError);
7642
7720
  }
7643
7721
  }
7644
7722
  return editor;
@@ -7696,42 +7774,6 @@ const editorSelectAllLeft = editor => {
7696
7774
  editorSelectHorizontalLeft(editor, lineCharacterStart);
7697
7775
  };
7698
7776
 
7699
- const RE_ALPHA_NUMERIC = /[a-zA-Z\d]/;
7700
- const isAlphaNumeric = char => {
7701
- return RE_ALPHA_NUMERIC.test(char);
7702
- };
7703
-
7704
- const isWordChar = char => {
7705
- return isAlphaNumeric(char) || char === '_';
7706
- };
7707
- const getWordStartIndex = (line, index) => {
7708
- for (let i = index - 1; i >= 0; i--) {
7709
- if (!isWordChar(line[i])) {
7710
- return i + 1;
7711
- }
7712
- }
7713
- return 0;
7714
- };
7715
- const getWordEndIndex = (line, index) => {
7716
- for (let i = index; i < line.length; i++) {
7717
- if (!isWordChar(line[i])) {
7718
- return i;
7719
- }
7720
- }
7721
- return line.length;
7722
- };
7723
- const getWordMatchAtPosition = (lines, rowIndex, columnIndex) => {
7724
- const line = lines[rowIndex];
7725
- const start = getWordStartIndex(line, columnIndex);
7726
- const end = getWordEndIndex(line, columnIndex);
7727
- const word = line.slice(start, end);
7728
- return {
7729
- end,
7730
- start,
7731
- word
7732
- };
7733
- };
7734
-
7735
7777
  const isMultiLineMatch = (lines, rowIndex, wordParts) => {
7736
7778
  let j = 0;
7737
7779
  if (!lines[rowIndex + j].endsWith(wordParts[j])) {
@@ -8199,7 +8241,7 @@ const setLanguageId = async (editor, languageId, tokenizePath) => {
8199
8241
  await loadTokenizer(languageId, tokenizePath);
8200
8242
  const tokenizer = getTokenizer(languageId);
8201
8243
  const newTokenizerId = tokenizerId + 1;
8202
- set$3(newTokenizerId, tokenizer);
8244
+ set$4(newTokenizerId, tokenizer);
8203
8245
  const latest = getEditor$1(editor.uid);
8204
8246
  if (!latest) {
8205
8247
  return editor;
@@ -8291,7 +8333,7 @@ const setText = (editor, text) => {
8291
8333
  };
8292
8334
 
8293
8335
  const create$1 = () => {
8294
- const uid = create$7();
8336
+ const uid = create$8();
8295
8337
  const widget = {
8296
8338
  id: Hover,
8297
8339
  newState: {
@@ -8379,7 +8421,7 @@ const showHover = async state => {
8379
8421
  };
8380
8422
 
8381
8423
  const create = () => {
8382
- const completionUid = create$7();
8424
+ const completionUid = create$8();
8383
8425
  const widget = {
8384
8426
  id: SourceAction$1,
8385
8427
  newState: {
@@ -8648,7 +8690,7 @@ const tabCompletion = async editor => {
8648
8690
  }
8649
8691
  return editorSnippet(editor, tabCompletion);
8650
8692
  } catch (error) {
8651
- await handleError(error);
8693
+ await handleError$1(error);
8652
8694
  // TODO cursor should always be of type object
8653
8695
  const rowIndex = editor.selections[0];
8654
8696
  const columnIndex = editor.selections[1];
@@ -8927,7 +8969,7 @@ const toggleComment = async editor => {
8927
8969
  } catch (error$1) {
8928
8970
  error(error$1);
8929
8971
  // TODO use correct position
8930
- await editorShowMessage(/* editor */editor, /* rowIndex */0, /* columnIndex */0, /* message */String(error$1), /* isError */true);
8972
+ await editorShowMessage(/* editor */editor, /* rowIndex */0, /* columnIndex */0, /* message */String(error$1));
8931
8973
  return editor;
8932
8974
  }
8933
8975
  };
@@ -9242,6 +9284,7 @@ const editorUnindent = editor => {
9242
9284
 
9243
9285
  const isFunctional = widgetId => {
9244
9286
  switch (widgetId) {
9287
+ case Message:
9245
9288
  case ColorPicker$1:
9246
9289
  case Completion:
9247
9290
  case Find:
@@ -9253,7 +9296,7 @@ const isFunctional = widgetId => {
9253
9296
  return false;
9254
9297
  }
9255
9298
  };
9256
- const addWidget$1 = (widget, id, render) => {
9299
+ const addWidget = (widget, id, render) => {
9257
9300
  const commands = render(widget);
9258
9301
  // TODO how to generate a unique integer id
9259
9302
  // that doesn't collide with ids created in renderer worker?
@@ -9384,7 +9427,7 @@ const createFn = (key, name, widgetId) => {
9384
9427
  focused: true,
9385
9428
  widgets: removeEditorWidget(latest.widgets, widgetId)
9386
9429
  };
9387
- set$8(editor.uid, latest, newEditor);
9430
+ set$9(editor.uid, latest, newEditor);
9388
9431
  return newEditor;
9389
9432
  }
9390
9433
  const newState = {
@@ -9392,7 +9435,7 @@ const createFn = (key, name, widgetId) => {
9392
9435
  commands
9393
9436
  };
9394
9437
  const newEditor = updateWidget(latest, widgetId, newState);
9395
- set$8(editor.uid, latest, newEditor);
9438
+ set$9(editor.uid, latest, newEditor);
9396
9439
  return newEditor;
9397
9440
  };
9398
9441
  return fn;
@@ -9407,6 +9450,7 @@ const createFns = (keys, name, widgetId) => {
9407
9450
 
9408
9451
  const AppendToBody = 'Viewlet.appendToBody';
9409
9452
  const Focus = 'focus';
9453
+ const FocusSelector = 'Viewlet.focusSelector';
9410
9454
  const RegisterEventListeners = 'Viewlet.registerEventListeners';
9411
9455
  const SetSelectionByName = 'Viewlet.setSelectionByName';
9412
9456
  const SetValueByName = 'Viewlet.setValueByName';
@@ -9425,7 +9469,7 @@ const renderFull$4 = (oldState, newState) => {
9425
9469
  };
9426
9470
 
9427
9471
  const commandsToForward$5 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
9428
- const render$b = widget => {
9472
+ const render$c = widget => {
9429
9473
  const commands = renderFull$4(widget.oldState, widget.newState);
9430
9474
  const wrappedCommands = [];
9431
9475
  const {
@@ -9440,8 +9484,8 @@ const render$b = widget => {
9440
9484
  }
9441
9485
  return wrappedCommands;
9442
9486
  };
9443
- const add$7 = widget => {
9444
- return addWidget$1(widget, 'EditorCompletion', render$b);
9487
+ const add$8 = widget => {
9488
+ return addWidget(widget, 'EditorCompletion', render$c);
9445
9489
  };
9446
9490
  const remove$7 = widget => {
9447
9491
  return [['Viewlet.dispose', widget.newState.uid]];
@@ -9468,7 +9512,7 @@ const {
9468
9512
 
9469
9513
  const EditorCompletionWidget = {
9470
9514
  __proto__: null,
9471
- add: add$7,
9515
+ add: add$8,
9472
9516
  close: close$4,
9473
9517
  closeDetails: closeDetails$1,
9474
9518
  focusFirst: focusFirst$1,
@@ -9484,7 +9528,7 @@ const EditorCompletionWidget = {
9484
9528
  handleWheel: handleWheel$1,
9485
9529
  openDetails,
9486
9530
  remove: remove$7,
9487
- render: render$b,
9531
+ render: render$c,
9488
9532
  selectCurrent: selectCurrent$1,
9489
9533
  selectIndex: selectIndex$1,
9490
9534
  toggleDetails: toggleDetails$1
@@ -9498,7 +9542,7 @@ const renderFull$3 = (oldState, newState) => {
9498
9542
  };
9499
9543
 
9500
9544
  const commandsToForward$4 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
9501
- const render$a = widget => {
9545
+ const render$b = widget => {
9502
9546
  const commands = renderFull$3(widget.oldState, widget.newState);
9503
9547
  const wrappedCommands = [];
9504
9548
  const {
@@ -9513,8 +9557,8 @@ const render$a = widget => {
9513
9557
  }
9514
9558
  return wrappedCommands;
9515
9559
  };
9516
- const add$6 = widget => {
9517
- return addWidget$1(widget, 'FindWidget', render$a);
9560
+ const add$7 = widget => {
9561
+ return addWidget(widget, 'FindWidget', render$b);
9518
9562
  };
9519
9563
  const remove$6 = widget => {
9520
9564
  return [['Viewlet.dispose', widget.newState.uid]];
@@ -9551,7 +9595,7 @@ const {
9551
9595
 
9552
9596
  const EditorFindWidget = {
9553
9597
  __proto__: null,
9554
- add: add$6,
9598
+ add: add$7,
9555
9599
  close: close$3,
9556
9600
  focusCloseButton,
9557
9601
  focusFind,
@@ -9573,7 +9617,7 @@ const EditorFindWidget = {
9573
9617
  handleReplaceInput,
9574
9618
  handleToggleReplaceFocus,
9575
9619
  remove: remove$6,
9576
- render: render$a,
9620
+ render: render$b,
9577
9621
  replace,
9578
9622
  replaceAll,
9579
9623
  toggleMatchCase,
@@ -9831,6 +9875,7 @@ const HandleScrollBarVerticalPointerDown = 30;
9831
9875
  const HandleScrollBarVerticalPointerMove = 31;
9832
9876
  const HandleScrollBarVerticalPointerUp = 32;
9833
9877
  const HandleWheel = 33;
9878
+ const HandleKeyUp = 34;
9834
9879
 
9835
9880
  const Div = 4;
9836
9881
  const Input = 6;
@@ -9943,10 +9988,10 @@ const renderBounds$2 = {
9943
9988
  },
9944
9989
  isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y
9945
9990
  };
9946
- const render$9 = [renderHoverDom, renderBounds$2];
9991
+ const render$a = [renderHoverDom, renderBounds$2];
9947
9992
  const renderHover = (oldState, newState) => {
9948
9993
  const commands = [];
9949
- for (const item of render$9) {
9994
+ for (const item of render$a) {
9950
9995
  if (!item.isEqual(oldState, newState)) {
9951
9996
  commands.push(item.apply(oldState, newState));
9952
9997
  }
@@ -9955,7 +10000,7 @@ const renderHover = (oldState, newState) => {
9955
10000
  };
9956
10001
 
9957
10002
  const commandsToForward$3 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
9958
- const render$8 = widget => {
10003
+ const render$9 = widget => {
9959
10004
  const commands = renderFull$4(widget.oldState, widget.newState);
9960
10005
  const wrappedCommands = [];
9961
10006
  const {
@@ -9970,8 +10015,8 @@ const render$8 = widget => {
9970
10015
  }
9971
10016
  return wrappedCommands;
9972
10017
  };
9973
- const add$5 = widget => {
9974
- return addWidget$1(widget, 'EditorRename', render$8);
10018
+ const add$6 = widget => {
10019
+ return addWidget(widget, 'EditorRename', render$9);
9975
10020
  };
9976
10021
  const remove$5 = widget => {
9977
10022
  return [['Viewlet.dispose', widget.newState.uid]];
@@ -9985,11 +10030,11 @@ const {
9985
10030
  const EditorRenameWidget = {
9986
10031
  __proto__: null,
9987
10032
  accept,
9988
- add: add$5,
10033
+ add: add$6,
9989
10034
  close: close$2,
9990
10035
  handleInput,
9991
10036
  remove: remove$5,
9992
- render: render$8
10037
+ render: render$9
9993
10038
  };
9994
10039
 
9995
10040
  const rerender = editor => {
@@ -10010,13 +10055,13 @@ const focusNext$1 = state => {
10010
10055
  return focusIndex$1(state, nextIndex);
10011
10056
  };
10012
10057
 
10013
- const removeWidget$1 = widget => {
10058
+ const removeWidget = widget => {
10014
10059
  // @ts-ignore
10015
- return [['Viewlet.send', widget.newState.uid, 'dispose']];
10060
+ return [['Viewlet.dispose', widget.newState.uid]];
10016
10061
  };
10017
10062
 
10018
10063
  const commandsToForward$2 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
10019
- const render$7 = widget => {
10064
+ const render$8 = widget => {
10020
10065
  const commands = renderFull$4(widget.oldState, widget.newState);
10021
10066
  const wrappedCommands = [];
10022
10067
  const {
@@ -10031,10 +10076,10 @@ const render$7 = widget => {
10031
10076
  }
10032
10077
  return wrappedCommands;
10033
10078
  };
10034
- const add$4 = widget => {
10035
- return addWidget$1(widget, 'EditorSourceActions', render$7);
10079
+ const add$5 = widget => {
10080
+ return addWidget(widget, 'EditorSourceActions', render$8);
10036
10081
  };
10037
- const remove$4 = removeWidget$1;
10082
+ const remove$4 = removeWidget;
10038
10083
  const {
10039
10084
  close: close$1,
10040
10085
  closeDetails,
@@ -10052,7 +10097,7 @@ const {
10052
10097
 
10053
10098
  const EditorSourceActionWidget = {
10054
10099
  __proto__: null,
10055
- add: add$4,
10100
+ add: add$5,
10056
10101
  close: close$1,
10057
10102
  closeDetails,
10058
10103
  focusFirst,
@@ -10062,7 +10107,7 @@ const EditorSourceActionWidget = {
10062
10107
  focusPrevious,
10063
10108
  handleWheel,
10064
10109
  remove: remove$4,
10065
- render: render$7,
10110
+ render: render$8,
10066
10111
  selectCurrent,
10067
10112
  selectIndex,
10068
10113
  selectItem,
@@ -10162,6 +10207,7 @@ const FocusFindWidgetCloseButton = 48;
10162
10207
  const FocusFindWidgetNextMatchButton = 49;
10163
10208
  const FocusFindWidgetPreviousMatchButton = 50;
10164
10209
  const FocusEditorCodeGenerator = 52;
10210
+ const FocusColorPicker = 41;
10165
10211
 
10166
10212
  const getPositionAtCursor = editorUid => {
10167
10213
  const editor = getEditor$1(editorUid);
@@ -10217,7 +10263,7 @@ const setSelections2 = async (editorUid, selections) => {
10217
10263
  selections
10218
10264
  };
10219
10265
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
10220
- set$8(editorUid, editor, newEditorWithDerivedState);
10266
+ set$9(editorUid, editor, newEditorWithDerivedState);
10221
10267
  };
10222
10268
  const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
10223
10269
  const editor = getEditor$1(editorUid);
@@ -10237,7 +10283,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
10237
10283
  widgets: newWidgets
10238
10284
  };
10239
10285
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
10240
- set$8(editorUid, editor, newEditorWithDerivedState);
10286
+ set$9(editorUid, editor, newEditorWithDerivedState);
10241
10287
  await setFocus(FocusEditorText);
10242
10288
  if (unsetAdditionalFocus$1) {
10243
10289
  await unsetAdditionalFocus(unsetAdditionalFocus$1);
@@ -10250,7 +10296,7 @@ const applyEdits2 = async (editorUid, edits) => {
10250
10296
  const editor = getEditor$1(editorUid);
10251
10297
  const newEditor = await applyEdit(editor, edits);
10252
10298
  const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
10253
- set$8(editorUid, editor, newEditorWithDerivedState);
10299
+ set$9(editorUid, editor, newEditorWithDerivedState);
10254
10300
  };
10255
10301
  const getSourceActions = async editorUid => {
10256
10302
  const actions = await getEditorSourceActions(editorUid);
@@ -10270,6 +10316,10 @@ const ensure = async (fontName, fontUrl) => {
10270
10316
 
10271
10317
  const getKeyBindings = () => {
10272
10318
  return [{
10319
+ command: 'Editor.closeColorPicker',
10320
+ key: Escape,
10321
+ when: FocusColorPicker
10322
+ }, {
10273
10323
  command: 'Editor.closeSourceAction',
10274
10324
  key: Escape,
10275
10325
  when: FocusSourceActions
@@ -10828,7 +10878,7 @@ const handleMessagePort = async (port, rpcId) => {
10828
10878
  messagePort: port
10829
10879
  });
10830
10880
  if (rpcId) {
10831
- set$f(rpcId, rpc);
10881
+ set$h(rpcId, rpc);
10832
10882
  }
10833
10883
  };
10834
10884
 
@@ -10979,7 +11029,7 @@ const hotReload = async () => {
10979
11029
  await relaunchWorkers();
10980
11030
  const newEditors = await restoreWidgetState(keys, savedStates);
10981
11031
  for (const editor of newEditors) {
10982
- set$8(editor.newState.uid, editor.oldState, editor.newState);
11032
+ set$9(editor.newState.uid, editor.oldState, editor.newState);
10983
11033
  }
10984
11034
 
10985
11035
  // TODO ask renderer worker to rerender all editors
@@ -11017,7 +11067,7 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
11017
11067
  if (syntaxHighlightingEnabled) {
11018
11068
  setEnabled$1(true);
11019
11069
  const syntaxRpc = await createSyntaxHighlightingWorkerRpc();
11020
- set$6(syntaxRpc);
11070
+ set$7(syntaxRpc);
11021
11071
  }
11022
11072
  if (syncIncremental) {
11023
11073
  setEnabled(true);
@@ -11159,7 +11209,7 @@ const loadContent = async (state, savedState) => {
11159
11209
  await loadTokenizer(computedLanguageId, tokenizePath);
11160
11210
  const tokenizer = getTokenizer(computedLanguageId);
11161
11211
  const newTokenizerId = state.tokenizerId + 1;
11162
- set$3(newTokenizerId, tokenizer);
11212
+ set$4(newTokenizerId, tokenizer);
11163
11213
  const newEditor0 = {
11164
11214
  ...state,
11165
11215
  charWidth,
@@ -11354,11 +11404,11 @@ const renderCss$1 = (oldState, newState) => {
11354
11404
 
11355
11405
  const renderFocus$2 = (oldState, newState) => {
11356
11406
  const selector = '.EditorInput textarea';
11357
- return [FocusSelector, newState.uid, selector];
11407
+ return [FocusSelector$1, newState.uid, selector];
11358
11408
  };
11359
11409
 
11360
11410
  const renderFocusContext$1 = (oldState, newState) => {
11361
- return [SetFocusContext$1, newState.uid, FocusEditorText$1];
11411
+ return [SetFocusContext$1, newState.uid, newState.focus];
11362
11412
  };
11363
11413
 
11364
11414
  const SetText = 1;
@@ -11844,6 +11894,7 @@ const getEditorContentVirtualDom = ({
11844
11894
  return [{
11845
11895
  childCount: 5,
11846
11896
  className: 'EditorContent',
11897
+ onKeyUp: HandleKeyUp,
11847
11898
  onMouseMove: HandleMouseMove,
11848
11899
  type: Div
11849
11900
  }, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom()];
@@ -11949,79 +12000,6 @@ const renderIncremental = (oldState, newState) => {
11949
12000
  return [SetPatches, newState.uid, patches];
11950
12001
  };
11951
12002
 
11952
- const addWidget = widget => {
11953
- const module = get$6(widget.id);
11954
- if (!module) {
11955
- throw new Error('unsupported widget');
11956
- }
11957
- return module.add(widget);
11958
- };
11959
- const renderWidget = widget => {
11960
- const module = get$6(widget.id);
11961
- if (!module) {
11962
- throw new Error('unsupported widget');
11963
- }
11964
- return module.render(widget);
11965
- };
11966
- const removeWidget = widget => {
11967
- const module = get$6(widget.id);
11968
- if (!module) {
11969
- throw new Error('unsupported widget');
11970
- }
11971
- return module.remove(widget);
11972
- };
11973
-
11974
- const renderWidgets$1 = (oldState, newState) => {
11975
- const addedWidgets = [];
11976
- const changedWidgets = [];
11977
- const removedWidgets = [];
11978
- const oldWidgets = oldState.widgets || [];
11979
- const newWidgets = newState.widgets || [];
11980
- const oldWidgetMap = Object.create(null);
11981
- const newWidgetMap = Object.create(null);
11982
- for (const oldWidget of oldWidgets) {
11983
- oldWidgetMap[oldWidget.id] = oldWidget;
11984
- }
11985
- for (const newWidget of newWidgets) {
11986
- newWidgetMap[newWidget.id] = newWidget;
11987
- }
11988
- for (const oldWidget of oldWidgets) {
11989
- if (Object.hasOwn(newWidgetMap, oldWidget.id)) {
11990
- changedWidgets.push(newWidgetMap[oldWidget.id]);
11991
- } else {
11992
- removedWidgets.push(oldWidget);
11993
- }
11994
- }
11995
- for (const newWidget of newWidgets) {
11996
- if (Object.hasOwn(oldWidgetMap, newWidget.id)) ; else {
11997
- addedWidgets.push(newWidget);
11998
- }
11999
- }
12000
- const addCommands = [];
12001
- for (const addedWidget of addedWidgets) {
12002
- const childCommands = addWidget(addedWidget);
12003
- if (childCommands.length > 0) {
12004
- addCommands.push(...childCommands);
12005
- }
12006
- }
12007
- const changeCommands = [];
12008
- for (const changedWidget of changedWidgets) {
12009
- const childCommands = renderWidget(changedWidget);
12010
- if (childCommands.length > 0) {
12011
- changeCommands.push(...childCommands);
12012
- }
12013
- }
12014
- const removeCommands = [];
12015
- for (const removedWidget of removedWidgets) {
12016
- const childCommands = removeWidget(removedWidget);
12017
- if (childCommands.length > 0) {
12018
- removeCommands.push(...childCommands);
12019
- }
12020
- }
12021
- const allCommands = [...addCommands, ...changeCommands, ...removeCommands];
12022
- return allCommands.filter(item => item[0] !== 'Viewlet.setFocusContext');
12023
- };
12024
-
12025
12003
  const getRenderer = diffType => {
12026
12004
  switch (diffType) {
12027
12005
  case RenderCss:
@@ -12060,7 +12038,7 @@ const render2 = (uid, diffResult) => {
12060
12038
  newState,
12061
12039
  oldState
12062
12040
  } = get$7(uid);
12063
- set$8(uid, newState, newState);
12041
+ set$9(uid, newState, newState);
12064
12042
  const commands = applyRender(oldState, newState, diffResult);
12065
12043
  return commands;
12066
12044
  };
@@ -12152,7 +12130,7 @@ const renderWidgets = {
12152
12130
  isEqual: (oldState, newState) => oldState.widgets === newState.widgets,
12153
12131
  multiple: true
12154
12132
  };
12155
- const render$6 = [renderLines, renderSelections, renderCss, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
12133
+ const render$7 = [renderLines, renderSelections, renderCss, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
12156
12134
  const renderEditor = async id => {
12157
12135
  const instance = get$7(id);
12158
12136
  if (!instance) {
@@ -12163,8 +12141,8 @@ const renderEditor = async id => {
12163
12141
  oldState
12164
12142
  } = instance;
12165
12143
  const commands = [];
12166
- set$8(id, newState, newState);
12167
- for (const item of render$6) {
12144
+ set$9(id, newState, newState);
12145
+ for (const item of render$7) {
12168
12146
  if (item.isEqual(oldState, newState)) {
12169
12147
  continue;
12170
12148
  }
@@ -12186,6 +12164,9 @@ const renderEventListeners = () => {
12186
12164
  }, {
12187
12165
  name: HandleMouseMove,
12188
12166
  params: ['handleMouseMove', ClientX, ClientY, AltKey]
12167
+ }, {
12168
+ name: HandleKeyUp,
12169
+ params: ['handleKeyUp', Key]
12189
12170
  }, {
12190
12171
  name: HandleBlur,
12191
12172
  params: ['handleBlur']
@@ -12316,7 +12297,7 @@ const updateDebugInfo = async debugId => {
12316
12297
  ...newState,
12317
12298
  highlightedLine: newInfo.rowIndex
12318
12299
  };
12319
- set$8(key, oldState, newEditor);
12300
+ set$9(key, oldState, newEditor);
12320
12301
  // @ts-ignore
12321
12302
  await invoke$b('Editor.rerender', key);
12322
12303
  };
@@ -12337,7 +12318,7 @@ const wrapCommand = fn => async (editorUid, ...args) => {
12337
12318
 
12338
12319
  // TODO combine neweditor with latest editor?
12339
12320
 
12340
- set$8(editorUid, state, newEditorWithDerivedState);
12321
+ set$9(editorUid, state, newEditorWithDerivedState);
12341
12322
  return newEditorWithDerivedState;
12342
12323
  };
12343
12324
 
@@ -12354,6 +12335,7 @@ const commandMap = {
12354
12335
  'Editor.braceCompletion': wrapCommand(braceCompletion),
12355
12336
  'Editor.cancelSelection': wrapCommand(cancelSelection),
12356
12337
  'Editor.closeCodeGenerator': wrapCommand(closeCodeGenerator),
12338
+ 'Editor.closeColorPicker': wrapCommand(closeColorPicker),
12357
12339
  'Editor.closeFind': wrapCommand(closeFind),
12358
12340
  'Editor.closeFind2': closeFind2,
12359
12341
  'Editor.closeRename': wrapCommand(closeRename),
@@ -12395,6 +12377,7 @@ const commandMap = {
12395
12377
  'Editor.deleteWordPartRight': wrapCommand(deleteWordPartRight),
12396
12378
  'Editor.deleteWordRight': wrapCommand(deleteWordRight),
12397
12379
  'Editor.diff2': diff2,
12380
+ 'Editor.dispose': disposeEditor,
12398
12381
  'Editor.executeWidgetCommand': wrapCommand(executeWidgetCommand),
12399
12382
  'Editor.findAllReferences': wrapCommand(findAllReferences$1),
12400
12383
  'Editor.format': wrapCommand(format),
@@ -12430,6 +12413,7 @@ const commandMap = {
12430
12413
  'Editor.handleContextMenu': wrapCommand(handleContextMenu),
12431
12414
  'Editor.handleDoubleClick': wrapCommand(handleDoubleClick),
12432
12415
  'Editor.handleFocus': wrapCommand(handleFocus$1),
12416
+ 'Editor.handleKeyUp': wrapCommand(handleKeyUp),
12433
12417
  'Editor.handleMouseDown': wrapCommand(handleMouseDown),
12434
12418
  'Editor.handleMouseMove': wrapCommand(handleMouseMove),
12435
12419
  'Editor.handleMouseMoveWithAltKey': wrapCommand(handleMouseMoveWithAltKey),
@@ -12606,6 +12590,16 @@ for (const [key, value] of Object.entries(commandMap)) {
12606
12590
  }
12607
12591
  }
12608
12592
 
12593
+ const initializeErrorWorker = async () => {
12594
+ const rpc = await create$c({
12595
+ commandMap: {},
12596
+ send(port) {
12597
+ return sendMessagePortToErrorWorker(port, EditorWorker);
12598
+ }
12599
+ });
12600
+ set$g(rpc);
12601
+ };
12602
+
12609
12603
  const createExtensionHostRpc = async () => {
12610
12604
  const initialCommand = 'HandleMessagePort.handleMessagePort2';
12611
12605
  const rpc = await create$c({
@@ -12619,7 +12613,7 @@ const createExtensionHostRpc = async () => {
12619
12613
 
12620
12614
  const initializeExtensionHost = async () => {
12621
12615
  const extensionHostRpc = await createExtensionHostRpc();
12622
- set$2(extensionHostRpc);
12616
+ set$3(extensionHostRpc);
12623
12617
  };
12624
12618
 
12625
12619
  const createExtensionManagementWorkerRpc = async () => {
@@ -12635,7 +12629,7 @@ const createExtensionManagementWorkerRpc = async () => {
12635
12629
  const initializeExtensionManagementWorker = async () => {
12636
12630
  try {
12637
12631
  const rpc = await createExtensionManagementWorkerRpc();
12638
- set$d(rpc);
12632
+ set$e(rpc);
12639
12633
  } catch {
12640
12634
  // ignore
12641
12635
  }
@@ -12650,14 +12644,14 @@ const initializeOpenerWorker = async () => {
12650
12644
  commandMap: {},
12651
12645
  send: send$1
12652
12646
  });
12653
- set$c(rpc);
12647
+ set$d(rpc);
12654
12648
  };
12655
12649
 
12656
12650
  const initializeRendererWorker = async () => {
12657
12651
  const rpc = await create$a({
12658
12652
  commandMap: commandMap
12659
12653
  });
12660
- set$a(rpc);
12654
+ set$b(rpc);
12661
12655
  };
12662
12656
 
12663
12657
  const send = port => {
@@ -12668,12 +12662,12 @@ const initializeTextMeasurementWorker = async () => {
12668
12662
  commandMap: {},
12669
12663
  send
12670
12664
  });
12671
- set$b(rpc);
12665
+ set$c(rpc);
12672
12666
  };
12673
12667
 
12674
12668
  const listen = async () => {
12675
12669
  registerCommands(commandMap);
12676
- await Promise.all([initializeRendererWorker(), initializeExtensionHost(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
12670
+ await Promise.all([initializeRendererWorker(), initializeErrorWorker(), initializeExtensionHost(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
12677
12671
  };
12678
12672
 
12679
12673
  const CodeGeneratorInput = 'CodeGeneratorInput';
@@ -12721,10 +12715,10 @@ const renderFocus = {
12721
12715
  apply: (oldState, newState) => [Focus, '.CodeGeneratorInput', newState.focusSource],
12722
12716
  isEqual: (oldState, newState) => oldState.focused === newState.focused && oldState.focusSource === newState.focusSource
12723
12717
  };
12724
- const render$5 = [renderContent$1, renderBounds$1, renderFocus];
12718
+ const render$6 = [renderContent$1, renderBounds$1, renderFocus];
12725
12719
  const renderFull$2 = (oldState, newState) => {
12726
12720
  const commands = [];
12727
- for (const item of render$5) {
12721
+ for (const item of render$6) {
12728
12722
  if (!item.isEqual(oldState, newState)) {
12729
12723
  commands.push(item.apply(oldState, newState));
12730
12724
  }
@@ -12732,7 +12726,7 @@ const renderFull$2 = (oldState, newState) => {
12732
12726
  return commands;
12733
12727
  };
12734
12728
 
12735
- const render$4 = widget => {
12729
+ const render$5 = widget => {
12736
12730
  const commands = renderFull$2(widget.oldState, widget.newState);
12737
12731
  const wrappedCommands = [];
12738
12732
  const {
@@ -12748,16 +12742,16 @@ const render$4 = widget => {
12748
12742
  }
12749
12743
  return wrappedCommands;
12750
12744
  };
12751
- const add$3 = widget => {
12752
- return addWidget$1(widget, 'EditorCodeGenerator', render$4);
12745
+ const add$4 = widget => {
12746
+ return addWidget(widget, 'EditorCodeGenerator', render$5);
12753
12747
  };
12754
- const remove$3 = removeWidget$1;
12748
+ const remove$3 = removeWidget;
12755
12749
 
12756
12750
  const EditorCodeGeneratorWidget = {
12757
12751
  __proto__: null,
12758
- add: add$3,
12752
+ add: add$4,
12759
12753
  remove: remove$3,
12760
- render: render$4
12754
+ render: render$5
12761
12755
  };
12762
12756
 
12763
12757
  const renderFull$1 = (oldState, newState) => {
@@ -12767,8 +12761,8 @@ const renderFull$1 = (oldState, newState) => {
12767
12761
  return commands;
12768
12762
  };
12769
12763
 
12770
- const commandsToForward$1 = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetUid];
12771
- const render$3 = widget => {
12764
+ const commandsToForward$1 = [SetDom2, SetCss, AppendToBody, FocusSelector, SetBounds2, RegisterEventListeners, SetUid];
12765
+ const render$4 = widget => {
12772
12766
  const commands = renderFull$1(widget.oldState, widget.newState);
12773
12767
  const wrappedCommands = [];
12774
12768
  const {
@@ -12783,18 +12777,18 @@ const render$3 = widget => {
12783
12777
  }
12784
12778
  return wrappedCommands;
12785
12779
  };
12786
- const add$2 = widget => {
12787
- return addWidget$1(widget, 'ColorPicker', render$3);
12780
+ const add$3 = widget => {
12781
+ return addWidget(widget, 'ColorPicker', render$4);
12788
12782
  };
12789
- const remove$2 = removeWidget$1;
12783
+ const remove$2 = removeWidget;
12790
12784
  const Commands = {};
12791
12785
 
12792
12786
  const EditorColorPickerWidget = {
12793
12787
  __proto__: null,
12794
12788
  Commands,
12795
- add: add$2,
12789
+ add: add$3,
12796
12790
  remove: remove$2,
12797
- render: render$3
12791
+ render: render$4
12798
12792
  };
12799
12793
 
12800
12794
  const getCompletionDetailVirtualDom = content => {
@@ -12848,9 +12842,9 @@ const renderBounds = {
12848
12842
  },
12849
12843
  isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height
12850
12844
  };
12851
- const render$2 = [renderContent, renderBounds];
12845
+ const render$3 = [renderContent, renderBounds];
12852
12846
  const renderFull = (oldState, newState) => {
12853
- return renderParts(render$2, oldState, newState);
12847
+ return renderParts(render$3, oldState, newState);
12854
12848
  };
12855
12849
 
12856
12850
  const getWidgetState = (editor, id) => {
@@ -12869,7 +12863,7 @@ const getCompletionState = editor => {
12869
12863
  return getWidgetState(editor, Completion);
12870
12864
  };
12871
12865
 
12872
- const render$1 = widget => {
12866
+ const render$2 = widget => {
12873
12867
  const commands = renderFull(widget.oldState, widget.newState);
12874
12868
  const wrappedCommands = [];
12875
12869
  const {
@@ -12884,10 +12878,10 @@ const render$1 = widget => {
12884
12878
  }
12885
12879
  return wrappedCommands;
12886
12880
  };
12887
- const add$1 = widget => {
12888
- return addWidget$1(widget, 'EditorCompletionDetails', render$1);
12881
+ const add$2 = widget => {
12882
+ return addWidget(widget, 'EditorCompletionDetails', render$2);
12889
12883
  };
12890
- const remove$1 = removeWidget$1;
12884
+ const remove$1 = removeWidget;
12891
12885
  const handleEditorChange = (editor, state) => {
12892
12886
  const completionState = getCompletionState(editor);
12893
12887
  if (!completionState) {
@@ -12911,15 +12905,15 @@ const handleEditorDeleteLeft = (editor, state) => {
12911
12905
 
12912
12906
  const EditorCompletionDetailWidget = {
12913
12907
  __proto__: null,
12914
- add: add$1,
12908
+ add: add$2,
12915
12909
  handleEditorDeleteLeft,
12916
12910
  handleEditorType,
12917
12911
  remove: remove$1,
12918
- render: render$1
12912
+ render: render$2
12919
12913
  };
12920
12914
 
12921
12915
  const commandsToForward = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
12922
- const render = widget => {
12916
+ const render$1 = widget => {
12923
12917
  const commands = renderFull$4(widget.oldState, widget.newState);
12924
12918
  const wrappedCommands = [];
12925
12919
  const {
@@ -12934,8 +12928,8 @@ const render = widget => {
12934
12928
  }
12935
12929
  return wrappedCommands;
12936
12930
  };
12937
- const add = widget => {
12938
- return addWidget$1(widget, 'EditorCompletion', render);
12931
+ const add$1 = widget => {
12932
+ return addWidget(widget, 'EditorCompletion', render$1);
12939
12933
  };
12940
12934
  const remove = widget => {
12941
12935
  return [['Viewlet.dispose', widget.newState.uid]];
@@ -12946,21 +12940,48 @@ const {
12946
12940
 
12947
12941
  const EditorHoverWidget = {
12948
12942
  __proto__: null,
12949
- add,
12943
+ add: add$1,
12950
12944
  close,
12951
12945
  remove,
12946
+ render: render$1
12947
+ };
12948
+
12949
+ const render = widget => {
12950
+ const {
12951
+ message,
12952
+ uid,
12953
+ x,
12954
+ y
12955
+ } = widget.newState;
12956
+ const dom = [{
12957
+ childCount: 1,
12958
+ className: 'Viewlet EditorMessage EditorMessageText EditorOverlayMessage',
12959
+ style: `left:${x}px;top:${y}px;`,
12960
+ type: Div
12961
+ }, text(message)];
12962
+ return [[SetDom2, uid, dom]];
12963
+ };
12964
+ const add = widget => {
12965
+ return addWidget(widget, 'EditorMessage', render);
12966
+ };
12967
+
12968
+ const EditorMessageWidget = {
12969
+ __proto__: null,
12970
+ add,
12971
+ remove,
12952
12972
  render
12953
12973
  };
12954
12974
 
12955
12975
  const registerWidgets = () => {
12956
- set$7(ColorPicker$1, EditorColorPickerWidget);
12957
- set$7(Completion, EditorCompletionWidget);
12958
- set$7(CompletionDetail, EditorCompletionDetailWidget);
12959
- set$7(Find, EditorFindWidget);
12960
- set$7(Hover, EditorHoverWidget);
12961
- set$7(Rename$1, EditorRenameWidget);
12962
- set$7(SourceAction$1, EditorSourceActionWidget);
12963
- set$7(CodeGenerator, EditorCodeGeneratorWidget);
12976
+ set$8(ColorPicker$1, EditorColorPickerWidget);
12977
+ set$8(Completion, EditorCompletionWidget);
12978
+ set$8(CompletionDetail, EditorCompletionDetailWidget);
12979
+ set$8(Find, EditorFindWidget);
12980
+ set$8(Hover, EditorHoverWidget);
12981
+ set$8(Message, EditorMessageWidget);
12982
+ set$8(Rename$1, EditorRenameWidget);
12983
+ set$8(SourceAction$1, EditorSourceActionWidget);
12984
+ set$8(CodeGenerator, EditorCodeGeneratorWidget);
12964
12985
  };
12965
12986
 
12966
12987
  const handleUnhandledRejection = event => {