@lvce-editor/editor-worker 19.34.0 → 19.36.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.
@@ -2797,7 +2797,7 @@ const applyEdits = (textDocument, changes) => {
2797
2797
  }
2798
2798
  return newLines;
2799
2799
  };
2800
- const getLine = (textDocument, index) => {
2800
+ const getLine$1 = (textDocument, index) => {
2801
2801
  return textDocument.lines[index];
2802
2802
  };
2803
2803
  const getText$1 = state => {
@@ -2875,7 +2875,7 @@ const positionAt = (textDocument, offset) => {
2875
2875
  };
2876
2876
  };
2877
2877
 
2878
- const maxTokenizerLoadPasses = 10;
2878
+ const maxTokenizerLoadPasses$1 = 10;
2879
2879
 
2880
2880
  // const getTokensIncremental = (editor, min, max) => {
2881
2881
  // const currentLength = editor.lineStateCache.length
@@ -3226,7 +3226,7 @@ const getVisible$1 = async (editor, syncIncremental) => {
3226
3226
  tokenizersToLoad,
3227
3227
  tokens
3228
3228
  } = await getTokensViewport2(editor, minLineY, maxLineY, syncIncremental);
3229
- for (let i = 0; tokenizersToLoad.length > 0 && i < maxTokenizerLoadPasses; i++) {
3229
+ for (let i = 0; tokenizersToLoad.length > 0 && i < maxTokenizerLoadPasses$1; i++) {
3230
3230
  await loadTokenizers(tokenizersToLoad);
3231
3231
  // @ts-ignore
3232
3232
  const refreshed = await getTokensViewport2(editor, minLineY, maxLineY, syncIncremental);
@@ -3557,10 +3557,16 @@ const notifyListeners = async (listenerType, method, ...params) => {
3557
3557
  await Promise.all(notifications);
3558
3558
  };
3559
3559
 
3560
+ const width = 120;
3561
+ const characterWidth = 0.75;
3562
+ const lineHeight = 2;
3563
+ const minimumViewportHeight = 20;
3564
+
3560
3565
  const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3561
3566
  const x = dimensions.x ?? state.x;
3562
3567
  const y = dimensions.y ?? state.y;
3563
- const width = dimensions.width ?? state.width;
3568
+ const outerWidth = dimensions.width ?? state.outerWidth ?? state.width;
3569
+ const width$1 = Math.max(outerWidth - (state.minimapEnabled ? width : 0), 0);
3564
3570
  const height = dimensions.height ?? state.height;
3565
3571
  const numberOfVisibleLines = Math.floor(height / state.itemHeight);
3566
3572
  if (!('foldingRanges' in state)) {
@@ -3582,8 +3588,11 @@ const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3582
3588
  maxLineY,
3583
3589
  minLineY,
3584
3590
  numberOfVisibleLines,
3591
+ ...('outerWidth' in state && {
3592
+ outerWidth
3593
+ }),
3585
3594
  scrollBarHeight,
3586
- width,
3595
+ width: width$1,
3587
3596
  x,
3588
3597
  y
3589
3598
  };
@@ -3593,7 +3602,10 @@ const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3593
3602
  columnWidth,
3594
3603
  height,
3595
3604
  numberOfVisibleLines,
3596
- width,
3605
+ ...('outerWidth' in state && {
3606
+ outerWidth
3607
+ }),
3608
+ width: width$1,
3597
3609
  x,
3598
3610
  y
3599
3611
  };
@@ -4340,6 +4352,37 @@ const updateColorPickerValue$1 = async (editor, value) => {
4340
4352
  };
4341
4353
  };
4342
4354
 
4355
+ const maxTokenizerLoadPasses = 10;
4356
+ const getLine = (lineState, embeddedResults, tokenMap, lineLength) => {
4357
+ const embeddedResult = embeddedResults[lineState?.embeddedResultIndex];
4358
+ const useEmbeddedResult = Boolean(embeddedResult?.isFull);
4359
+ const tokens = (useEmbeddedResult ? embeddedResult.result.tokens : lineState?.tokens) || [0, lineLength];
4360
+ const lineTokenMap = useEmbeddedResult ? embeddedResult.TokenMap : tokenMap;
4361
+ const line = [];
4362
+ for (let i = 0; i < tokens.length; i += 2) {
4363
+ const tokenType = tokens[i];
4364
+ const tokenLength = tokens[i + 1];
4365
+ line.push(tokenLength, `Token ${lineTokenMap[tokenType] || 'Unknown'}`);
4366
+ }
4367
+ return line;
4368
+ };
4369
+ const getMinimapLines = async (editor, syncIncremental) => {
4370
+ const {
4371
+ lines
4372
+ } = editor;
4373
+ if (lines.length === 0) {
4374
+ return [];
4375
+ }
4376
+ let result = await getTokensViewport2(editor, 0, lines.length, syncIncremental);
4377
+ for (let i = 0; result.tokenizersToLoad.length > 0 && i < maxTokenizerLoadPasses; i++) {
4378
+ await loadTokenizers(result.tokenizersToLoad);
4379
+ result = await getTokensViewport2(editor, 0, lines.length, syncIncremental);
4380
+ }
4381
+ const tokenizer = get$4(editor.tokenizerId);
4382
+ const tokenMap = tokenizer.TokenMap || {};
4383
+ return result.tokens.map((lineState, index) => getLine(lineState, result.embeddedResults, tokenMap, lines[index].length));
4384
+ };
4385
+
4343
4386
  const getDiagnosticType = diagnostic => {
4344
4387
  return diagnostic.type;
4345
4388
  };
@@ -4398,6 +4441,9 @@ const shouldUpdateVisibleTextData = (oldState, newState) => {
4398
4441
  }
4399
4442
  return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
4400
4443
  };
4444
+ const shouldUpdateMinimapData = (oldState, newState) => {
4445
+ return newState.minimapEnabled && (!oldState.minimapEnabled || oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId);
4446
+ };
4401
4447
  const updateDerivedState = async (oldState, newState) => {
4402
4448
  const nextState = oldState.lines !== newState.lines && 'foldingRanges' in newState ? updateLayout(newState, []) : newState;
4403
4449
  let finalState = nextState;
@@ -4413,6 +4459,21 @@ const updateDerivedState = async (oldState, newState) => {
4413
4459
  textInfos
4414
4460
  };
4415
4461
  }
4462
+ if (!nextState.minimapEnabled && oldState.minimapEnabled) {
4463
+ finalState = {
4464
+ ...finalState,
4465
+ minimapLines: [],
4466
+ minimapRevision: finalState.minimapRevision + 1
4467
+ };
4468
+ } else if (shouldUpdateMinimapData(oldState, nextState)) {
4469
+ const syncIncremental = getEnabled();
4470
+ const minimapLines = await getMinimapLines(finalState, syncIncremental);
4471
+ finalState = {
4472
+ ...finalState,
4473
+ minimapLines,
4474
+ minimapRevision: finalState.minimapRevision + 1
4475
+ };
4476
+ }
4416
4477
  if (shouldUpdateDiagnosticData(oldState, nextState)) {
4417
4478
  const visualDecorations = await getVisibleDiagnostics(finalState, finalState.diagnostics ?? []);
4418
4479
  finalState = {
@@ -4545,6 +4606,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4545
4606
  diagnosticsEnabled: false,
4546
4607
  differences: [],
4547
4608
  embeds: [],
4609
+ endOfLineDecorations: [],
4548
4610
  finalDeltaY: 0,
4549
4611
  finalY: 0,
4550
4612
  focus: 0,
@@ -4578,11 +4640,15 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4578
4640
  lines: [],
4579
4641
  longestLineWidth: 0,
4580
4642
  maxLineY: 0,
4643
+ minimapEnabled: false,
4644
+ minimapLines: [],
4645
+ minimapRevision: 0,
4581
4646
  minimumSliderSize: 20,
4582
4647
  minLineY: 0,
4583
4648
  modified: false,
4584
4649
  numberOfLines: 0,
4585
4650
  numberOfVisibleLines: 0,
4651
+ outerWidth: width,
4586
4652
  platform,
4587
4653
  primarySelectionIndex: 0,
4588
4654
  redoStack: [],
@@ -4628,6 +4694,7 @@ const emptyEditor = {
4628
4694
  diagnostics: [],
4629
4695
  differences: [],
4630
4696
  embeds: [],
4697
+ endOfLineDecorations: [],
4631
4698
  focused: false,
4632
4699
  foldingRanges: [],
4633
4700
  hasListener: false,
@@ -4641,7 +4708,11 @@ const emptyEditor = {
4641
4708
  lines: [],
4642
4709
  longestLineWidth: 0,
4643
4710
  maxLineY: 0,
4711
+ minimapEnabled: false,
4712
+ minimapLines: [],
4713
+ minimapRevision: 0,
4644
4714
  minLineY: 0,
4715
+ outerWidth: 0,
4645
4716
  redoStack: [],
4646
4717
  scrollBarHeight: 0,
4647
4718
  selectionAnchorPosition: {
@@ -4792,6 +4863,7 @@ const createEditor = async ({
4792
4863
  diagnostics: [],
4793
4864
  diagnosticsEnabled,
4794
4865
  differences: [],
4866
+ endOfLineDecorations: [],
4795
4867
  finalDeltaY: 0,
4796
4868
  finalY: 0,
4797
4869
  focused: false,
@@ -4968,15 +5040,15 @@ const createStandaloneEditor = async ({
4968
5040
  set$8(id, createdEditor, finalEditor);
4969
5041
  };
4970
5042
 
4971
- const isEqual$4 = (oldState, newState) => {
5043
+ const isEqual$5 = (oldState, newState) => {
4972
5044
  return oldState.additionalFocus === newState.additionalFocus;
4973
5045
  };
4974
5046
 
4975
- const isEqual$3 = (oldState, newState) => {
5047
+ const isEqual$4 = (oldState, newState) => {
4976
5048
  return oldState.rowHeight === newState.rowHeight && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.deltaX === newState.deltaX && oldState.longestLineWidth === newState.longestLineWidth && oldState.minimumSliderSize === newState.minimumSliderSize && oldState.width === newState.width && oldState.scrollBarHeight === newState.scrollBarHeight;
4977
5049
  };
4978
5050
 
4979
- const isEqual$2 = (oldState, newState) => {
5051
+ const isEqual$3 = (oldState, newState) => {
4980
5052
  if (oldState.focus !== newState.focus) {
4981
5053
  return false;
4982
5054
  }
@@ -4989,23 +5061,31 @@ const isEqual$2 = (oldState, newState) => {
4989
5061
  return oldState.focused === newState.focused;
4990
5062
  };
4991
5063
 
4992
- const isEqual$1 = (oldState, newState) => {
5064
+ const isEqual$2 = (oldState, newState) => {
4993
5065
  return oldState.breakPoints === newState.breakPoints && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos;
4994
5066
  };
4995
5067
 
5068
+ const isEqual$1 = (oldState, newState) => {
5069
+ if (!oldState.minimapEnabled && !newState.minimapEnabled) {
5070
+ return true;
5071
+ }
5072
+ return oldState.minimapEnabled === newState.minimapEnabled && oldState.minimapLines === newState.minimapLines && oldState.minimapRevision === newState.minimapRevision && oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.numberOfVisibleLines === newState.numberOfVisibleLines;
5073
+ };
5074
+
4996
5075
  const RenderFocus = 6;
4997
5076
  const RenderFocusContext = 7;
4998
5077
  const RenderCss = 11;
4999
5078
  const RenderIncremental = 12;
5000
5079
  const RenderWidgets = 13;
5001
5080
  const RenderAdditionalFocusContext = 14;
5081
+ const RenderMinimap = 15;
5002
5082
 
5003
5083
  const isEqual = (oldState, newState) => {
5004
5084
  return oldState.widgets === newState.widgets && oldState.widgetRevision === newState.widgetRevision;
5005
5085
  };
5006
5086
 
5007
- const modules = [isEqual$1, isEqual$2, isEqual$2, isEqual$4, isEqual$3, isEqual];
5008
- const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderAdditionalFocusContext, RenderCss, RenderWidgets];
5087
+ const modules = [isEqual$2, isEqual$1, isEqual$3, isEqual$3, isEqual$5, isEqual$4, isEqual];
5088
+ const numbers = [RenderIncremental, RenderMinimap, RenderFocus, RenderFocusContext, RenderAdditionalFocusContext, RenderCss, RenderWidgets];
5009
5089
 
5010
5090
  const diff = (oldState, newState) => {
5011
5091
  const diffResult = [];
@@ -6616,7 +6696,7 @@ const copyLineDown = editor => {
6616
6696
  return {
6617
6697
  deleted: [''],
6618
6698
  end: position,
6619
- inserted: [getLine(editor, rowIndex), ''],
6699
+ inserted: [getLine$1(editor, rowIndex), ''],
6620
6700
  start: position
6621
6701
  };
6622
6702
  });
@@ -6643,7 +6723,7 @@ const copyLineUp = editor => {
6643
6723
  const changes = [{
6644
6724
  deleted: [''],
6645
6725
  end: position,
6646
- inserted: [getLine(editor, rowIndex), ''],
6726
+ inserted: [getLine$1(editor, rowIndex), ''],
6647
6727
  start: position
6648
6728
  }];
6649
6729
  return scheduleDocumentAndCursorsSelections(editor, changes);
@@ -6766,7 +6846,7 @@ const characterRight = (line, columnIndex) => {
6766
6846
  // @ts-ignore
6767
6847
  return next.segment.length;
6768
6848
  };
6769
- const isWhitespace = char => {
6849
+ const isWhitespace$1 = char => {
6770
6850
  return char === Space || char === Tab;
6771
6851
  };
6772
6852
  const lineCharacterStart = (line, columnIndex) => {
@@ -6774,7 +6854,7 @@ const lineCharacterStart = (line, columnIndex) => {
6774
6854
  return 0;
6775
6855
  }
6776
6856
  for (let i = 0; i < columnIndex; i++) {
6777
- if (!isWhitespace(line[i])) {
6857
+ if (!isWhitespace$1(line[i])) {
6778
6858
  return columnIndex - i;
6779
6859
  }
6780
6860
  }
@@ -7890,6 +7970,43 @@ const getClickHandler = modifier => {
7890
7970
  }
7891
7971
  };
7892
7972
 
7973
+ const isProviderDecoration = value => {
7974
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
7975
+ };
7976
+ const getProviderDecorations = (results, rowIndex) => {
7977
+ if (!Array.isArray(results)) {
7978
+ return [];
7979
+ }
7980
+ const decorations = [];
7981
+ for (const result of results) {
7982
+ if (!Array.isArray(result)) {
7983
+ continue;
7984
+ }
7985
+ for (const decoration of result) {
7986
+ if (isProviderDecoration(decoration) && typeof decoration.text === 'string') {
7987
+ decorations.push({
7988
+ rowIndex,
7989
+ text: decoration.text
7990
+ });
7991
+ }
7992
+ }
7993
+ }
7994
+ return decorations;
7995
+ };
7996
+ const getEditorLineDecorations = async (editor, rowIndex) => {
7997
+ const textDocument = {
7998
+ languageId: editor.languageId,
7999
+ text: getText$1(editor),
8000
+ uri: editor.uri
8001
+ };
8002
+ try {
8003
+ const results = await invoke$d('Extensions.executeProvidersByEvent', 'onEditorLineDecoration', 'ExtensionApi.executeEditorLineDecorationProvider', textDocument, rowIndex);
8004
+ return getProviderDecorations(results, rowIndex);
8005
+ } catch {
8006
+ return [];
8007
+ }
8008
+ };
8009
+
7893
8010
  const handleClickAtPosition = async (editor, modifier, rowIndex, columnIndex) => {
7894
8011
  object(editor);
7895
8012
  number(modifier);
@@ -7900,7 +8017,11 @@ const handleClickAtPosition = async (editor, modifier, rowIndex, columnIndex) =>
7900
8017
  columnIndex,
7901
8018
  rowIndex
7902
8019
  });
7903
- return newEditor;
8020
+ const endOfLineDecorations = await getEditorLineDecorations(newEditor, rowIndex);
8021
+ return {
8022
+ ...newEditor,
8023
+ endOfLineDecorations
8024
+ };
7904
8025
  };
7905
8026
 
7906
8027
  const Editor = 3;
@@ -7937,7 +8058,7 @@ const getNewSelections$7 = (line, rowIndex, columnIndex) => {
7937
8058
 
7938
8059
  // @ts-ignore
7939
8060
  const selectWord = (editor, rowIndex, columnIndex) => {
7940
- const line = getLine(editor, rowIndex);
8061
+ const line = getLine$1(editor, rowIndex);
7941
8062
  const newSelections = getNewSelections$7(line, rowIndex, columnIndex);
7942
8063
  return scheduleSelections(editor, newSelections);
7943
8064
  };
@@ -8048,7 +8169,7 @@ const selectLine = editor => {
8048
8169
  selections
8049
8170
  } = editor;
8050
8171
  const rowIndex = selections[editor.primarySelectionIndex];
8051
- const line = getLine(editor, rowIndex);
8172
+ const line = getLine$1(editor, rowIndex);
8052
8173
  const newSelections = getNewSelections$6(line, rowIndex);
8053
8174
  return scheduleSelections(editor, newSelections);
8054
8175
  };
@@ -10779,7 +10900,7 @@ const getSnippetChanges = (lines, selections, snippet) => {
10779
10900
  for (let i = 0; i < selections.length; i += 4) {
10780
10901
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
10781
10902
  if (insertedLines.length > 1) {
10782
- const line = getLine({
10903
+ const line = getLine$1({
10783
10904
  lines
10784
10905
  }, selectionStartRow);
10785
10906
  const indent = getIndent(line);
@@ -10937,14 +11058,14 @@ const getBlockCommentEdits = (editor, blockComment) => {
10937
11058
  selections
10938
11059
  } = editor;
10939
11060
  const [rowIndex] = selections;
10940
- const line = getLine(editor, rowIndex);
11061
+ const line = getLine$1(editor, rowIndex);
10941
11062
  const numberOfLines = editor.lines.length;
10942
11063
  let endRowIndex = rowIndex;
10943
11064
  let endColumnIndex = -1;
10944
11065
  const blockCommentStart = blockComment[0];
10945
11066
  const blockCommentEnd = blockComment[1];
10946
11067
  while (endRowIndex < numberOfLines) {
10947
- const line = getLine(editor, endRowIndex);
11068
+ const line = getLine$1(editor, endRowIndex);
10948
11069
  endColumnIndex = line.indexOf(blockCommentEnd);
10949
11070
  if (endColumnIndex !== -1) {
10950
11071
  break;
@@ -10954,7 +11075,7 @@ const getBlockCommentEdits = (editor, blockComment) => {
10954
11075
  let startColumnIndex = -1;
10955
11076
  let startRowIndex = rowIndex;
10956
11077
  while (startRowIndex >= 0) {
10957
- const line = getLine(editor, startRowIndex);
11078
+ const line = getLine$1(editor, startRowIndex);
10958
11079
  startColumnIndex = line.indexOf(blockCommentStart);
10959
11080
  if (startColumnIndex !== -1) {
10960
11081
  break;
@@ -11144,7 +11265,7 @@ const editorToggleLineComment = async editor => {
11144
11265
  }
11145
11266
  const textDocument = editor;
11146
11267
  const cursorRowIndex = editor.selections[0];
11147
- const line = getLine(textDocument, cursorRowIndex);
11268
+ const line = getLine$1(textDocument, cursorRowIndex);
11148
11269
  const documentEdits = [getLineCommentEdit(cursorRowIndex, line, lineComment)];
11149
11270
  return scheduleDocumentAndCursorsSelections(editor, documentEdits);
11150
11271
  };
@@ -11617,6 +11738,7 @@ const CompletionDetailContent = 'CompletionDetailContent';
11617
11738
  const Diagnostic = 'Diagnostic';
11618
11739
  const EditorCursor = 'EditorCursor';
11619
11740
  const EditorHoverDiagnosticOnly = 'EditorHoverDiagnosticOnly';
11741
+ const EditorLineDecoration = 'EditorLineDecoration';
11620
11742
  const EditorRow = 'EditorRow';
11621
11743
  const EditorRowHighlighted = 'EditorRowHighlighted';
11622
11744
  const EditorSelection = 'EditorSelection';
@@ -12741,6 +12863,7 @@ const kAutoClosingQuotes = 'editor.autoClosingQuotes';
12741
12863
  const kAutoClosingBrackets = 'editor.autoclosingBrackets';
12742
12864
  const kFontWeight = 'editor.fontWeight';
12743
12865
  const kHover = 'editor.hover';
12866
+ const kMinimapEnabled = 'editor.minimap.enabled';
12744
12867
  const isAutoClosingBracketsEnabled = async () => {
12745
12868
  return Boolean(await get$3(kAutoClosingBrackets));
12746
12869
  };
@@ -12786,9 +12909,12 @@ const diagnosticsEnabled = async () => {
12786
12909
  const getFontWeight = async () => {
12787
12910
  return (await get$3(kFontWeight)) ?? 400;
12788
12911
  };
12912
+ const getMinimapEnabled = async () => {
12913
+ return (await get$3(kMinimapEnabled)) ?? false;
12914
+ };
12789
12915
 
12790
12916
  const getEditorPreferences = async () => {
12791
- const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters()]);
12917
+ const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled()]);
12792
12918
  return {
12793
12919
  completionTriggerCharacters,
12794
12920
  diagnosticsEnabled: diagnosticsEnabled$1,
@@ -12802,6 +12928,7 @@ const getEditorPreferences = async () => {
12802
12928
  isQuickSuggestionsEnabled: isQuickSuggestionsEnabled$1,
12803
12929
  letterSpacing,
12804
12930
  lineNumbers,
12931
+ minimapEnabled,
12805
12932
  rowHeight,
12806
12933
  tabSize
12807
12934
  };
@@ -12815,6 +12942,7 @@ const handleSettingsChanged = async state => {
12815
12942
  fontSize,
12816
12943
  fontWeight,
12817
12944
  letterSpacing,
12945
+ minimapEnabled,
12818
12946
  rowHeight
12819
12947
  } = editorPreferences;
12820
12948
  const [charWidth, completionsOnTypeRaw] = await Promise.all([measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing), get$3('editor.completionsOnType')]);
@@ -12827,6 +12955,7 @@ const handleSettingsChanged = async state => {
12827
12955
  diagnostics: diagnosticsEnabled ? state.diagnostics : [],
12828
12956
  isMonospaceFont,
12829
12957
  itemHeight: rowHeight,
12958
+ minimapRevision: (state.minimapRevision || 0) + (minimapEnabled ? 1 : 0),
12830
12959
  visualDecorations: diagnosticsEnabled ? state.visualDecorations : []
12831
12960
  };
12832
12961
  return resize(editorWithUpdatedSettings, {}, charWidth);
@@ -13106,6 +13235,7 @@ const loadContent = async (state, savedState) => {
13106
13235
  isQuickSuggestionsEnabled,
13107
13236
  letterSpacing,
13108
13237
  lineNumbers,
13238
+ minimapEnabled,
13109
13239
  rowHeight,
13110
13240
  tabSize
13111
13241
  } = await getEditorPreferences();
@@ -13136,6 +13266,7 @@ const loadContent = async (state, savedState) => {
13136
13266
  letterSpacing,
13137
13267
  lineNumbers,
13138
13268
  loadError: '',
13269
+ minimapEnabled,
13139
13270
  rowHeight,
13140
13271
  tabSize,
13141
13272
  tokenizerId: newTokenizerId
@@ -13305,6 +13436,12 @@ ${editorSelector} .EditorRow {
13305
13436
  height: var(--EditorRowHeight);
13306
13437
  line-height: var(--EditorRowHeight);
13307
13438
  }
13439
+ ${editorSelector} .EditorLineDecoration {
13440
+ color: var(--EditorInlineBlameForeground, rgba(255, 255, 255, 0.5));
13441
+ font-style: italic;
13442
+ margin-left: 2em;
13443
+ user-select: none;
13444
+ }
13308
13445
  ${editorSelector} .R{background-color:#add6ff40}
13309
13446
  ${editorSelector} .ScrollBarThumbVertical {
13310
13447
  height: var(--ScrollBarHeight);
@@ -13618,12 +13755,12 @@ const diffTree = (oldNodes, newNodes) => {
13618
13755
  return removeTrailingNavigationPatches(patches);
13619
13756
  };
13620
13757
 
13758
+ const True = 'true';
13759
+
13621
13760
  const Button = 'button';
13622
13761
  const Code = 'code';
13623
13762
  const TextBox = 'textbox';
13624
13763
 
13625
- const True = 'true';
13626
-
13627
13764
  const editorInputNode = {
13628
13765
  childCount: 1,
13629
13766
  className: 'EditorInput',
@@ -13723,17 +13860,24 @@ const getEditorDiagnosticsVirtualDom = diagnostics => {
13723
13860
  }, ...diagnosticsDom];
13724
13861
  };
13725
13862
 
13726
- const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
13863
+ const editorLineDecorationNode = {
13864
+ childCount: 1,
13865
+ className: EditorLineDecoration,
13866
+ type: Span
13867
+ };
13868
+ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = []) => {
13727
13869
  const dom = [];
13728
13870
  for (let i = 0; i < textInfos.length; i++) {
13729
13871
  const textInfo = textInfos[i];
13730
13872
  const difference = differences[i];
13873
+ const rowIndex = visibleLineIndices[i] ?? i;
13874
+ const rowDecorations = endOfLineDecorations.filter(decoration => decoration.rowIndex === rowIndex);
13731
13875
  let className = EditorRow;
13732
13876
  if (i === highlightedLine) {
13733
13877
  className = mergeClassNames(className, EditorRowHighlighted);
13734
13878
  }
13735
13879
  dom.push({
13736
- childCount: textInfo.length / 2,
13880
+ childCount: textInfo.length / 2 + rowDecorations.length,
13737
13881
  className,
13738
13882
  translate: px(difference),
13739
13883
  type: Div
@@ -13747,12 +13891,15 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
13747
13891
  type: Span
13748
13892
  }, text(tokenText));
13749
13893
  }
13894
+ for (const decoration of rowDecorations) {
13895
+ dom.push(editorLineDecorationNode, text(decoration.text));
13896
+ }
13750
13897
  }
13751
13898
  return dom;
13752
13899
  };
13753
13900
 
13754
- const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
13755
- const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine);
13901
+ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = []) => {
13902
+ const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations);
13756
13903
  return [{
13757
13904
  childCount: textInfos.length,
13758
13905
  className: 'EditorRows',
@@ -13910,6 +14057,19 @@ const textEditorErrorMessageNode = {
13910
14057
  className: 'TextEditorErrorMessage',
13911
14058
  type: Div
13912
14059
  };
14060
+ const getMinimapVirtualDom = (minimapEnabled, minimapLines, minLineY) => {
14061
+ if (!minimapEnabled) {
14062
+ return [];
14063
+ }
14064
+ return [{
14065
+ ariaHidden: True,
14066
+ childCount: 0,
14067
+ className: 'EditorMinimap',
14068
+ 'data-line-count': minimapLines.length,
14069
+ 'data-visible-start': minLineY,
14070
+ type: Div
14071
+ }];
14072
+ };
13913
14073
  const getEditorVirtualDom = ({
13914
14074
  breakPoints = [],
13915
14075
  cursorInfos = [],
@@ -13920,6 +14080,8 @@ const getEditorVirtualDom = ({
13920
14080
  lineNumbers = true,
13921
14081
  loadError = '',
13922
14082
  maxLineY = 0,
14083
+ minimapEnabled = false,
14084
+ minimapLines = [],
13923
14085
  minLineY = 0,
13924
14086
  scrollBarDiagnostics = [],
13925
14087
  selectionInfos = [],
@@ -13939,8 +14101,9 @@ const getEditorVirtualDom = ({
13939
14101
  const visibleGutterInfos = breakPoints.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices) : gutterInfos;
13940
14102
  const showGutter = lineNumbers || breakPoints.length > 0;
13941
14103
  const gutterDom = showGutter ? getEditorGutterVirtualDom(visibleGutterInfos) : [];
14104
+ const minimapDom = getMinimapVirtualDom(minimapEnabled, minimapLines, minLineY);
13942
14105
  return [{
13943
- childCount: showGutter ? 2 : 1,
14106
+ childCount: (showGutter ? 2 : 1) + (minimapEnabled ? 1 : 0),
13944
14107
  className: mergeClassNames('Viewlet', 'Editor'),
13945
14108
  'data-uid': uid,
13946
14109
  onContextMenu: HandleContextMenu,
@@ -13955,7 +14118,7 @@ const getEditorVirtualDom = ({
13955
14118
  scrollBarDiagnostics,
13956
14119
  selectionInfos,
13957
14120
  textInfos
13958
- })];
14121
+ }), ...minimapDom];
13959
14122
  };
13960
14123
 
13961
14124
  const renderedDoms = new Map();
@@ -13991,6 +14154,78 @@ const renderIncremental = (oldState, newState) => {
13991
14154
  return [SetPatches, newState.uid, patches];
13992
14155
  };
13993
14156
 
14157
+ const isWhitespace = className => {
14158
+ return className.includes('Whitespace');
14159
+ };
14160
+ const getLineRectangles = (line, y, height) => {
14161
+ const rectangles = [];
14162
+ let x = 0;
14163
+ for (let i = 0; i < line.length; i += 2) {
14164
+ const length = line[i];
14165
+ const className = line[i + 1];
14166
+ const width$1 = Math.min(length * characterWidth, width - x);
14167
+ if (!isWhitespace(className) && width$1 > 0) {
14168
+ rectangles.push({
14169
+ className,
14170
+ height,
14171
+ width: width$1,
14172
+ x,
14173
+ y
14174
+ });
14175
+ }
14176
+ x += length * characterWidth;
14177
+ if (x >= width) {
14178
+ return rectangles;
14179
+ }
14180
+ }
14181
+ return rectangles;
14182
+ };
14183
+ const getViewportRectangle = (state, lineCount) => {
14184
+ const {
14185
+ deltaY,
14186
+ finalDeltaY,
14187
+ height,
14188
+ numberOfVisibleLines
14189
+ } = state;
14190
+ const viewportHeight = Math.min(Math.max(numberOfVisibleLines / Math.max(lineCount, 1) * height, minimumViewportHeight), height);
14191
+ const availableHeight = Math.max(height - viewportHeight, 0);
14192
+ const y = finalDeltaY > 0 ? deltaY / finalDeltaY * availableHeight : 0;
14193
+ return {
14194
+ className: 'EditorMinimapViewport',
14195
+ height: viewportHeight,
14196
+ width: width,
14197
+ x: 0,
14198
+ y
14199
+ };
14200
+ };
14201
+ const getMinimapRectangles = state => {
14202
+ const {
14203
+ height,
14204
+ minimapLines
14205
+ } = state;
14206
+ const lineCount = minimapLines.length;
14207
+ const rectangles = [];
14208
+ if (lineCount > 0 && height > 0) {
14209
+ const rowHeight = Math.min(lineHeight, height / lineCount);
14210
+ for (let lineIndex = 0; lineIndex < lineCount; lineIndex++) {
14211
+ const line = minimapLines[lineIndex];
14212
+ const y = lineIndex * rowHeight;
14213
+ rectangles.push(...getLineRectangles(line, y, rowHeight));
14214
+ }
14215
+ }
14216
+ rectangles.push(getViewportRectangle(state, lineCount));
14217
+ return rectangles;
14218
+ };
14219
+
14220
+ const renderMinimap = (oldState, newState) => {
14221
+ if (!newState.minimapEnabled) {
14222
+ return [];
14223
+ }
14224
+ const rectangles = getMinimapRectangles(newState);
14225
+ const revision = `${newState.minimapRevision}:${newState.minLineY}`;
14226
+ return ['Viewlet.renderCanvas', newState.uid, '.EditorMinimap', 'EditorMinimapCanvas', width, newState.height, rectangles, revision];
14227
+ };
14228
+
13994
14229
  const getRenderer = diffType => {
13995
14230
  switch (diffType) {
13996
14231
  case RenderAdditionalFocusContext:
@@ -14003,6 +14238,8 @@ const getRenderer = diffType => {
14003
14238
  return renderFocusContext$1;
14004
14239
  case RenderIncremental:
14005
14240
  return renderIncremental;
14241
+ case RenderMinimap:
14242
+ return renderMinimap;
14006
14243
  case RenderWidgets:
14007
14244
  return renderWidgets$1;
14008
14245
  default:
@@ -14046,6 +14283,7 @@ const renderLines = {
14046
14283
  }
14047
14284
  const {
14048
14285
  differences,
14286
+ endOfLineDecorations,
14049
14287
  textInfos
14050
14288
  } = newState;
14051
14289
  newState.differences = differences;
@@ -14054,10 +14292,10 @@ const renderLines = {
14054
14292
  visibleLineIndices
14055
14293
  } = newState;
14056
14294
  const relativeLine = visibleLineIndices.indexOf(highlightedLine);
14057
- const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine);
14295
+ const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine, visibleLineIndices, endOfLineDecorations);
14058
14296
  return [/* method */'setText', dom];
14059
14297
  },
14060
- isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
14298
+ isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
14061
14299
  };
14062
14300
  const renderSelections = {
14063
14301
  apply: (oldState, newState) => {
@@ -14073,11 +14311,11 @@ const renderSelections = {
14073
14311
  };
14074
14312
  const renderCss = {
14075
14313
  apply: renderCss$1,
14076
- isEqual: isEqual$3
14314
+ isEqual: isEqual$4
14077
14315
  };
14078
14316
  const renderFocus$1 = {
14079
14317
  apply: (oldState, newState) => [/* method */'setFocused', newState.focused],
14080
- isEqual: isEqual$2
14318
+ isEqual: isEqual$3
14081
14319
  };
14082
14320
  const renderFocusContext = {
14083
14321
  apply: (oldState, newState) => [SetFocusContext$1, newState.uid, newState.focus, 0, newState.uid, 'Editor'],
@@ -14085,7 +14323,7 @@ const renderFocusContext = {
14085
14323
  };
14086
14324
  const renderAdditionalFocusContext = {
14087
14325
  apply: renderAdditionalFocusContext$1,
14088
- isEqual: isEqual$4
14326
+ isEqual: isEqual$5
14089
14327
  };
14090
14328
  const renderDecorations = {
14091
14329
  apply(oldState, newState) {
@@ -57,9 +57,9 @@
57
57
  "category": "text-editor",
58
58
  "description": "Controls whether the minimap is shown",
59
59
  "heading": "Minimap",
60
- "id": "editor.minimap",
60
+ "id": "editor.minimap.enabled",
61
61
  "type": 3,
62
- "value": "true"
62
+ "value": false
63
63
  },
64
64
  {
65
65
  "category": "text-editor",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.34.0",
3
+ "version": "19.36.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"