@lvce-editor/editor-worker 3.18.0 → 3.20.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.
@@ -258,9 +258,9 @@ const renderColorPickerDom = {
258
258
  return ['Viewlet.setDom2', dom];
259
259
  }
260
260
  };
261
- const render$a = [renderColorPickerDom, renderColor$1, renderOffsetX$1];
261
+ const render$b = [renderColorPickerDom, renderColor$1, renderOffsetX$1];
262
262
  const renderColorPicker = async (oldState, newState) => {
263
- return renderParts(render$a, oldState, newState);
263
+ return renderParts(render$b, oldState, newState);
264
264
  };
265
265
 
266
266
  // TODO use numeric enum
@@ -1213,7 +1213,7 @@ const set$6 = (id, fn) => {
1213
1213
  const get$6 = id => {
1214
1214
  return state$1$1.callbacks[id];
1215
1215
  };
1216
- const remove$4 = id => {
1216
+ const remove$5 = id => {
1217
1217
  delete state$1$1.callbacks[id];
1218
1218
  };
1219
1219
  const state$9 = {
@@ -1259,7 +1259,7 @@ const resolve = (id, args) => {
1259
1259
  return;
1260
1260
  }
1261
1261
  fn(args);
1262
- remove$4(id);
1262
+ remove$5(id);
1263
1263
  };
1264
1264
  const create$2$1 = (method, params) => {
1265
1265
  const {
@@ -1451,7 +1451,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
1451
1451
  const errorProperty = getErrorProperty(error, prettyError);
1452
1452
  return create$1$1(message, errorProperty);
1453
1453
  };
1454
- const create$a = (message, result) => {
1454
+ const create$c = (message, result) => {
1455
1455
  return {
1456
1456
  jsonrpc: Two,
1457
1457
  id: message.id,
@@ -1460,7 +1460,7 @@ const create$a = (message, result) => {
1460
1460
  };
1461
1461
  const getSuccessResponse = (message, result) => {
1462
1462
  const resultProperty = result ?? null;
1463
- return create$a(message, resultProperty);
1463
+ return create$c(message, resultProperty);
1464
1464
  };
1465
1465
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
1466
1466
  try {
@@ -1660,7 +1660,7 @@ const waitForFirstMessage$1 = async port => {
1660
1660
  return event;
1661
1661
  };
1662
1662
 
1663
- const create$9 = async () => {
1663
+ const create$b = async () => {
1664
1664
  const {
1665
1665
  port1,
1666
1666
  port2
@@ -1705,7 +1705,7 @@ const wrap$3 = port => {
1705
1705
 
1706
1706
  const IpcParentWithExtensionHostWorker = {
1707
1707
  __proto__: null,
1708
- create: create$9,
1708
+ create: create$b,
1709
1709
  wrap: wrap$3
1710
1710
  };
1711
1711
 
@@ -1713,7 +1713,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1713
1713
  await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
1714
1714
  };
1715
1715
 
1716
- const create$8 = async () => {
1716
+ const create$a = async () => {
1717
1717
  const {
1718
1718
  port1,
1719
1719
  port2
@@ -1758,7 +1758,7 @@ const wrap$1 = port => {
1758
1758
 
1759
1759
  const IpcParentWithSyntaxHighlightingWorker = {
1760
1760
  __proto__: null,
1761
- create: create$8,
1761
+ create: create$a,
1762
1762
  wrap: wrap$1
1763
1763
  };
1764
1764
 
@@ -1766,7 +1766,7 @@ const sendMessagePortToRendererProcess = async port => {
1766
1766
  await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
1767
1767
  };
1768
1768
 
1769
- const create$7 = async () => {
1769
+ const create$9 = async () => {
1770
1770
  const {
1771
1771
  port1,
1772
1772
  port2
@@ -1811,7 +1811,7 @@ const wrap = port => {
1811
1811
 
1812
1812
  const IpcParentWithRendererProcess = {
1813
1813
  __proto__: null,
1814
- create: create$7,
1814
+ create: create$9,
1815
1815
  wrap
1816
1816
  };
1817
1817
 
@@ -1828,7 +1828,7 @@ const getModule$1 = method => {
1828
1828
  }
1829
1829
  };
1830
1830
 
1831
- const create$6 = async ({
1831
+ const create$8 = async ({
1832
1832
  method,
1833
1833
  ...options
1834
1834
  }) => {
@@ -1846,7 +1846,7 @@ const create$6 = async ({
1846
1846
  const createRpc = method => {
1847
1847
  let _ipc;
1848
1848
  const listen = async () => {
1849
- const ipc = await create$6({
1849
+ const ipc = await create$8({
1850
1850
  method
1851
1851
  });
1852
1852
  handleIpc(ipc);
@@ -2122,7 +2122,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
2122
2122
  const supported = () => {
2123
2123
  return 'Segmenter' in Intl;
2124
2124
  };
2125
- const create$5 = () => {
2125
+ const create$7 = () => {
2126
2126
  // @ts-ignore
2127
2127
  const segmenter = new Intl.Segmenter();
2128
2128
  return {
@@ -2160,7 +2160,7 @@ const create$5 = () => {
2160
2160
 
2161
2161
  // @ts-ignore
2162
2162
  const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
2163
- const segmenter = create$5();
2163
+ const segmenter = create$7();
2164
2164
  const segments = segmenter.getSegments(line);
2165
2165
  const isMonospaceFont = false;
2166
2166
  const charWidth = 0;
@@ -2394,6 +2394,8 @@ const Completion = 'completion';
2394
2394
  const CompletionDetail$1 = 'completionDetail';
2395
2395
  const ColorPicker$1 = 'colorPicker';
2396
2396
  const Find = 'find';
2397
+ const Hover = 'hover';
2398
+ const SourceAction = 'sourceAction';
2397
2399
 
2398
2400
  const isCompletionWidget = widget => {
2399
2401
  return widget.id === Completion;
@@ -2441,7 +2443,11 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
2441
2443
  return editor;
2442
2444
  }
2443
2445
  const widget = factory();
2446
+ // @ts-ignore
2447
+ widget.newState.editorUid = editor.uid;
2444
2448
  const newState = await newStateGenerator(widget.newState);
2449
+ // @ts-ignore
2450
+ newState.editorUid = editor.uid;
2445
2451
  const latestWidget = {
2446
2452
  ...widget,
2447
2453
  newState
@@ -2460,12 +2466,12 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
2460
2466
  return newEditor;
2461
2467
  };
2462
2468
 
2463
- const create$4 = () => {
2469
+ const create$6 = () => {
2464
2470
  return Math.random();
2465
2471
  };
2466
2472
 
2467
- const create$3 = () => {
2468
- const completionUid = create$4();
2473
+ const create$5 = () => {
2474
+ const completionUid = create$6();
2469
2475
  const widget = {
2470
2476
  id: ColorPicker$1,
2471
2477
  oldState: {
@@ -2506,12 +2512,14 @@ const FocusFindWidgetReplaceAllButton = 47;
2506
2512
  const FocusFindWidgetCloseButton = 48;
2507
2513
  const FocusFindWidgetNextMatchButton = 49;
2508
2514
  const FocusFindWidgetPreviousMatchButton = 50;
2515
+ const FocusEditorHover = 51;
2516
+ const SourceActions = 52;
2509
2517
 
2510
- const newStateGenerator = state => {
2518
+ const newStateGenerator$1 = state => {
2511
2519
  return loadContent$3(state);
2512
2520
  };
2513
2521
  const openColorPicker = async editor => {
2514
- return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$3, newStateGenerator);
2522
+ return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$5, newStateGenerator$1);
2515
2523
  };
2516
2524
 
2517
2525
  const state$6 = {
@@ -2808,7 +2816,7 @@ const characterLeft = (line, columnIndex) => {
2808
2816
  if (!supported()) {
2809
2817
  return 1;
2810
2818
  }
2811
- const segmenter = create$5();
2819
+ const segmenter = create$7();
2812
2820
  const last = segmenter.at(line, columnIndex - 1);
2813
2821
  return columnIndex - last.index;
2814
2822
  };
@@ -2819,7 +2827,7 @@ const characterRight = (line, columnIndex) => {
2819
2827
  if (!supported()) {
2820
2828
  return 1;
2821
2829
  }
2822
- const segmenter = create$5();
2830
+ const segmenter = create$7();
2823
2831
  const next = segmenter.at(line, columnIndex);
2824
2832
  return next.segment.length;
2825
2833
  };
@@ -3401,7 +3409,10 @@ const UiStrings$1 = {
3401
3409
  NoTypeDefinitionFound: 'No type definition found',
3402
3410
  NoTypeDefinitionFoundFor: "No type definition found for '{PH1}'",
3403
3411
  NoResults: 'No Results',
3404
- Replace: 'Replace'
3412
+ Replace: 'Replace',
3413
+ SourceAction: 'Source Action',
3414
+ OrganizeImports: 'Organize Imports',
3415
+ SortImports: 'Sort Imports'
3405
3416
  };
3406
3417
  const noDefinitionFound = () => {
3407
3418
  return i18nString(UiStrings$1.NoDefinitionFound);
@@ -3422,6 +3433,12 @@ const noTypeDefinitionFound = () => {
3422
3433
  const noResults$1 = () => {
3423
3434
  return i18nString(UiStrings$1.NoResults);
3424
3435
  };
3436
+ const organizeImports$1 = () => {
3437
+ return i18nString(UiStrings$1.OrganizeImports);
3438
+ };
3439
+ const sortImports = () => {
3440
+ return i18nString(UiStrings$1.SortImports);
3441
+ };
3425
3442
 
3426
3443
  // @ts-ignore
3427
3444
  const goTo = async ({
@@ -4564,8 +4581,8 @@ const moveSelectionPx = (editor, x, y) => {
4564
4581
  return editorMoveSelection(editor, position);
4565
4582
  };
4566
4583
 
4567
- const create$2 = () => {
4568
- const completionUid = create$4();
4584
+ const create$4 = () => {
4585
+ const completionUid = create$6();
4569
4586
  const completionWidget = {
4570
4587
  id: Completion,
4571
4588
  oldState: {
@@ -5051,7 +5068,7 @@ const openCompletion = async editor => {
5051
5068
  if (hasWidget(widgets, Completion)) {
5052
5069
  return editor;
5053
5070
  }
5054
- const completionWidget = create$2();
5071
+ const completionWidget = create$4();
5055
5072
  const newWidgets = [...widgets, completionWidget];
5056
5073
  const newEditor = {
5057
5074
  ...editor,
@@ -5080,8 +5097,8 @@ const User = 1;
5080
5097
  const Script = 2;
5081
5098
  const Unknown$1 = 0;
5082
5099
 
5083
- const create$1 = () => {
5084
- const uid = create$4();
5100
+ const create$3 = () => {
5101
+ const uid = create$6();
5085
5102
  const widget = {
5086
5103
  id: Find,
5087
5104
  oldState: {
@@ -5478,7 +5495,7 @@ const openFind2 = async editor => {
5478
5495
  return latestState;
5479
5496
  };
5480
5497
  const fullFocus = true;
5481
- return addWidgetToEditor(Find, FindWidget, editor, create$1, newStateGenerator, fullFocus);
5498
+ return addWidgetToEditor(Find, FindWidget, editor, create$3, newStateGenerator, fullFocus);
5482
5499
  };
5483
5500
 
5484
5501
  const openFind = async state => {
@@ -6370,185 +6387,522 @@ const showHover = async state => {
6370
6387
  return state;
6371
6388
  };
6372
6389
 
6373
- const EditorSourceActions = 'EditorSourceActions';
6374
- const showSourceActions = async editor => {
6375
- // TODO
6376
- // 1. hide hover, completions, color picker
6377
- // 2. query source actions from extension host
6378
- // 3. show source actions menu
6390
+ const create$2 = () => {
6391
+ const uid = create$6();
6392
+ const widget = {
6393
+ id: Hover,
6394
+ oldState: {
6395
+ uid: uid,
6396
+ x: 0,
6397
+ y: 0,
6398
+ width: 0,
6399
+ height: 0,
6400
+ content: '',
6401
+ diagnostics: [],
6402
+ documentation: '',
6403
+ editorUid: 0,
6404
+ lineInfos: []
6405
+ },
6406
+ newState: {
6407
+ uid: uid,
6408
+ x: 0,
6409
+ y: 0,
6410
+ width: 0,
6411
+ height: 0,
6412
+ content: '',
6413
+ diagnostics: [],
6414
+ documentation: '',
6415
+ editorUid: 0,
6416
+ lineInfos: []
6417
+ }
6418
+ };
6419
+ return widget;
6420
+ };
6379
6421
 
6380
- await invoke$3('Viewlet.openWidget', EditorSourceActions);
6381
- return editor;
6422
+ const executeHoverProvider = (editor, offset) => {
6423
+ object(editor);
6424
+ number$1(offset);
6425
+ return execute({
6426
+ event: OnHover,
6427
+ editor,
6428
+ method: HoverExecute,
6429
+ args: [offset],
6430
+ noProviderFoundMessage: 'No hover provider found'
6431
+ });
6382
6432
  };
6383
6433
 
6384
- const compareString = (a, b) => {
6385
- return a.localeCompare(b);
6434
+ const getHover = async (editor, offset) => {
6435
+ object(editor);
6436
+ number$1(offset);
6437
+ // TODO invoke extension host worker directly
6438
+ const hover = await executeHoverProvider(editor, offset);
6439
+ return hover;
6386
6440
  };
6387
6441
 
6388
- // @ts-ignore
6389
- const getSortedLines = lines => {
6390
- const newLines = [...lines];
6391
- newLines.sort(compareString);
6392
- return newLines;
6442
+ let _ipc;
6443
+ const listen$5 = async () => {
6444
+ const ipc = await create$8({
6445
+ method: RendererProcess
6446
+ });
6447
+ handleIpc(ipc);
6448
+ _ipc = ipc;
6449
+ };
6450
+ const invoke = async (method, ...args) => {
6451
+ return invoke$5(_ipc, method, ...args);
6393
6452
  };
6394
- const origin = 'sort-lines-ascending';
6395
6453
 
6396
- // @ts-ignore
6397
- const getSortLinesAscendingChanges = (lines, selections) => {
6398
- const startRowIndex = selections[0];
6399
- const endRowIndex = selections[2];
6400
- const changes = [];
6401
- for (let i = 0; i < selections.length; i += 4) {
6402
- const selectionStartRow = selections[i];
6403
- const selectionStartColumn = selections[i + 1];
6404
- const selectionEndRow = selections[i + 2];
6405
- const selectionEndColumn = selections[i + 3];
6406
- const start = {
6407
- rowIndex: selectionStartRow,
6408
- columnIndex: selectionStartColumn
6409
- };
6410
- const end = {
6411
- rowIndex: selectionEndRow,
6412
- columnIndex: selectionEndColumn
6413
- };
6414
- const selection = {
6415
- start,
6416
- end
6417
- };
6418
- const selectionLines = lines.slice(startRowIndex, endRowIndex + 1);
6419
- const sortedSelectionLines = getSortedLines(selectionLines);
6420
- changes.push({
6421
- start: start,
6422
- end: end,
6423
- inserted: sortedSelectionLines,
6424
- deleted: getSelectionText({
6425
- lines
6426
- }, selection),
6427
- origin
6428
- });
6429
- }
6430
- return changes;
6454
+ const measureTextBlockHeight = (text, fontFamily, fontSize, lineHeight, width) => {
6455
+ return invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width);
6431
6456
  };
6432
6457
 
6433
- // @ts-ignore
6434
- const sortLinesAscending = editor => {
6435
- const {
6436
- lines,
6437
- selections
6438
- } = editor;
6439
- const changes = getSortLinesAscendingChanges(lines, selections);
6440
- return scheduleDocumentAndCursorsSelections(editor, changes);
6458
+ const deepCopy = value => {
6459
+ return structuredClone(value);
6441
6460
  };
6442
6461
 
6443
- const getTabCompletion = async editor => {
6444
- const {
6445
- selections
6446
- } = editor;
6447
- const rowIndex = selections[0];
6448
- const columnIndex = selections[1];
6449
- const offset = offsetAt(editor, rowIndex, columnIndex);
6450
- const tabCompletion = await invoke$3('ExtensionHostTabCompletion.executeTabCompletionProvider', editor, offset);
6451
- return tabCompletion;
6462
+ const getInitialLineState = initialLineState => {
6463
+ return deepCopy(initialLineState);
6452
6464
  };
6453
6465
 
6454
- const getChanges = (lines, selections, snippet) => {
6455
- // TODO verify that deleted fits in the line
6456
- const insertedLines = splitLines$2(snippet.inserted);
6457
- const changes = [];
6458
- const selectionChanges = [];
6459
- for (let i = 0; i < selections.length; i += 4) {
6460
- const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
6461
- if (insertedLines.length > 1) {
6462
- const line = getLine({
6463
- lines
6464
- }, selectionStartRow);
6465
- const indent = getIndent(line);
6466
- const insertedLinesHere = [insertedLines[0], ...insertedLines.slice(1).map(line => indent + line)];
6467
- const deleted = [''];
6468
- changes.push({
6469
- start: {
6470
- rowIndex: selectionStartRow,
6471
- columnIndex: selectionStartColumn - snippet.deleted
6472
- },
6473
- end: {
6474
- rowIndex: selectionEndRow,
6475
- columnIndex: selectionEndColumn
6476
- },
6477
- inserted: insertedLinesHere,
6478
- deleted,
6479
- origin: EditorSnippet
6480
- });
6481
- const lastInsertedLine = insertedLines.at(-1);
6482
- selectionChanges.push(selectionEndRow + insertedLines.length - deleted.length,
6483
- // @ts-ignore
6484
- selectionEndColumn + lastInsertedLine.length, selectionEndRow + insertedLines.length - deleted.length,
6485
- // @ts-ignore
6486
- selectionEndColumn + lastInsertedLine.length);
6487
- } else {
6488
- const line = insertedLines[0];
6489
- const placeholderIndex = line.indexOf('$0');
6490
- if (placeholderIndex === -1) {
6491
- const cursorColumnIndex = selectionStartColumn - snippet.deleted;
6492
- // @ts-ignore
6493
- selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
6494
- // @ts-ignore
6495
- changes.push({
6496
- start: {
6497
- rowIndex: selectionStartRow,
6498
- columnIndex: selectionStartColumn - snippet.deleted
6499
- },
6500
- end: {
6501
- rowIndex: selectionEndRow,
6502
- columnIndex: selectionEndColumn
6503
- },
6504
- inserted: insertedLines,
6505
- deleted: [''],
6506
- origin: EditorSnippet
6507
- });
6508
- } else {
6509
- const inserted = line.replace('$0', '');
6510
- const cursorColumnIndex = selectionEndColumn + 2;
6511
- selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
6512
- changes.push({
6513
- start: {
6514
- rowIndex: selectionStartRow,
6515
- columnIndex: selectionStartColumn - snippet.deleted
6516
- },
6517
- end: {
6518
- rowIndex: selectionEndRow,
6519
- columnIndex: selectionEndColumn
6520
- },
6521
- inserted: [inserted],
6522
- deleted: [''],
6523
- origin: EditorSnippet
6524
- });
6525
- }
6526
- }
6466
+ const getLineInfo$1 = (line, tokens, TokenMap) => {
6467
+ const tokensLength = tokens.length;
6468
+ let end = 0;
6469
+ let start = 0;
6470
+ const lineInfo = [];
6471
+ for (let i = 0; i < tokensLength; i += 2) {
6472
+ const tokenType = tokens[i];
6473
+ const tokenLength = tokens[i + 1];
6474
+ end += tokenLength;
6475
+ const text = line.slice(start, end);
6476
+ const className = `Token ${TokenMap[tokenType] || 'Unknown'}`;
6477
+ const normalizedText = text;
6478
+ lineInfo.push(normalizedText, className);
6479
+ start = end;
6527
6480
  }
6528
- return {
6529
- changes,
6530
- selectionChanges: new Uint32Array(selectionChanges)
6531
- };
6481
+ return lineInfo;
6532
6482
  };
6533
6483
 
6534
- // const getIndent =
6535
- // TODO rename to insertSnippet
6536
- // TODO handle snippet tabstops and cursors $0 -> becomes cursor
6537
- const editorSnippet = (editor, snippet) => {
6538
- // TODO verify that deleted fits in the line
6539
- const {
6540
- lines,
6541
- selections
6542
- } = editor;
6543
- const {
6544
- changes,
6545
- selectionChanges
6546
- } = getChanges(lines, selections, snippet);
6547
- return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
6484
+ const state = {
6485
+ warned: []
6548
6486
  };
6549
-
6550
- const getErrorMessage = error => {
6551
- return `${error}`;
6487
+ const flattenTokensArray = tokens => {
6488
+ const flattened = [];
6489
+ for (const token of tokens) {
6490
+ object(token);
6491
+ flattened.push(token.type, token.length);
6492
+ }
6493
+ return flattened;
6494
+ };
6495
+ const warnDeprecatedArrayReturn = (languageId, fn) => {
6496
+ if (state.warned.includes(fn)) {
6497
+ return;
6498
+ }
6499
+ state.warned.push(fn);
6500
+ console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
6501
+ };
6502
+ const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
6503
+ try {
6504
+ const lineState = tokenizeLine(line, lineStateAtStart);
6505
+ if (!lineState || !lineState.tokens || !lineState.state) {
6506
+ throw new Error('invalid tokenization result');
6507
+ }
6508
+ if (!hasArrayReturn) {
6509
+ warnDeprecatedArrayReturn(languageId, tokenizeLine);
6510
+ // workaround for old tokenizers
6511
+ lineState.tokens = flattenTokensArray(lineState.tokens);
6512
+ }
6513
+ return lineState;
6514
+ } catch (error) {
6515
+ console.error(error);
6516
+ return {
6517
+ tokens: [/* type */0, /* length */line.length],
6518
+ lineState: lineStateAtStart
6519
+ };
6520
+ }
6521
+ };
6522
+
6523
+ const getLineInfos = (lines, tokenizer, languageId) => {
6524
+ const lineInfos = [];
6525
+ const {
6526
+ tokenizeLine,
6527
+ initialLineState,
6528
+ hasArrayReturn,
6529
+ TokenMap
6530
+ } = tokenizer;
6531
+ let currentLineState = getInitialLineState(initialLineState);
6532
+ for (const line of lines) {
6533
+ const result = safeTokenizeLine(languageId, tokenizeLine, line, currentLineState, hasArrayReturn);
6534
+ const {
6535
+ tokens
6536
+ } = result;
6537
+ const lineInfo = getLineInfo$1(line, tokens, TokenMap);
6538
+ lineInfos.push(lineInfo);
6539
+ currentLineState = result;
6540
+ }
6541
+ return lineInfos;
6542
+ };
6543
+
6544
+ const tokenizeCodeBlock = async (codeBlock, languageId, tokenizerPath) => {
6545
+ await loadTokenizer(languageId, tokenizerPath);
6546
+ const tokenizer = getTokenizer(languageId);
6547
+ const lines = splitLines$2(codeBlock);
6548
+ const lineInfos = getLineInfos(lines, tokenizer, languageId);
6549
+ return lineInfos;
6550
+ };
6551
+
6552
+ const getHoverPosition = (position, selections) => {
6553
+ if (position) {
6554
+ return position;
6555
+ }
6556
+ const rowIndex = selections[0];
6557
+ const columnIndex = selections[1];
6558
+ return {
6559
+ rowIndex,
6560
+ columnIndex
6561
+ };
6562
+ };
6563
+ const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
6564
+ const matching = [];
6565
+ for (const diagnostic of diagnostics) {
6566
+ if (diagnostic.rowIndex === rowIndex) {
6567
+ matching.push(diagnostic);
6568
+ }
6569
+ }
6570
+ return matching;
6571
+ };
6572
+ const fallbackDisplayStringLanguageId = 'typescript'; // TODO remove this
6573
+
6574
+ const hoverDocumentationFontSize = 15;
6575
+ const hoverDocumentationFontFamily = 'Fira Code';
6576
+ const hoverDocumentationLineHeight = '1.33333';
6577
+ const hoverBorderLeft = 1;
6578
+ const hoverBorderRight = 1;
6579
+ const hoverPaddingLeft = 8;
6580
+ const hoverPaddingRight = 8;
6581
+ const hovverFullWidth = 400;
6582
+ const hoverDocumentationWidth = hovverFullWidth - hoverPaddingLeft - hoverPaddingRight - hoverBorderLeft - hoverBorderRight;
6583
+ const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) => {
6584
+ const x$1 = x(editor, rowIndex, wordStart);
6585
+ const y$1 = editor.height - y(editor, rowIndex) + editor.y + 40;
6586
+ return {
6587
+ x: x$1,
6588
+ y: y$1
6589
+ };
6590
+ };
6591
+ const getEditorHoverInfo = async (editorUid, position) => {
6592
+ number$1(editorUid);
6593
+ const instance = get$7(editorUid);
6594
+ const editor = instance.newState;
6595
+ const {
6596
+ selections
6597
+ } = editor;
6598
+ const {
6599
+ rowIndex,
6600
+ columnIndex
6601
+ } = getHoverPosition(position, selections);
6602
+ const offset = offsetAt(editor, rowIndex, columnIndex);
6603
+ const hover = await getHover(editor, offset);
6604
+ if (!hover) {
6605
+ return undefined;
6606
+ }
6607
+ const {
6608
+ displayString,
6609
+ documentation,
6610
+ displayStringLanguageId
6611
+ } = hover;
6612
+ const tokenizerPath = '';
6613
+ const lineInfos = await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath);
6614
+ const wordPart = await getWordBefore(editor, rowIndex, columnIndex);
6615
+ const wordStart = columnIndex - wordPart.length;
6616
+ await measureTextBlockHeight(documentation, hoverDocumentationFontFamily, hoverDocumentationFontSize, hoverDocumentationLineHeight, hoverDocumentationWidth);
6617
+ const {
6618
+ x,
6619
+ y
6620
+ } = getHoverPositionXy(editor, rowIndex, wordStart);
6621
+ const diagnostics = editor.diagnostics || [];
6622
+ const matchingDiagnostics = getMatchingDiagnostics(diagnostics, rowIndex);
6623
+ return {
6624
+ lineInfos,
6625
+ documentation,
6626
+ x,
6627
+ y,
6628
+ matchingDiagnostics
6629
+ };
6630
+ };
6631
+
6632
+ const loadHoverContent = async state => {
6633
+ // TODO
6634
+ const position = undefined;
6635
+ const hoverInfo = await getEditorHoverInfo(state.editorUid, position);
6636
+ if (!hoverInfo) {
6637
+ return state;
6638
+ }
6639
+ const {
6640
+ lineInfos,
6641
+ documentation,
6642
+ x,
6643
+ y,
6644
+ matchingDiagnostics
6645
+ } = hoverInfo;
6646
+ return {
6647
+ ...state,
6648
+ lineInfos,
6649
+ documentation,
6650
+ x,
6651
+ y,
6652
+ diagnostics: matchingDiagnostics
6653
+ };
6654
+ };
6655
+
6656
+ const newStateGenerator = state => {
6657
+ return loadHoverContent(state);
6658
+ };
6659
+ const showHover2 = async editor => {
6660
+ return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
6661
+ };
6662
+
6663
+ const EditorSourceActions = 'EditorSourceActions';
6664
+ const showSourceActions$1 = async editor => {
6665
+ // TODO
6666
+ // 1. hide hover, completions, color picker
6667
+ // 2. query source actions from extension host
6668
+ // 3. show source actions menu
6669
+
6670
+ await invoke$3('Viewlet.openWidget', EditorSourceActions);
6671
+ return editor;
6672
+ };
6673
+
6674
+ const getEditorSourceActions = async () => {
6675
+ const sourceActions = [{
6676
+ name: organizeImports$1(),
6677
+ command: 'Editor.organizeImports'
6678
+ }, {
6679
+ name: sortImports(),
6680
+ command: 'Editor.sortImports'
6681
+ }];
6682
+ return sourceActions;
6683
+ };
6684
+
6685
+ const loadSourceActions = async (editorUid, state) => {
6686
+ // const editor = GetEditor.getEditor(editorUid)
6687
+ // TODO request source actions information from extensions
6688
+ const sourceActions = await getEditorSourceActions();
6689
+ // TODO avoid side effect
6690
+ return {
6691
+ ...state,
6692
+ sourceActions,
6693
+ x: 200,
6694
+ y: -200,
6695
+ width: 250,
6696
+ height: 150,
6697
+ maxHeight: 150,
6698
+ focusedIndex: 0
6699
+ };
6700
+ };
6701
+
6702
+ const create$1 = () => {
6703
+ const completionUid = create$6();
6704
+ const widget = {
6705
+ id: SourceAction,
6706
+ oldState: {
6707
+ uid: completionUid,
6708
+ x: 0,
6709
+ y: 0,
6710
+ width: 0,
6711
+ height: 0,
6712
+ focusedIndex: 0,
6713
+ sourceActions: [],
6714
+ maxHeight: 0
6715
+ },
6716
+ newState: {
6717
+ uid: completionUid,
6718
+ x: 0,
6719
+ y: 0,
6720
+ width: 0,
6721
+ height: 0,
6722
+ focusedIndex: 0,
6723
+ sourceActions: [],
6724
+ maxHeight: 0
6725
+ }
6726
+ };
6727
+ return widget;
6728
+ };
6729
+
6730
+ const showSourceActions = async editor => {
6731
+ const uid = editor.uid;
6732
+ const newStateGenerator = state => {
6733
+ return loadSourceActions(uid, state);
6734
+ };
6735
+ return addWidgetToEditor(SourceAction, SourceActions, editor, create$1, newStateGenerator);
6736
+ };
6737
+
6738
+ const compareString = (a, b) => {
6739
+ return a.localeCompare(b);
6740
+ };
6741
+
6742
+ // @ts-ignore
6743
+ const getSortedLines = lines => {
6744
+ const newLines = [...lines];
6745
+ newLines.sort(compareString);
6746
+ return newLines;
6747
+ };
6748
+ const origin = 'sort-lines-ascending';
6749
+
6750
+ // @ts-ignore
6751
+ const getSortLinesAscendingChanges = (lines, selections) => {
6752
+ const startRowIndex = selections[0];
6753
+ const endRowIndex = selections[2];
6754
+ const changes = [];
6755
+ for (let i = 0; i < selections.length; i += 4) {
6756
+ const selectionStartRow = selections[i];
6757
+ const selectionStartColumn = selections[i + 1];
6758
+ const selectionEndRow = selections[i + 2];
6759
+ const selectionEndColumn = selections[i + 3];
6760
+ const start = {
6761
+ rowIndex: selectionStartRow,
6762
+ columnIndex: selectionStartColumn
6763
+ };
6764
+ const end = {
6765
+ rowIndex: selectionEndRow,
6766
+ columnIndex: selectionEndColumn
6767
+ };
6768
+ const selection = {
6769
+ start,
6770
+ end
6771
+ };
6772
+ const selectionLines = lines.slice(startRowIndex, endRowIndex + 1);
6773
+ const sortedSelectionLines = getSortedLines(selectionLines);
6774
+ changes.push({
6775
+ start: start,
6776
+ end: end,
6777
+ inserted: sortedSelectionLines,
6778
+ deleted: getSelectionText({
6779
+ lines
6780
+ }, selection),
6781
+ origin
6782
+ });
6783
+ }
6784
+ return changes;
6785
+ };
6786
+
6787
+ // @ts-ignore
6788
+ const sortLinesAscending = editor => {
6789
+ const {
6790
+ lines,
6791
+ selections
6792
+ } = editor;
6793
+ const changes = getSortLinesAscendingChanges(lines, selections);
6794
+ return scheduleDocumentAndCursorsSelections(editor, changes);
6795
+ };
6796
+
6797
+ const getTabCompletion = async editor => {
6798
+ const {
6799
+ selections
6800
+ } = editor;
6801
+ const rowIndex = selections[0];
6802
+ const columnIndex = selections[1];
6803
+ const offset = offsetAt(editor, rowIndex, columnIndex);
6804
+ const tabCompletion = await invoke$3('ExtensionHostTabCompletion.executeTabCompletionProvider', editor, offset);
6805
+ return tabCompletion;
6806
+ };
6807
+
6808
+ const getChanges = (lines, selections, snippet) => {
6809
+ // TODO verify that deleted fits in the line
6810
+ const insertedLines = splitLines$2(snippet.inserted);
6811
+ const changes = [];
6812
+ const selectionChanges = [];
6813
+ for (let i = 0; i < selections.length; i += 4) {
6814
+ const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
6815
+ if (insertedLines.length > 1) {
6816
+ const line = getLine({
6817
+ lines
6818
+ }, selectionStartRow);
6819
+ const indent = getIndent(line);
6820
+ const insertedLinesHere = [insertedLines[0], ...insertedLines.slice(1).map(line => indent + line)];
6821
+ const deleted = [''];
6822
+ changes.push({
6823
+ start: {
6824
+ rowIndex: selectionStartRow,
6825
+ columnIndex: selectionStartColumn - snippet.deleted
6826
+ },
6827
+ end: {
6828
+ rowIndex: selectionEndRow,
6829
+ columnIndex: selectionEndColumn
6830
+ },
6831
+ inserted: insertedLinesHere,
6832
+ deleted,
6833
+ origin: EditorSnippet
6834
+ });
6835
+ const lastInsertedLine = insertedLines.at(-1);
6836
+ selectionChanges.push(selectionEndRow + insertedLines.length - deleted.length,
6837
+ // @ts-ignore
6838
+ selectionEndColumn + lastInsertedLine.length, selectionEndRow + insertedLines.length - deleted.length,
6839
+ // @ts-ignore
6840
+ selectionEndColumn + lastInsertedLine.length);
6841
+ } else {
6842
+ const line = insertedLines[0];
6843
+ const placeholderIndex = line.indexOf('$0');
6844
+ if (placeholderIndex === -1) {
6845
+ const cursorColumnIndex = selectionStartColumn - snippet.deleted;
6846
+ // @ts-ignore
6847
+ selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
6848
+ // @ts-ignore
6849
+ changes.push({
6850
+ start: {
6851
+ rowIndex: selectionStartRow,
6852
+ columnIndex: selectionStartColumn - snippet.deleted
6853
+ },
6854
+ end: {
6855
+ rowIndex: selectionEndRow,
6856
+ columnIndex: selectionEndColumn
6857
+ },
6858
+ inserted: insertedLines,
6859
+ deleted: [''],
6860
+ origin: EditorSnippet
6861
+ });
6862
+ } else {
6863
+ const inserted = line.replace('$0', '');
6864
+ const cursorColumnIndex = selectionEndColumn + 2;
6865
+ selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
6866
+ changes.push({
6867
+ start: {
6868
+ rowIndex: selectionStartRow,
6869
+ columnIndex: selectionStartColumn - snippet.deleted
6870
+ },
6871
+ end: {
6872
+ rowIndex: selectionEndRow,
6873
+ columnIndex: selectionEndColumn
6874
+ },
6875
+ inserted: [inserted],
6876
+ deleted: [''],
6877
+ origin: EditorSnippet
6878
+ });
6879
+ }
6880
+ }
6881
+ }
6882
+ return {
6883
+ changes,
6884
+ selectionChanges: new Uint32Array(selectionChanges)
6885
+ };
6886
+ };
6887
+
6888
+ // const getIndent =
6889
+ // TODO rename to insertSnippet
6890
+ // TODO handle snippet tabstops and cursors $0 -> becomes cursor
6891
+ const editorSnippet = (editor, snippet) => {
6892
+ // TODO verify that deleted fits in the line
6893
+ const {
6894
+ lines,
6895
+ selections
6896
+ } = editor;
6897
+ const {
6898
+ changes,
6899
+ selectionChanges
6900
+ } = getChanges(lines, selections, snippet);
6901
+ return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
6902
+ };
6903
+
6904
+ const getErrorMessage = error => {
6905
+ return `${error}`;
6552
6906
  };
6553
6907
  const tabCompletion = async editor => {
6554
6908
  try {
@@ -7126,459 +7480,249 @@ const editorUnindent = editor => {
7126
7480
  deleted: 2
7127
7481
  });
7128
7482
  // @ts-ignore
7129
- cursorEdits.push({
7130
- rowIndex: editor.cursor.rowIndex,
7131
- columnIndex: editor.cursor.columnIndex - 2
7132
- });
7133
- // @ts-ignore
7134
- undefined(editor, documentEdits, cursorEdits);
7135
- };
7136
- // const editor = {
7137
- // textDocument: {
7138
- // lines: [' line 1'],
7139
- // },
7140
- // cursor: {
7141
- // rowIndex: 0,
7142
- // columnIndex: 8,
7143
- // },
7144
- // selections: [
7145
- // {
7146
- // start: {
7147
- // rowIndex: 0,
7148
- // columnIndex: 0,
7149
- // },
7150
- // end: {
7151
- // rowIndex: 0,
7152
- // columnIndex: 8,
7153
- // },
7154
- // },
7155
- // ],
7156
- // tokenizer: TokenizePlainText,
7157
- // }
7158
- // editorUnindent(editor)
7159
-
7160
- // editor.lines //?
7161
-
7162
- const isCompletionDetailWidget = widget => {
7163
- return widget.id === CompletionDetail$1;
7164
- };
7165
- const closeDetails = editor => {
7166
- const {
7167
- widgets
7168
- } = editor;
7169
- const index = widgets.findIndex(isCompletionDetailWidget);
7170
- if (index === -1) {
7171
- return editor;
7172
- }
7173
- const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
7174
- return {
7175
- ...editor,
7176
- widgets: newWidgets
7177
- };
7178
- };
7179
-
7180
- const getCompletionState = editor => {
7181
- return getWidgetState(editor, Completion);
7182
- };
7183
-
7184
- const isCompletion$1 = widget => {
7185
- return widget.id === Completion;
7186
- };
7187
- const focusIndex = (editor, index) => {
7188
- const child = getCompletionState(editor);
7189
- if (index === -1) {
7190
- return editor;
7191
- }
7192
- const childIndex = editor.widgets.findIndex(isCompletion$1);
7193
- // TODO scroll up/down if necessary
7194
- const childWidget = editor.widgets[childIndex];
7195
- const newWidget = {
7196
- ...childWidget,
7197
- newState: {
7198
- ...child,
7199
- focusedIndex: index,
7200
- focused: true
7201
- }
7202
- };
7203
- const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
7204
- return {
7205
- ...editor,
7206
- widgets: newWidgets
7207
- };
7208
- };
7209
-
7210
- const focusFirst = editor => {
7211
- const firstIndex = 0;
7212
- return focusIndex(editor, firstIndex);
7213
- };
7214
-
7215
- const focusNext = editor => {
7216
- const child = getCompletionState(editor);
7217
- if (!child) {
7218
- return editor;
7219
- }
7220
- const nextIndex = child.focusedIndex + 1;
7221
- return focusIndex(editor, nextIndex);
7222
- };
7223
-
7224
- const focusPrevious = editor => {
7225
- const child = getCompletionState(editor);
7226
- if (!child) {
7227
- return editor;
7228
- }
7229
- const previousIndex = child.focusedIndex - 1;
7230
- return focusIndex(editor, previousIndex);
7231
- };
7232
-
7233
- const create = () => {
7234
- const completionUid = create$4();
7235
- const completionWidget = {
7236
- id: CompletionDetail$1,
7237
- oldState: {
7238
- content: '',
7239
- uid: completionUid,
7240
- x: 0,
7241
- y: 0,
7242
- width: 0,
7243
- height: 0
7244
- },
7245
- newState: {
7246
- content: '',
7247
- uid: completionUid,
7248
- x: 0,
7249
- y: 0,
7250
- width: 0,
7251
- height: 0
7252
- }
7253
- };
7254
- return completionWidget;
7255
- };
7256
-
7257
- const getCompletionDetailBounds = (completionBounds, borderSize) => {
7258
- return {
7259
- x: completionBounds.x + completionBounds.width - borderSize,
7260
- y: completionBounds.y,
7261
- width: 100,
7262
- height: 100
7263
- };
7264
- };
7265
-
7266
- const openDetails = editor => {
7267
- const child = getCompletionState(editor);
7268
- if (!child) {
7269
- return editor;
7270
- }
7271
- // TODO avoid closure
7272
- const newStateGenerator = state => {
7273
- const borderSize = 1;
7274
- const newestState = {
7275
- ...state,
7276
- content: 'abc',
7277
- ...getCompletionDetailBounds(child, borderSize)
7278
- };
7279
- return newestState;
7280
- };
7281
- return addWidgetToEditor(CompletionDetail$1, CompletionDetail, editor, create, newStateGenerator);
7282
- };
7283
-
7284
- const getEdits = async (editor, completionItem) => {
7285
- const child = getCompletionState(editor);
7286
- // @ts-ignore
7287
- const {
7288
- leadingWord,
7289
- uid
7290
- } = child;
7291
- const word = completionItem.label;
7292
- const resolvedItem = await resolveCompletion(editor, word, completionItem);
7293
- const inserted = resolvedItem ? resolvedItem.snippet : word;
7294
- // TODO type and dispose commands should be sent to renderer process at the same time
7295
- const {
7296
- selections
7297
- } = editor;
7298
- const [startRowIndex, startColumnIndex] = selections;
7299
- const leadingWordLength = leadingWord.length;
7300
- const replaceRange$1 = new Uint32Array([startRowIndex, startColumnIndex - leadingWordLength, startRowIndex, startColumnIndex]);
7301
- const changes = replaceRange(editor, replaceRange$1, [inserted], '');
7302
- return changes;
7483
+ cursorEdits.push({
7484
+ rowIndex: editor.cursor.rowIndex,
7485
+ columnIndex: editor.cursor.columnIndex - 2
7486
+ });
7487
+ // @ts-ignore
7488
+ undefined(editor, documentEdits, cursorEdits);
7303
7489
  };
7304
- const isCompletion = widget => {
7305
- return widget.id === Completion;
7490
+ // const editor = {
7491
+ // textDocument: {
7492
+ // lines: [' line 1'],
7493
+ // },
7494
+ // cursor: {
7495
+ // rowIndex: 0,
7496
+ // columnIndex: 8,
7497
+ // },
7498
+ // selections: [
7499
+ // {
7500
+ // start: {
7501
+ // rowIndex: 0,
7502
+ // columnIndex: 0,
7503
+ // },
7504
+ // end: {
7505
+ // rowIndex: 0,
7506
+ // columnIndex: 8,
7507
+ // },
7508
+ // },
7509
+ // ],
7510
+ // tokenizer: TokenizePlainText,
7511
+ // }
7512
+ // editorUnindent(editor)
7513
+
7514
+ // editor.lines //?
7515
+
7516
+ const isCompletionDetailWidget = widget => {
7517
+ return widget.id === CompletionDetail$1;
7306
7518
  };
7307
- const select = async (editor, completionItem) => {
7308
- const changes = await getEdits(editor, completionItem);
7309
- const index = editor.widgets.indexOf
7310
- // ViewletModuleId.EditorCompletion
7311
- ();
7312
- if (index !== -1) {
7313
- editor.widgets.splice(index, 1);
7314
- editor.completionState = None$1;
7315
- editor.completionUid = 0;
7316
- }
7317
- // TODO dispose completion widget
7318
- // TODO apply edit in editor worker instead of asking renderer worker
7319
- // await RendererWorker.invoke('Viewlet.dispose', state.uid)
7519
+ const closeDetails = editor => {
7320
7520
  const {
7321
7521
  widgets
7322
7522
  } = editor;
7323
- const completionWidgetIndex = editor.widgets.findIndex(isCompletion);
7324
- const newWidgets = [...widgets.slice(0, completionWidgetIndex), ...widgets.slice(completionWidgetIndex + 1)];
7325
- const intermediateEditor = await applyEdit(editor, changes);
7523
+ const index = widgets.findIndex(isCompletionDetailWidget);
7524
+ if (index === -1) {
7525
+ return editor;
7526
+ }
7527
+ const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
7326
7528
  return {
7327
- ...intermediateEditor,
7529
+ ...editor,
7328
7530
  widgets: newWidgets
7329
7531
  };
7330
7532
  };
7331
- const selectIndex = (editor, index) => {
7332
- const child = getCompletionState(editor);
7333
- if (!child) {
7334
- return editor;
7335
- }
7336
- const {
7337
- items
7338
- } = child;
7339
- if (index === -1) {
7340
- return editor;
7341
- }
7342
- if (index > items.length) {
7343
- throw new Error('index too large');
7344
- }
7345
- const actualIndex = index;
7346
- const completionItem = items[actualIndex];
7347
- return select(editor, completionItem);
7533
+
7534
+ const getCompletionState = editor => {
7535
+ return getWidgetState(editor, Completion);
7348
7536
  };
7349
7537
 
7350
- const selectCurrent = editor => {
7538
+ const isCompletion$1 = widget => {
7539
+ return widget.id === Completion;
7540
+ };
7541
+ const focusIndex = (editor, index) => {
7351
7542
  const child = getCompletionState(editor);
7352
- if (!child) {
7543
+ if (index === -1) {
7353
7544
  return editor;
7354
7545
  }
7355
- const {
7356
- focusedIndex
7357
- } = child;
7358
- return selectIndex(editor, focusedIndex);
7546
+ const childIndex = editor.widgets.findIndex(isCompletion$1);
7547
+ // TODO scroll up/down if necessary
7548
+ const childWidget = editor.widgets[childIndex];
7549
+ const newWidget = {
7550
+ ...childWidget,
7551
+ newState: {
7552
+ ...child,
7553
+ focusedIndex: index,
7554
+ focused: true
7555
+ }
7556
+ };
7557
+ const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
7558
+ return {
7559
+ ...editor,
7560
+ widgets: newWidgets
7561
+ };
7359
7562
  };
7360
7563
 
7361
- const getCompletionDetailState = editor => {
7362
- return getWidgetState(editor, CompletionDetail$1);
7564
+ const focusFirst = editor => {
7565
+ const firstIndex = 0;
7566
+ return focusIndex(editor, firstIndex);
7363
7567
  };
7364
7568
 
7365
- const toggleDetails = editor => {
7366
- const child = getCompletionDetailState(editor);
7569
+ const focusNext = editor => {
7570
+ const child = getCompletionState(editor);
7367
7571
  if (!child) {
7368
- return openDetails(editor);
7369
- }
7370
- return closeDetails(editor);
7371
- };
7372
-
7373
- const executeHoverProvider = (editor, offset) => {
7374
- object(editor);
7375
- number$1(offset);
7376
- return execute({
7377
- event: OnHover,
7378
- editor,
7379
- method: HoverExecute,
7380
- args: [offset],
7381
- noProviderFoundMessage: 'No hover provider found'
7382
- });
7383
- };
7384
-
7385
- const getHover = async (editor, offset) => {
7386
- object(editor);
7387
- number$1(offset);
7388
- // TODO invoke extension host worker directly
7389
- const hover = await executeHoverProvider(editor, offset);
7390
- return hover;
7391
- };
7392
-
7393
- let _ipc;
7394
- const listen$5 = async () => {
7395
- const ipc = await create$6({
7396
- method: RendererProcess
7397
- });
7398
- handleIpc(ipc);
7399
- _ipc = ipc;
7400
- };
7401
- const invoke = async (method, ...args) => {
7402
- return invoke$5(_ipc, method, ...args);
7403
- };
7404
-
7405
- const measureTextBlockHeight = (text, fontFamily, fontSize, lineHeight, width) => {
7406
- return invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width);
7407
- };
7408
-
7409
- const deepCopy = value => {
7410
- return structuredClone(value);
7411
- };
7412
-
7413
- const getInitialLineState = initialLineState => {
7414
- return deepCopy(initialLineState);
7415
- };
7416
-
7417
- const getLineInfo$1 = (line, tokens, TokenMap) => {
7418
- const tokensLength = tokens.length;
7419
- let end = 0;
7420
- let start = 0;
7421
- const lineInfo = [];
7422
- for (let i = 0; i < tokensLength; i += 2) {
7423
- const tokenType = tokens[i];
7424
- const tokenLength = tokens[i + 1];
7425
- end += tokenLength;
7426
- const text = line.slice(start, end);
7427
- const className = `Token ${TokenMap[tokenType] || 'Unknown'}`;
7428
- const normalizedText = text;
7429
- lineInfo.push(normalizedText, className);
7430
- start = end;
7431
- }
7432
- return lineInfo;
7433
- };
7434
-
7435
- const state = {
7436
- warned: []
7437
- };
7438
- const flattenTokensArray = tokens => {
7439
- const flattened = [];
7440
- for (const token of tokens) {
7441
- object(token);
7442
- flattened.push(token.type, token.length);
7443
- }
7444
- return flattened;
7445
- };
7446
- const warnDeprecatedArrayReturn = (languageId, fn) => {
7447
- if (state.warned.includes(fn)) {
7448
- return;
7449
- }
7450
- state.warned.push(fn);
7451
- console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
7452
- };
7453
- const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
7454
- try {
7455
- const lineState = tokenizeLine(line, lineStateAtStart);
7456
- if (!lineState || !lineState.tokens || !lineState.state) {
7457
- throw new Error('invalid tokenization result');
7458
- }
7459
- if (!hasArrayReturn) {
7460
- warnDeprecatedArrayReturn(languageId, tokenizeLine);
7461
- // workaround for old tokenizers
7462
- lineState.tokens = flattenTokensArray(lineState.tokens);
7463
- }
7464
- return lineState;
7465
- } catch (error) {
7466
- console.error(error);
7467
- return {
7468
- tokens: [/* type */0, /* length */line.length],
7469
- lineState: lineStateAtStart
7470
- };
7572
+ return editor;
7471
7573
  }
7574
+ const nextIndex = child.focusedIndex + 1;
7575
+ return focusIndex(editor, nextIndex);
7472
7576
  };
7473
7577
 
7474
- const getLineInfos = (lines, tokenizer, languageId) => {
7475
- const lineInfos = [];
7476
- const {
7477
- tokenizeLine,
7478
- initialLineState,
7479
- hasArrayReturn,
7480
- TokenMap
7481
- } = tokenizer;
7482
- let currentLineState = getInitialLineState(initialLineState);
7483
- for (const line of lines) {
7484
- const result = safeTokenizeLine(languageId, tokenizeLine, line, currentLineState, hasArrayReturn);
7485
- const {
7486
- tokens
7487
- } = result;
7488
- const lineInfo = getLineInfo$1(line, tokens, TokenMap);
7489
- lineInfos.push(lineInfo);
7490
- currentLineState = result;
7578
+ const focusPrevious = editor => {
7579
+ const child = getCompletionState(editor);
7580
+ if (!child) {
7581
+ return editor;
7491
7582
  }
7492
- return lineInfos;
7583
+ const previousIndex = child.focusedIndex - 1;
7584
+ return focusIndex(editor, previousIndex);
7493
7585
  };
7494
7586
 
7495
- const tokenizeCodeBlock = async (codeBlock, languageId, tokenizerPath) => {
7496
- await loadTokenizer(languageId, tokenizerPath);
7497
- const tokenizer = getTokenizer(languageId);
7498
- const lines = splitLines$2(codeBlock);
7499
- const lineInfos = getLineInfos(lines, tokenizer, languageId);
7500
- return lineInfos;
7587
+ const create = () => {
7588
+ const completionUid = create$6();
7589
+ const completionWidget = {
7590
+ id: CompletionDetail$1,
7591
+ oldState: {
7592
+ content: '',
7593
+ uid: completionUid,
7594
+ x: 0,
7595
+ y: 0,
7596
+ width: 0,
7597
+ height: 0
7598
+ },
7599
+ newState: {
7600
+ content: '',
7601
+ uid: completionUid,
7602
+ x: 0,
7603
+ y: 0,
7604
+ width: 0,
7605
+ height: 0
7606
+ }
7607
+ };
7608
+ return completionWidget;
7501
7609
  };
7502
7610
 
7503
- const getHoverPosition = (position, selections) => {
7504
- if (position) {
7505
- return position;
7506
- }
7507
- const rowIndex = selections[0];
7508
- const columnIndex = selections[1];
7611
+ const getCompletionDetailBounds = (completionBounds, borderSize) => {
7509
7612
  return {
7510
- rowIndex,
7511
- columnIndex
7613
+ x: completionBounds.x + completionBounds.width - borderSize,
7614
+ y: completionBounds.y,
7615
+ width: 100,
7616
+ height: 100
7512
7617
  };
7513
7618
  };
7514
- const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
7515
- const matching = [];
7516
- for (const diagnostic of diagnostics) {
7517
- if (diagnostic.rowIndex === rowIndex) {
7518
- matching.push(diagnostic);
7519
- }
7520
- }
7521
- return matching;
7522
- };
7523
- const fallbackDisplayStringLanguageId = 'typescript'; // TODO remove this
7524
7619
 
7525
- const hoverDocumentationFontSize = 15;
7526
- const hoverDocumentationFontFamily = 'Fira Code';
7527
- const hoverDocumentationLineHeight = '1.33333';
7528
- const hoverBorderLeft = 1;
7529
- const hoverBorderRight = 1;
7530
- const hoverPaddingLeft = 8;
7531
- const hoverPaddingRight = 8;
7532
- const hovverFullWidth = 400;
7533
- const hoverDocumentationWidth = hovverFullWidth - hoverPaddingLeft - hoverPaddingRight - hoverBorderLeft - hoverBorderRight;
7534
- const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) => {
7535
- const x$1 = x(editor, rowIndex, wordStart);
7536
- const y$1 = editor.height - y(editor, rowIndex) + editor.y + 40;
7537
- return {
7538
- x: x$1,
7539
- y: y$1
7620
+ const openDetails = editor => {
7621
+ const child = getCompletionState(editor);
7622
+ if (!child) {
7623
+ return editor;
7624
+ }
7625
+ // TODO avoid closure
7626
+ const newStateGenerator = state => {
7627
+ const borderSize = 1;
7628
+ const newestState = {
7629
+ ...state,
7630
+ content: 'abc',
7631
+ ...getCompletionDetailBounds(child, borderSize)
7632
+ };
7633
+ return newestState;
7540
7634
  };
7635
+ return addWidgetToEditor(CompletionDetail$1, CompletionDetail, editor, create, newStateGenerator);
7541
7636
  };
7542
- const getEditorHoverInfo = async (editorUid, position) => {
7543
- number$1(editorUid);
7544
- const instance = get$7(editorUid);
7545
- const editor = instance.newState;
7637
+
7638
+ const getEdits = async (editor, completionItem) => {
7639
+ const child = getCompletionState(editor);
7640
+ // @ts-ignore
7641
+ const {
7642
+ leadingWord,
7643
+ uid
7644
+ } = child;
7645
+ const word = completionItem.label;
7646
+ const resolvedItem = await resolveCompletion(editor, word, completionItem);
7647
+ const inserted = resolvedItem ? resolvedItem.snippet : word;
7648
+ // TODO type and dispose commands should be sent to renderer process at the same time
7546
7649
  const {
7547
7650
  selections
7548
7651
  } = editor;
7549
- const {
7550
- rowIndex,
7551
- columnIndex
7552
- } = getHoverPosition(position, selections);
7553
- const offset = offsetAt(editor, rowIndex, columnIndex);
7554
- const hover = await getHover(editor, offset);
7555
- if (!hover) {
7556
- return undefined;
7652
+ const [startRowIndex, startColumnIndex] = selections;
7653
+ const leadingWordLength = leadingWord.length;
7654
+ const replaceRange$1 = new Uint32Array([startRowIndex, startColumnIndex - leadingWordLength, startRowIndex, startColumnIndex]);
7655
+ const changes = replaceRange(editor, replaceRange$1, [inserted], '');
7656
+ return changes;
7657
+ };
7658
+ const isCompletion = widget => {
7659
+ return widget.id === Completion;
7660
+ };
7661
+ const select = async (editor, completionItem) => {
7662
+ const changes = await getEdits(editor, completionItem);
7663
+ const index = editor.widgets.indexOf
7664
+ // ViewletModuleId.EditorCompletion
7665
+ ();
7666
+ if (index !== -1) {
7667
+ editor.widgets.splice(index, 1);
7668
+ editor.completionState = None$1;
7669
+ editor.completionUid = 0;
7557
7670
  }
7671
+ // TODO dispose completion widget
7672
+ // TODO apply edit in editor worker instead of asking renderer worker
7673
+ // await RendererWorker.invoke('Viewlet.dispose', state.uid)
7558
7674
  const {
7559
- displayString,
7560
- documentation,
7561
- displayStringLanguageId
7562
- } = hover;
7563
- const tokenizerPath = '';
7564
- const lineInfos = await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath);
7565
- const wordPart = await getWordBefore(editor, rowIndex, columnIndex);
7566
- const wordStart = columnIndex - wordPart.length;
7567
- await measureTextBlockHeight(documentation, hoverDocumentationFontFamily, hoverDocumentationFontSize, hoverDocumentationLineHeight, hoverDocumentationWidth);
7568
- const {
7569
- x,
7570
- y
7571
- } = getHoverPositionXy(editor, rowIndex, wordStart);
7572
- const diagnostics = editor.diagnostics || [];
7573
- const matchingDiagnostics = getMatchingDiagnostics(diagnostics, rowIndex);
7675
+ widgets
7676
+ } = editor;
7677
+ const completionWidgetIndex = editor.widgets.findIndex(isCompletion);
7678
+ const newWidgets = [...widgets.slice(0, completionWidgetIndex), ...widgets.slice(completionWidgetIndex + 1)];
7679
+ const intermediateEditor = await applyEdit(editor, changes);
7574
7680
  return {
7575
- lineInfos,
7576
- documentation,
7577
- x,
7578
- y,
7579
- matchingDiagnostics
7681
+ ...intermediateEditor,
7682
+ widgets: newWidgets
7580
7683
  };
7581
7684
  };
7685
+ const selectIndex = (editor, index) => {
7686
+ const child = getCompletionState(editor);
7687
+ if (!child) {
7688
+ return editor;
7689
+ }
7690
+ const {
7691
+ items
7692
+ } = child;
7693
+ if (index === -1) {
7694
+ return editor;
7695
+ }
7696
+ if (index > items.length) {
7697
+ throw new Error('index too large');
7698
+ }
7699
+ const actualIndex = index;
7700
+ const completionItem = items[actualIndex];
7701
+ return select(editor, completionItem);
7702
+ };
7703
+
7704
+ const selectCurrent = editor => {
7705
+ const child = getCompletionState(editor);
7706
+ if (!child) {
7707
+ return editor;
7708
+ }
7709
+ const {
7710
+ focusedIndex
7711
+ } = child;
7712
+ return selectIndex(editor, focusedIndex);
7713
+ };
7714
+
7715
+ const getCompletionDetailState = editor => {
7716
+ return getWidgetState(editor, CompletionDetail$1);
7717
+ };
7718
+
7719
+ const toggleDetails = editor => {
7720
+ const child = getCompletionDetailState(editor);
7721
+ if (!child) {
7722
+ return openDetails(editor);
7723
+ }
7724
+ return closeDetails(editor);
7725
+ };
7582
7726
 
7583
7727
  const loadContent = async (editorUid, state, position) => {
7584
7728
  const hoverInfo = await getEditorHoverInfo(editorUid, position);
@@ -7709,7 +7853,7 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
7709
7853
 
7710
7854
  const renderHoverDom = {
7711
7855
  isEqual(oldState, newState) {
7712
- return oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.diagnostics === newState.diagnostics;
7856
+ return oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics;
7713
7857
  },
7714
7858
  apply(oldState, newState) {
7715
7859
  const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
@@ -7718,26 +7862,22 @@ const renderHoverDom = {
7718
7862
  };
7719
7863
  const renderBounds$4 = {
7720
7864
  isEqual(oldState, newState) {
7721
- return oldState.x === newState.x && oldState.y === newState.y && oldState.resizedWidth === newState.resizedWidth;
7865
+ return oldState.x === newState.x && oldState.y === newState.y;
7722
7866
  },
7723
7867
  apply(oldState, newState) {
7724
- // @ts-ignore
7725
7868
  const {
7726
7869
  x,
7727
7870
  y,
7728
- width,
7729
- height,
7730
- resizedWidth,
7731
- uid
7871
+ height
7732
7872
  } = newState;
7733
- console.log('apply');
7734
- return [SetBounds, x, y, resizedWidth, height];
7873
+ const renderWidth = 200;
7874
+ return [SetBounds, x, y, renderWidth, height];
7735
7875
  }
7736
7876
  };
7737
- const render$9 = [renderHoverDom, renderBounds$4];
7738
- const renderHover = async (oldState, newState) => {
7877
+ const render$a = [renderHoverDom, renderBounds$4];
7878
+ const renderHover = (oldState, newState) => {
7739
7879
  const commands = [];
7740
- for (const item of render$9) {
7880
+ for (const item of render$a) {
7741
7881
  if (!item.isEqual(oldState, newState)) {
7742
7882
  commands.push(item.apply(oldState, newState));
7743
7883
  }
@@ -8695,7 +8835,7 @@ const renderWidgets = {
8695
8835
  },
8696
8836
  multiple: true
8697
8837
  };
8698
- const render$8 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
8838
+ const render$9 = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
8699
8839
  const renderEditor = async id => {
8700
8840
  const instance = get$7(id);
8701
8841
  if (!instance) {
@@ -8707,7 +8847,7 @@ const renderEditor = async id => {
8707
8847
  } = instance;
8708
8848
  const commands = [];
8709
8849
  set$7(id, newState, newState);
8710
- for (const item of render$8) {
8850
+ for (const item of render$9) {
8711
8851
  if (!item.isEqual(oldState, newState)) {
8712
8852
  const result = await item.apply(oldState, newState);
8713
8853
  // @ts-ignore
@@ -8919,7 +9059,9 @@ const commandMap = {
8919
9059
  'Editor.setLanguageId': setLanguageId,
8920
9060
  'Editor.setSelections': setSelections,
8921
9061
  'Editor.showHover': showHover,
8922
- 'Editor.showSourceActions': showSourceActions,
9062
+ 'Editor.showHover2': showHover2,
9063
+ 'Editor.showSourceActions': showSourceActions$1,
9064
+ 'Editor.showSourceActions2': showSourceActions,
8923
9065
  'Editor.sortLinesAscending': sortLinesAscending,
8924
9066
  'Editor.tabCompletion': tabCompletion,
8925
9067
  'Editor.toggleBlockComment': toggleBlockComment,
@@ -8945,6 +9087,7 @@ const commandMap = {
8945
9087
  'EditorCompletion.selectIndex': selectIndex,
8946
9088
  'EditorCompletion.toggleDetails': toggleDetails,
8947
9089
  'FindWidget.close': close$1,
9090
+ 'FindWidget.focusCloseButton': focusCloseButton,
8948
9091
  'FindWidget.focusFind': focusFind,
8949
9092
  'FindWidget.focusFirst': focusFirst$1,
8950
9093
  'FindWidget.focusIndex': focusIndex$1,
@@ -8966,7 +9109,6 @@ const commandMap = {
8966
9109
  'FindWidget.handleToggleReplaceFocus': handleToggleReplaceFocus,
8967
9110
  'FindWidget.loadContent': loadContent$1,
8968
9111
  'FindWidget.toggleReplace': toggleReplace,
8969
- 'FindWidget.focusCloseButton': focusCloseButton,
8970
9112
  'Font.ensure': ensure,
8971
9113
  'Hover.getHoverInfo': getEditorHoverInfo,
8972
9114
  'Hover.handleSashPointerDown': handleSashPointerDown,
@@ -9226,10 +9368,10 @@ const renderScrollBar = {
9226
9368
  return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
9227
9369
  }
9228
9370
  };
9229
- const render$7 = [renderItems, renderBounds$3, renderHeight, renderNegativeMargin, renderScrollBar];
9371
+ const render$8 = [renderItems, renderBounds$3, renderHeight, renderNegativeMargin, renderScrollBar];
9230
9372
  const renderCompletion = (oldState, newState) => {
9231
9373
  const commands = [];
9232
- for (const item of render$7) {
9374
+ for (const item of render$8) {
9233
9375
  if (!item.isEqual(oldState, newState)) {
9234
9376
  commands.push(item.apply(oldState, newState));
9235
9377
  }
@@ -9242,7 +9384,7 @@ const removeWidget = widget => {
9242
9384
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
9243
9385
  };
9244
9386
 
9245
- const render$6 = widget => {
9387
+ const render$7 = widget => {
9246
9388
  const commands = renderCompletion(widget.oldState, widget.newState);
9247
9389
  const wrappedCommands = [];
9248
9390
  const uid = widget.newState.uid;
@@ -9251,8 +9393,8 @@ const render$6 = widget => {
9251
9393
  }
9252
9394
  return wrappedCommands;
9253
9395
  };
9254
- const add$3 = widget => {
9255
- const commands = render$6(widget);
9396
+ const add$4 = widget => {
9397
+ const commands = render$7(widget);
9256
9398
  const id = 'EditorCompletion';
9257
9399
  // TODO how to generate a unique integer id
9258
9400
  // that doesn't collide with ids created in renderer worker?
@@ -9262,7 +9404,7 @@ const add$3 = widget => {
9262
9404
  allCommands.push(...commands);
9263
9405
  return allCommands;
9264
9406
  };
9265
- const remove$3 = removeWidget;
9407
+ const remove$4 = removeWidget;
9266
9408
  const handleEditorType = (editor, state) => {
9267
9409
  const {
9268
9410
  unfilteredItems,
@@ -9327,11 +9469,11 @@ const handleEditorDeleteLeft = (editor, state) => {
9327
9469
 
9328
9470
  const EditorCompletionWidget = {
9329
9471
  __proto__: null,
9330
- add: add$3,
9472
+ add: add$4,
9331
9473
  handleEditorDeleteLeft,
9332
9474
  handleEditorType,
9333
- remove: remove$3,
9334
- render: render$6
9475
+ remove: remove$4,
9476
+ render: render$7
9335
9477
  };
9336
9478
 
9337
9479
  const MessagePort$1 = 1;
@@ -9882,10 +10024,10 @@ const renderBounds$2 = {
9882
10024
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
9883
10025
  }
9884
10026
  };
9885
- const render$5 = [renderContent$1, renderBounds$2, renderColor, renderOffsetX];
10027
+ const render$6 = [renderContent$1, renderBounds$2, renderColor, renderOffsetX];
9886
10028
  const renderFull$1 = (oldState, newState) => {
9887
10029
  const commands = [];
9888
- for (const item of render$5) {
10030
+ for (const item of render$6) {
9889
10031
  if (!item.isEqual(oldState, newState)) {
9890
10032
  commands.push(item.apply(oldState, newState));
9891
10033
  }
@@ -9893,7 +10035,7 @@ const renderFull$1 = (oldState, newState) => {
9893
10035
  return commands;
9894
10036
  };
9895
10037
 
9896
- const render$4 = widget => {
10038
+ const render$5 = widget => {
9897
10039
  const commands = renderFull$1(widget.oldState, widget.newState);
9898
10040
  const wrappedCommands = [];
9899
10041
  const uid = widget.newState.uid;
@@ -9906,10 +10048,10 @@ const render$4 = widget => {
9906
10048
  }
9907
10049
  return wrappedCommands;
9908
10050
  };
9909
- const add$2 = widget => {
9910
- return addWidget(widget, 'ColorPicker', render$4);
10051
+ const add$3 = widget => {
10052
+ return addWidget(widget, 'ColorPicker', render$5);
9911
10053
  };
9912
- const remove$2 = removeWidget;
10054
+ const remove$3 = removeWidget;
9913
10055
  const Commands$1 = {
9914
10056
  'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
9915
10057
  'ColorPicker.handleSliderPointerMove': handleSliderPointerMove
@@ -9918,9 +10060,9 @@ const Commands$1 = {
9918
10060
  const EditorColorPickerWidget = {
9919
10061
  __proto__: null,
9920
10062
  Commands: Commands$1,
9921
- add: add$2,
9922
- remove: remove$2,
9923
- render: render$4
10063
+ add: add$3,
10064
+ remove: remove$3,
10065
+ render: render$5
9924
10066
  };
9925
10067
 
9926
10068
  const getCompletionDetailVirtualDom = content => {
@@ -9968,12 +10110,12 @@ const renderBounds$1 = {
9968
10110
  return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
9969
10111
  }
9970
10112
  };
9971
- const render$3 = [renderContent, renderBounds$1];
10113
+ const render$4 = [renderContent, renderBounds$1];
9972
10114
  const renderFull = (oldState, newState) => {
9973
- return renderParts(render$3, oldState, newState);
10115
+ return renderParts(render$4, oldState, newState);
9974
10116
  };
9975
10117
 
9976
- const render$2 = widget => {
10118
+ const render$3 = widget => {
9977
10119
  const commands = renderFull(widget.oldState, widget.newState);
9978
10120
  const wrappedCommands = [];
9979
10121
  const uid = widget.newState.uid;
@@ -9986,16 +10128,16 @@ const render$2 = widget => {
9986
10128
  }
9987
10129
  return wrappedCommands;
9988
10130
  };
9989
- const add$1 = widget => {
9990
- return addWidget(widget, 'EditorCompletionDetails', render$2);
10131
+ const add$2 = widget => {
10132
+ return addWidget(widget, 'EditorCompletionDetails', render$3);
9991
10133
  };
9992
- const remove$1 = removeWidget;
10134
+ const remove$2 = removeWidget;
9993
10135
 
9994
10136
  const EditorCompletionDetailWidget = {
9995
10137
  __proto__: null,
9996
- add: add$1,
9997
- remove: remove$1,
9998
- render: render$2
10138
+ add: add$2,
10139
+ remove: remove$2,
10140
+ render: render$3
9999
10141
  };
10000
10142
 
10001
10143
  /**
@@ -10341,16 +10483,16 @@ const renderFocus = {
10341
10483
  // },
10342
10484
  // }
10343
10485
 
10344
- const render$1 = [renderDetails, renderBounds, renderValue, renderFocus];
10486
+ const render$2 = [renderDetails, renderBounds, renderValue, renderFocus];
10345
10487
  const apply = (oldState, newState) => {
10346
10488
  // TODO avoid side effect
10347
10489
  if (oldState.focus !== newState.focus) {
10348
10490
  setFocus(newState.focus);
10349
10491
  }
10350
- return renderParts(render$1, oldState, newState);
10492
+ return renderParts(render$2, oldState, newState);
10351
10493
  };
10352
10494
 
10353
- const render = widget => {
10495
+ const render$1 = widget => {
10354
10496
  const commands = apply(widget.oldState, widget.newState);
10355
10497
  const wrappedCommands = [];
10356
10498
  const uid = widget.newState.uid;
@@ -10363,10 +10505,10 @@ const render = widget => {
10363
10505
  }
10364
10506
  return wrappedCommands;
10365
10507
  };
10366
- const add = widget => {
10367
- return addWidget(widget, 'FindWidget', render);
10508
+ const add$1 = widget => {
10509
+ return addWidget(widget, 'FindWidget', render$1);
10368
10510
  };
10369
- const remove = removeWidget;
10511
+ const remove$1 = removeWidget;
10370
10512
  const Commands = {
10371
10513
  'FindWidget.close': close$1,
10372
10514
  'FindWidget.focusNext': focusNext$1,
@@ -10381,6 +10523,35 @@ const Commands = {
10381
10523
  const EditorFindWidget = {
10382
10524
  __proto__: null,
10383
10525
  Commands,
10526
+ add: add$1,
10527
+ remove: remove$1,
10528
+ render: render$1
10529
+ };
10530
+
10531
+ const SourceActionWidget = {
10532
+ __proto__: null
10533
+ };
10534
+
10535
+ const render = widget => {
10536
+ const commands = renderHover(widget.oldState, widget.newState);
10537
+ const wrappedCommands = [];
10538
+ const uid = widget.newState.uid;
10539
+ for (const command of commands) {
10540
+ if (command[0] === 'Viewlet.setDom2') {
10541
+ wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10542
+ } else {
10543
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
10544
+ }
10545
+ }
10546
+ return wrappedCommands;
10547
+ };
10548
+ const add = widget => {
10549
+ return addWidget(widget, 'EditorHover', render);
10550
+ };
10551
+ const remove = removeWidget;
10552
+
10553
+ const EditorHoverWidget = {
10554
+ __proto__: null,
10384
10555
  add,
10385
10556
  remove,
10386
10557
  render
@@ -10391,6 +10562,8 @@ const registerWidgets = () => {
10391
10562
  set(Completion, EditorCompletionWidget);
10392
10563
  set(CompletionDetail$1, EditorCompletionDetailWidget);
10393
10564
  set(Find, EditorFindWidget);
10565
+ set(Hover, EditorHoverWidget);
10566
+ set(SourceAction, SourceActionWidget);
10394
10567
  };
10395
10568
 
10396
10569
  const main = async () => {