@lvce-editor/editor-worker 19.35.0 → 19.37.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.
- package/dist/editorWorkerMain.js +207 -31
- package/dist/settings.json +2 -2
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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 = {
|
|
@@ -4579,11 +4640,15 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
4579
4640
|
lines: [],
|
|
4580
4641
|
longestLineWidth: 0,
|
|
4581
4642
|
maxLineY: 0,
|
|
4643
|
+
minimapEnabled: false,
|
|
4644
|
+
minimapLines: [],
|
|
4645
|
+
minimapRevision: 0,
|
|
4582
4646
|
minimumSliderSize: 20,
|
|
4583
4647
|
minLineY: 0,
|
|
4584
4648
|
modified: false,
|
|
4585
4649
|
numberOfLines: 0,
|
|
4586
4650
|
numberOfVisibleLines: 0,
|
|
4651
|
+
outerWidth: width,
|
|
4587
4652
|
platform,
|
|
4588
4653
|
primarySelectionIndex: 0,
|
|
4589
4654
|
redoStack: [],
|
|
@@ -4643,7 +4708,11 @@ const emptyEditor = {
|
|
|
4643
4708
|
lines: [],
|
|
4644
4709
|
longestLineWidth: 0,
|
|
4645
4710
|
maxLineY: 0,
|
|
4711
|
+
minimapEnabled: false,
|
|
4712
|
+
minimapLines: [],
|
|
4713
|
+
minimapRevision: 0,
|
|
4646
4714
|
minLineY: 0,
|
|
4715
|
+
outerWidth: 0,
|
|
4647
4716
|
redoStack: [],
|
|
4648
4717
|
scrollBarHeight: 0,
|
|
4649
4718
|
selectionAnchorPosition: {
|
|
@@ -4971,15 +5040,15 @@ const createStandaloneEditor = async ({
|
|
|
4971
5040
|
set$8(id, createdEditor, finalEditor);
|
|
4972
5041
|
};
|
|
4973
5042
|
|
|
4974
|
-
const isEqual$
|
|
5043
|
+
const isEqual$5 = (oldState, newState) => {
|
|
4975
5044
|
return oldState.additionalFocus === newState.additionalFocus;
|
|
4976
5045
|
};
|
|
4977
5046
|
|
|
4978
|
-
const isEqual$
|
|
5047
|
+
const isEqual$4 = (oldState, newState) => {
|
|
4979
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;
|
|
4980
5049
|
};
|
|
4981
5050
|
|
|
4982
|
-
const isEqual$
|
|
5051
|
+
const isEqual$3 = (oldState, newState) => {
|
|
4983
5052
|
if (oldState.focus !== newState.focus) {
|
|
4984
5053
|
return false;
|
|
4985
5054
|
}
|
|
@@ -4992,23 +5061,31 @@ const isEqual$2 = (oldState, newState) => {
|
|
|
4992
5061
|
return oldState.focused === newState.focused;
|
|
4993
5062
|
};
|
|
4994
5063
|
|
|
4995
|
-
const isEqual$
|
|
5064
|
+
const isEqual$2 = (oldState, newState) => {
|
|
4996
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;
|
|
4997
5066
|
};
|
|
4998
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
|
+
|
|
4999
5075
|
const RenderFocus = 6;
|
|
5000
5076
|
const RenderFocusContext = 7;
|
|
5001
5077
|
const RenderCss = 11;
|
|
5002
5078
|
const RenderIncremental = 12;
|
|
5003
5079
|
const RenderWidgets = 13;
|
|
5004
5080
|
const RenderAdditionalFocusContext = 14;
|
|
5081
|
+
const RenderMinimap = 15;
|
|
5005
5082
|
|
|
5006
5083
|
const isEqual = (oldState, newState) => {
|
|
5007
5084
|
return oldState.widgets === newState.widgets && oldState.widgetRevision === newState.widgetRevision;
|
|
5008
5085
|
};
|
|
5009
5086
|
|
|
5010
|
-
const modules = [isEqual$1, isEqual$
|
|
5011
|
-
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];
|
|
5012
5089
|
|
|
5013
5090
|
const diff = (oldState, newState) => {
|
|
5014
5091
|
const diffResult = [];
|
|
@@ -6619,7 +6696,7 @@ const copyLineDown = editor => {
|
|
|
6619
6696
|
return {
|
|
6620
6697
|
deleted: [''],
|
|
6621
6698
|
end: position,
|
|
6622
|
-
inserted: [getLine(editor, rowIndex), ''],
|
|
6699
|
+
inserted: [getLine$1(editor, rowIndex), ''],
|
|
6623
6700
|
start: position
|
|
6624
6701
|
};
|
|
6625
6702
|
});
|
|
@@ -6646,7 +6723,7 @@ const copyLineUp = editor => {
|
|
|
6646
6723
|
const changes = [{
|
|
6647
6724
|
deleted: [''],
|
|
6648
6725
|
end: position,
|
|
6649
|
-
inserted: [getLine(editor, rowIndex), ''],
|
|
6726
|
+
inserted: [getLine$1(editor, rowIndex), ''],
|
|
6650
6727
|
start: position
|
|
6651
6728
|
}];
|
|
6652
6729
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
@@ -6769,7 +6846,7 @@ const characterRight = (line, columnIndex) => {
|
|
|
6769
6846
|
// @ts-ignore
|
|
6770
6847
|
return next.segment.length;
|
|
6771
6848
|
};
|
|
6772
|
-
const isWhitespace = char => {
|
|
6849
|
+
const isWhitespace$1 = char => {
|
|
6773
6850
|
return char === Space || char === Tab;
|
|
6774
6851
|
};
|
|
6775
6852
|
const lineCharacterStart = (line, columnIndex) => {
|
|
@@ -6777,7 +6854,7 @@ const lineCharacterStart = (line, columnIndex) => {
|
|
|
6777
6854
|
return 0;
|
|
6778
6855
|
}
|
|
6779
6856
|
for (let i = 0; i < columnIndex; i++) {
|
|
6780
|
-
if (!isWhitespace(line[i])) {
|
|
6857
|
+
if (!isWhitespace$1(line[i])) {
|
|
6781
6858
|
return columnIndex - i;
|
|
6782
6859
|
}
|
|
6783
6860
|
}
|
|
@@ -7981,7 +8058,7 @@ const getNewSelections$7 = (line, rowIndex, columnIndex) => {
|
|
|
7981
8058
|
|
|
7982
8059
|
// @ts-ignore
|
|
7983
8060
|
const selectWord = (editor, rowIndex, columnIndex) => {
|
|
7984
|
-
const line = getLine(editor, rowIndex);
|
|
8061
|
+
const line = getLine$1(editor, rowIndex);
|
|
7985
8062
|
const newSelections = getNewSelections$7(line, rowIndex, columnIndex);
|
|
7986
8063
|
return scheduleSelections(editor, newSelections);
|
|
7987
8064
|
};
|
|
@@ -8092,7 +8169,7 @@ const selectLine = editor => {
|
|
|
8092
8169
|
selections
|
|
8093
8170
|
} = editor;
|
|
8094
8171
|
const rowIndex = selections[editor.primarySelectionIndex];
|
|
8095
|
-
const line = getLine(editor, rowIndex);
|
|
8172
|
+
const line = getLine$1(editor, rowIndex);
|
|
8096
8173
|
const newSelections = getNewSelections$6(line, rowIndex);
|
|
8097
8174
|
return scheduleSelections(editor, newSelections);
|
|
8098
8175
|
};
|
|
@@ -10823,7 +10900,7 @@ const getSnippetChanges = (lines, selections, snippet) => {
|
|
|
10823
10900
|
for (let i = 0; i < selections.length; i += 4) {
|
|
10824
10901
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
10825
10902
|
if (insertedLines.length > 1) {
|
|
10826
|
-
const line = getLine({
|
|
10903
|
+
const line = getLine$1({
|
|
10827
10904
|
lines
|
|
10828
10905
|
}, selectionStartRow);
|
|
10829
10906
|
const indent = getIndent(line);
|
|
@@ -10981,14 +11058,14 @@ const getBlockCommentEdits = (editor, blockComment) => {
|
|
|
10981
11058
|
selections
|
|
10982
11059
|
} = editor;
|
|
10983
11060
|
const [rowIndex] = selections;
|
|
10984
|
-
const line = getLine(editor, rowIndex);
|
|
11061
|
+
const line = getLine$1(editor, rowIndex);
|
|
10985
11062
|
const numberOfLines = editor.lines.length;
|
|
10986
11063
|
let endRowIndex = rowIndex;
|
|
10987
11064
|
let endColumnIndex = -1;
|
|
10988
11065
|
const blockCommentStart = blockComment[0];
|
|
10989
11066
|
const blockCommentEnd = blockComment[1];
|
|
10990
11067
|
while (endRowIndex < numberOfLines) {
|
|
10991
|
-
const line = getLine(editor, endRowIndex);
|
|
11068
|
+
const line = getLine$1(editor, endRowIndex);
|
|
10992
11069
|
endColumnIndex = line.indexOf(blockCommentEnd);
|
|
10993
11070
|
if (endColumnIndex !== -1) {
|
|
10994
11071
|
break;
|
|
@@ -10998,7 +11075,7 @@ const getBlockCommentEdits = (editor, blockComment) => {
|
|
|
10998
11075
|
let startColumnIndex = -1;
|
|
10999
11076
|
let startRowIndex = rowIndex;
|
|
11000
11077
|
while (startRowIndex >= 0) {
|
|
11001
|
-
const line = getLine(editor, startRowIndex);
|
|
11078
|
+
const line = getLine$1(editor, startRowIndex);
|
|
11002
11079
|
startColumnIndex = line.indexOf(blockCommentStart);
|
|
11003
11080
|
if (startColumnIndex !== -1) {
|
|
11004
11081
|
break;
|
|
@@ -11188,7 +11265,7 @@ const editorToggleLineComment = async editor => {
|
|
|
11188
11265
|
}
|
|
11189
11266
|
const textDocument = editor;
|
|
11190
11267
|
const cursorRowIndex = editor.selections[0];
|
|
11191
|
-
const line = getLine(textDocument, cursorRowIndex);
|
|
11268
|
+
const line = getLine$1(textDocument, cursorRowIndex);
|
|
11192
11269
|
const documentEdits = [getLineCommentEdit(cursorRowIndex, line, lineComment)];
|
|
11193
11270
|
return scheduleDocumentAndCursorsSelections(editor, documentEdits);
|
|
11194
11271
|
};
|
|
@@ -12786,6 +12863,7 @@ const kAutoClosingQuotes = 'editor.autoClosingQuotes';
|
|
|
12786
12863
|
const kAutoClosingBrackets = 'editor.autoclosingBrackets';
|
|
12787
12864
|
const kFontWeight = 'editor.fontWeight';
|
|
12788
12865
|
const kHover = 'editor.hover';
|
|
12866
|
+
const kMinimapEnabled = 'editor.minimap.enabled';
|
|
12789
12867
|
const isAutoClosingBracketsEnabled = async () => {
|
|
12790
12868
|
return Boolean(await get$3(kAutoClosingBrackets));
|
|
12791
12869
|
};
|
|
@@ -12831,9 +12909,12 @@ const diagnosticsEnabled = async () => {
|
|
|
12831
12909
|
const getFontWeight = async () => {
|
|
12832
12910
|
return (await get$3(kFontWeight)) ?? 400;
|
|
12833
12911
|
};
|
|
12912
|
+
const getMinimapEnabled = async () => {
|
|
12913
|
+
return (await get$3(kMinimapEnabled)) ?? false;
|
|
12914
|
+
};
|
|
12834
12915
|
|
|
12835
12916
|
const getEditorPreferences = async () => {
|
|
12836
|
-
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()]);
|
|
12837
12918
|
return {
|
|
12838
12919
|
completionTriggerCharacters,
|
|
12839
12920
|
diagnosticsEnabled: diagnosticsEnabled$1,
|
|
@@ -12847,6 +12928,7 @@ const getEditorPreferences = async () => {
|
|
|
12847
12928
|
isQuickSuggestionsEnabled: isQuickSuggestionsEnabled$1,
|
|
12848
12929
|
letterSpacing,
|
|
12849
12930
|
lineNumbers,
|
|
12931
|
+
minimapEnabled,
|
|
12850
12932
|
rowHeight,
|
|
12851
12933
|
tabSize
|
|
12852
12934
|
};
|
|
@@ -12860,6 +12942,7 @@ const handleSettingsChanged = async state => {
|
|
|
12860
12942
|
fontSize,
|
|
12861
12943
|
fontWeight,
|
|
12862
12944
|
letterSpacing,
|
|
12945
|
+
minimapEnabled,
|
|
12863
12946
|
rowHeight
|
|
12864
12947
|
} = editorPreferences;
|
|
12865
12948
|
const [charWidth, completionsOnTypeRaw] = await Promise.all([measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing), get$3('editor.completionsOnType')]);
|
|
@@ -12872,6 +12955,7 @@ const handleSettingsChanged = async state => {
|
|
|
12872
12955
|
diagnostics: diagnosticsEnabled ? state.diagnostics : [],
|
|
12873
12956
|
isMonospaceFont,
|
|
12874
12957
|
itemHeight: rowHeight,
|
|
12958
|
+
minimapRevision: (state.minimapRevision || 0) + (minimapEnabled ? 1 : 0),
|
|
12875
12959
|
visualDecorations: diagnosticsEnabled ? state.visualDecorations : []
|
|
12876
12960
|
};
|
|
12877
12961
|
return resize(editorWithUpdatedSettings, {}, charWidth);
|
|
@@ -13151,6 +13235,7 @@ const loadContent = async (state, savedState) => {
|
|
|
13151
13235
|
isQuickSuggestionsEnabled,
|
|
13152
13236
|
letterSpacing,
|
|
13153
13237
|
lineNumbers,
|
|
13238
|
+
minimapEnabled,
|
|
13154
13239
|
rowHeight,
|
|
13155
13240
|
tabSize
|
|
13156
13241
|
} = await getEditorPreferences();
|
|
@@ -13181,6 +13266,7 @@ const loadContent = async (state, savedState) => {
|
|
|
13181
13266
|
letterSpacing,
|
|
13182
13267
|
lineNumbers,
|
|
13183
13268
|
loadError: '',
|
|
13269
|
+
minimapEnabled,
|
|
13184
13270
|
rowHeight,
|
|
13185
13271
|
tabSize,
|
|
13186
13272
|
tokenizerId: newTokenizerId
|
|
@@ -13669,12 +13755,12 @@ const diffTree = (oldNodes, newNodes) => {
|
|
|
13669
13755
|
return removeTrailingNavigationPatches(patches);
|
|
13670
13756
|
};
|
|
13671
13757
|
|
|
13758
|
+
const True = 'true';
|
|
13759
|
+
|
|
13672
13760
|
const Button = 'button';
|
|
13673
13761
|
const Code = 'code';
|
|
13674
13762
|
const TextBox = 'textbox';
|
|
13675
13763
|
|
|
13676
|
-
const True = 'true';
|
|
13677
|
-
|
|
13678
13764
|
const editorInputNode = {
|
|
13679
13765
|
childCount: 1,
|
|
13680
13766
|
className: 'EditorInput',
|
|
@@ -13971,6 +14057,19 @@ const textEditorErrorMessageNode = {
|
|
|
13971
14057
|
className: 'TextEditorErrorMessage',
|
|
13972
14058
|
type: Div
|
|
13973
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-lineCount': minimapLines.length,
|
|
14069
|
+
'data-visibleStart': minLineY,
|
|
14070
|
+
type: Div
|
|
14071
|
+
}];
|
|
14072
|
+
};
|
|
13974
14073
|
const getEditorVirtualDom = ({
|
|
13975
14074
|
breakPoints = [],
|
|
13976
14075
|
cursorInfos = [],
|
|
@@ -13981,6 +14080,8 @@ const getEditorVirtualDom = ({
|
|
|
13981
14080
|
lineNumbers = true,
|
|
13982
14081
|
loadError = '',
|
|
13983
14082
|
maxLineY = 0,
|
|
14083
|
+
minimapEnabled = false,
|
|
14084
|
+
minimapLines = [],
|
|
13984
14085
|
minLineY = 0,
|
|
13985
14086
|
scrollBarDiagnostics = [],
|
|
13986
14087
|
selectionInfos = [],
|
|
@@ -14000,8 +14101,9 @@ const getEditorVirtualDom = ({
|
|
|
14000
14101
|
const visibleGutterInfos = breakPoints.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices) : gutterInfos;
|
|
14001
14102
|
const showGutter = lineNumbers || breakPoints.length > 0;
|
|
14002
14103
|
const gutterDom = showGutter ? getEditorGutterVirtualDom(visibleGutterInfos) : [];
|
|
14104
|
+
const minimapDom = getMinimapVirtualDom(minimapEnabled, minimapLines, minLineY);
|
|
14003
14105
|
return [{
|
|
14004
|
-
childCount: showGutter ? 2 : 1,
|
|
14106
|
+
childCount: (showGutter ? 2 : 1) + (minimapEnabled ? 1 : 0),
|
|
14005
14107
|
className: mergeClassNames('Viewlet', 'Editor'),
|
|
14006
14108
|
'data-uid': uid,
|
|
14007
14109
|
onContextMenu: HandleContextMenu,
|
|
@@ -14016,7 +14118,7 @@ const getEditorVirtualDom = ({
|
|
|
14016
14118
|
scrollBarDiagnostics,
|
|
14017
14119
|
selectionInfos,
|
|
14018
14120
|
textInfos
|
|
14019
|
-
})];
|
|
14121
|
+
}), ...minimapDom];
|
|
14020
14122
|
};
|
|
14021
14123
|
|
|
14022
14124
|
const renderedDoms = new Map();
|
|
@@ -14052,6 +14154,78 @@ const renderIncremental = (oldState, newState) => {
|
|
|
14052
14154
|
return [SetPatches, newState.uid, patches];
|
|
14053
14155
|
};
|
|
14054
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
|
+
|
|
14055
14229
|
const getRenderer = diffType => {
|
|
14056
14230
|
switch (diffType) {
|
|
14057
14231
|
case RenderAdditionalFocusContext:
|
|
@@ -14064,6 +14238,8 @@ const getRenderer = diffType => {
|
|
|
14064
14238
|
return renderFocusContext$1;
|
|
14065
14239
|
case RenderIncremental:
|
|
14066
14240
|
return renderIncremental;
|
|
14241
|
+
case RenderMinimap:
|
|
14242
|
+
return renderMinimap;
|
|
14067
14243
|
case RenderWidgets:
|
|
14068
14244
|
return renderWidgets$1;
|
|
14069
14245
|
default:
|
|
@@ -14135,11 +14311,11 @@ const renderSelections = {
|
|
|
14135
14311
|
};
|
|
14136
14312
|
const renderCss = {
|
|
14137
14313
|
apply: renderCss$1,
|
|
14138
|
-
isEqual: isEqual$
|
|
14314
|
+
isEqual: isEqual$4
|
|
14139
14315
|
};
|
|
14140
14316
|
const renderFocus$1 = {
|
|
14141
14317
|
apply: (oldState, newState) => [/* method */'setFocused', newState.focused],
|
|
14142
|
-
isEqual: isEqual$
|
|
14318
|
+
isEqual: isEqual$3
|
|
14143
14319
|
};
|
|
14144
14320
|
const renderFocusContext = {
|
|
14145
14321
|
apply: (oldState, newState) => [SetFocusContext$1, newState.uid, newState.focus, 0, newState.uid, 'Editor'],
|
|
@@ -14147,7 +14323,7 @@ const renderFocusContext = {
|
|
|
14147
14323
|
};
|
|
14148
14324
|
const renderAdditionalFocusContext = {
|
|
14149
14325
|
apply: renderAdditionalFocusContext$1,
|
|
14150
|
-
isEqual: isEqual$
|
|
14326
|
+
isEqual: isEqual$5
|
|
14151
14327
|
};
|
|
14152
14328
|
const renderDecorations = {
|
|
14153
14329
|
apply(oldState, newState) {
|
package/dist/settings.json
CHANGED
|
@@ -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":
|
|
62
|
+
"value": false
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"category": "text-editor",
|