monaco-editor11 1.0.9 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/monaco-editor11.es.js +12 -16
- package/dist/monaco-editor11.umd.js +1 -1
- package/package.json +2 -2
- package/dist/monaco.d.ts +0 -8
- package/dist/workers/common/initialize.js +0 -16
- package/dist/workers/common/workers.js +0 -141
- package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +0 -128
- package/dist/workers/editor/common/abstractText.js +0 -89
- package/dist/workers/editor/common/ast.js +0 -485
- package/dist/workers/editor/common/autoIndent.js +0 -390
- package/dist/workers/editor/common/beforeEditPositionMapper.js +0 -110
- package/dist/workers/editor/common/bracketPairsImpl.js +0 -717
- package/dist/workers/editor/common/bracketPairsTree.js +0 -343
- package/dist/workers/editor/common/brackets.js +0 -108
- package/dist/workers/editor/common/characterClassifier.js +0 -59
- package/dist/workers/editor/common/characterPair.js +0 -40
- package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +0 -97
- package/dist/workers/editor/common/columnRange.js +0 -35
- package/dist/workers/editor/common/combineTextEditInfos.js +0 -124
- package/dist/workers/editor/common/common.js +0 -20
- package/dist/workers/editor/common/computeMovedLines.js +0 -249
- package/dist/workers/editor/common/concat23Trees.js +0 -192
- package/dist/workers/editor/common/contiguousMultilineTokens.js +0 -32
- package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +0 -23
- package/dist/workers/editor/common/contiguousTokensEditing.js +0 -128
- package/dist/workers/editor/common/contiguousTokensStore.js +0 -207
- package/dist/workers/editor/common/coordinatesConverter.js +0 -51
- package/dist/workers/editor/common/cursor.js +0 -899
- package/dist/workers/editor/common/cursorAtomicMoveOperations.js +0 -145
- package/dist/workers/editor/common/cursorCollection.js +0 -194
- package/dist/workers/editor/common/cursorColumnSelection.js +0 -93
- package/dist/workers/editor/common/cursorColumns.js +0 -112
- package/dist/workers/editor/common/cursorCommon.js +0 -250
- package/dist/workers/editor/common/cursorContext.js +0 -15
- package/dist/workers/editor/common/cursorDeleteOperations.js +0 -231
- package/dist/workers/editor/common/cursorMoveCommands.js +0 -676
- package/dist/workers/editor/common/cursorMoveOperations.js +0 -290
- package/dist/workers/editor/common/cursorTypeEditOperations.js +0 -968
- package/dist/workers/editor/common/cursorTypeOperations.js +0 -173
- package/dist/workers/editor/common/cursorUtils.js +0 -75
- package/dist/workers/editor/common/cursorWordOperations.js +0 -720
- package/dist/workers/editor/common/defaultDocumentColorsComputer.js +0 -138
- package/dist/workers/editor/common/defaultLinesDiffComputer.js +0 -188
- package/dist/workers/editor/common/diffAlgorithm.js +0 -139
- package/dist/workers/editor/common/diffEditor.js +0 -38
- package/dist/workers/editor/common/dynamicProgrammingDiffing.js +0 -101
- package/dist/workers/editor/common/edit.js +0 -183
- package/dist/workers/editor/common/editOperation.js +0 -36
- package/dist/workers/editor/common/editStack.js +0 -363
- package/dist/workers/editor/common/editorAction.js +0 -26
- package/dist/workers/editor/common/editorBaseApi.js +0 -43
- package/dist/workers/editor/common/editorColorRegistry.js +0 -102
- package/dist/workers/editor/common/editorCommon.js +0 -13
- package/dist/workers/editor/common/editorConfigurationSchema.js +0 -338
- package/dist/workers/editor/common/editorContextKeys.js +0 -84
- package/dist/workers/editor/common/editorFeatures.js +0 -17
- package/dist/workers/editor/common/editorOptions.js +0 -3440
- package/dist/workers/editor/common/editorTheme.js +0 -23
- package/dist/workers/editor/common/editorWebWorker.js +0 -299
- package/dist/workers/editor/common/editorWorker.js +0 -9
- package/dist/workers/editor/common/editorWorkerHost.js +0 -15
- package/dist/workers/editor/common/editorZoom.js +0 -26
- package/dist/workers/editor/common/electricCharacter.js +0 -55
- package/dist/workers/editor/common/encodedTokenAttributes.js +0 -79
- package/dist/workers/editor/common/enterAction.js +0 -53
- package/dist/workers/editor/common/eolCounter.js +0 -44
- package/dist/workers/editor/common/findSectionHeaders.js +0 -128
- package/dist/workers/editor/common/fixBrackets.js +0 -67
- package/dist/workers/editor/common/fixedArray.js +0 -70
- package/dist/workers/editor/common/fontInfo.js +0 -172
- package/dist/workers/editor/common/fontInfoFromSettings.js +0 -29
- package/dist/workers/editor/common/getIconClasses.js +0 -106
- package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +0 -24
- package/dist/workers/editor/common/glyphLanesModel.js +0 -61
- package/dist/workers/editor/common/guidesTextModelPart.js +0 -405
- package/dist/workers/editor/common/heuristicSequenceOptimizations.js +0 -374
- package/dist/workers/editor/common/indentRules.js +0 -63
- package/dist/workers/editor/common/indentation.js +0 -39
- package/dist/workers/editor/common/indentationGuesser.js +0 -178
- package/dist/workers/editor/common/indentationLineProcessor.js +0 -193
- package/dist/workers/editor/common/inlineDecorations.js +0 -26
- package/dist/workers/editor/common/inplaceReplaceSupport.js +0 -87
- package/dist/workers/editor/common/inputMode.js +0 -22
- package/dist/workers/editor/common/intervalTree.js +0 -1002
- package/dist/workers/editor/common/language.js +0 -9
- package/dist/workers/editor/common/languageBracketsConfiguration.js +0 -133
- package/dist/workers/editor/common/languageConfiguration.js +0 -138
- package/dist/workers/editor/common/languageConfigurationRegistry.js +0 -361
- package/dist/workers/editor/common/languageFeatureDebounce.js +0 -137
- package/dist/workers/editor/common/languageFeatureRegistry.js +0 -180
- package/dist/workers/editor/common/languageFeatures.js +0 -9
- package/dist/workers/editor/common/languageFeaturesService.js +0 -47
- package/dist/workers/editor/common/languageSelector.js +0 -112
- package/dist/workers/editor/common/languageService.js +0 -92
- package/dist/workers/editor/common/languages.js +0 -522
- package/dist/workers/editor/common/languagesAssociations.js +0 -193
- package/dist/workers/editor/common/languagesRegistry.js +0 -237
- package/dist/workers/editor/common/legacyLinesDiffComputer.js +0 -468
- package/dist/workers/editor/common/length.js +0 -129
- package/dist/workers/editor/common/lineDecorations.js +0 -208
- package/dist/workers/editor/common/lineEdit.js +0 -75
- package/dist/workers/editor/common/lineHeights.js +0 -370
- package/dist/workers/editor/common/linePart.js +0 -25
- package/dist/workers/editor/common/lineRange.js +0 -312
- package/dist/workers/editor/common/lineSequence.js +0 -36
- package/dist/workers/editor/common/lineTokens.js +0 -405
- package/dist/workers/editor/common/linesDiffComputer.js +0 -29
- package/dist/workers/editor/common/linesDiffComputers.js +0 -13
- package/dist/workers/editor/common/linesLayout.js +0 -765
- package/dist/workers/editor/common/linesSliceCharSequence.js +0 -205
- package/dist/workers/editor/common/linkComputer.js +0 -269
- package/dist/workers/editor/common/markerDecorations.js +0 -9
- package/dist/workers/editor/common/markerDecorationsService.js +0 -248
- package/dist/workers/editor/common/minimapTokensColorTracker.js +0 -58
- package/dist/workers/editor/common/mirrorTextModel.js +0 -117
- package/dist/workers/editor/common/model.js +0 -9
- package/dist/workers/editor/common/modelLineProjection.js +0 -350
- package/dist/workers/editor/common/modelLineProjectionData.js +0 -297
- package/dist/workers/editor/common/modelService.js +0 -413
- package/dist/workers/editor/common/modesRegistry.js +0 -75
- package/dist/workers/editor/common/monospaceLineBreaksComputer.js +0 -473
- package/dist/workers/editor/common/myersDiffAlgorithm.js +0 -159
- package/dist/workers/editor/common/nodeReader.js +0 -127
- package/dist/workers/editor/common/nullTokenize.js +0 -29
- package/dist/workers/editor/common/offsetRange.js +0 -225
- package/dist/workers/editor/common/onEnter.js +0 -109
- package/dist/workers/editor/common/oneCursor.js +0 -117
- package/dist/workers/editor/common/overviewZoneManager.js +0 -176
- package/dist/workers/editor/common/parser.js +0 -121
- package/dist/workers/editor/common/pieceTreeBase.js +0 -1473
- package/dist/workers/editor/common/pieceTreeTextBuffer.js +0 -461
- package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +0 -140
- package/dist/workers/editor/common/point.js +0 -50
- package/dist/workers/editor/common/position.js +0 -142
- package/dist/workers/editor/common/positionToOffset.js +0 -17
- package/dist/workers/editor/common/positionToOffsetImpl.js +0 -98
- package/dist/workers/editor/common/prefixSumComputer.js +0 -226
- package/dist/workers/editor/common/range.js +0 -421
- package/dist/workers/editor/common/rangeMapping.js +0 -229
- package/dist/workers/editor/common/rangeSingleLine.js +0 -17
- package/dist/workers/editor/common/rbTreeBase.js +0 -362
- package/dist/workers/editor/common/rect.js +0 -163
- package/dist/workers/editor/common/replaceCommand.js +0 -158
- package/dist/workers/editor/common/resolverService.js +0 -5
- package/dist/workers/editor/common/rgba.js +0 -35
- package/dist/workers/editor/common/richEditBrackets.js +0 -356
- package/dist/workers/editor/common/selection.js +0 -145
- package/dist/workers/editor/common/semanticTokensDto.js +0 -82
- package/dist/workers/editor/common/semanticTokensProviderStyling.js +0 -263
- package/dist/workers/editor/common/semanticTokensStyling.js +0 -9
- package/dist/workers/editor/common/semanticTokensStylingService.js +0 -47
- package/dist/workers/editor/common/shiftCommand.js +0 -241
- package/dist/workers/editor/common/smallImmutableSet.js +0 -108
- package/dist/workers/editor/common/sparseMultilineTokens.js +0 -548
- package/dist/workers/editor/common/sparseTokensStore.js +0 -210
- package/dist/workers/editor/common/standaloneEnums.js +0 -1017
- package/dist/workers/editor/common/standaloneStrings.js +0 -42
- package/dist/workers/editor/common/stringBuilder.js +0 -122
- package/dist/workers/editor/common/stringEdit.js +0 -165
- package/dist/workers/editor/common/supports.js +0 -58
- package/dist/workers/editor/common/surroundSelectionCommand.js +0 -44
- package/dist/workers/editor/common/textChange.js +0 -248
- package/dist/workers/editor/common/textEdit.js +0 -269
- package/dist/workers/editor/common/textLength.js +0 -87
- package/dist/workers/editor/common/textModel.js +0 -2031
- package/dist/workers/editor/common/textModelBracketPairs.js +0 -45
- package/dist/workers/editor/common/textModelDefaults.js +0 -18
- package/dist/workers/editor/common/textModelEditSource.js +0 -166
- package/dist/workers/editor/common/textModelEvents.js +0 -216
- package/dist/workers/editor/common/textModelGuides.js +0 -40
- package/dist/workers/editor/common/textModelPart.js +0 -23
- package/dist/workers/editor/common/textModelSearch.js +0 -455
- package/dist/workers/editor/common/textModelStringEdit.js +0 -11
- package/dist/workers/editor/common/textModelSync.impl.js +0 -307
- package/dist/workers/editor/common/textModelText.js +0 -26
- package/dist/workers/editor/common/textModelTokens.js +0 -436
- package/dist/workers/editor/common/textResourceConfiguration.js +0 -6
- package/dist/workers/editor/common/textToHtmlTokenizer.js +0 -139
- package/dist/workers/editor/common/tokenStore.js +0 -407
- package/dist/workers/editor/common/tokenWithTextArray.js +0 -73
- package/dist/workers/editor/common/tokenization.js +0 -287
- package/dist/workers/editor/common/tokenizationRegistry.js +0 -123
- package/dist/workers/editor/common/tokenizationTextModelPart.js +0 -275
- package/dist/workers/editor/common/tokenizer.js +0 -301
- package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +0 -261
- package/dist/workers/editor/common/treeSitterLibraryService.js +0 -9
- package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +0 -167
- package/dist/workers/editor/common/treeSitterThemeService.js +0 -9
- package/dist/workers/editor/common/treeSitterTokenizationImpl.js +0 -713
- package/dist/workers/editor/common/treeSitterTree.js +0 -395
- package/dist/workers/editor/common/treeViewsDnd.js +0 -24
- package/dist/workers/editor/common/treeViewsDndService.js +0 -12
- package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +0 -98
- package/dist/workers/editor/common/unicodeTextModelHighlighter.js +0 -188
- package/dist/workers/editor/common/utils.js +0 -62
- package/dist/workers/editor/common/viewContext.js +0 -22
- package/dist/workers/editor/common/viewEventHandler.js +0 -186
- package/dist/workers/editor/common/viewEvents.js +0 -180
- package/dist/workers/editor/common/viewLayout.js +0 -368
- package/dist/workers/editor/common/viewLineRenderer.js +0 -948
- package/dist/workers/editor/common/viewLinesViewportData.js +0 -30
- package/dist/workers/editor/common/viewModel.js +0 -98
- package/dist/workers/editor/common/viewModelDecoration.js +0 -55
- package/dist/workers/editor/common/viewModelDecorations.js +0 -132
- package/dist/workers/editor/common/viewModelEventDispatcher.js +0 -398
- package/dist/workers/editor/common/viewModelImpl.js +0 -1163
- package/dist/workers/editor/common/viewModelLines.js +0 -938
- package/dist/workers/editor/common/wordCharacterClassifier.js +0 -87
- package/dist/workers/editor/common/wordHelper.js +0 -127
- package/dist/workers/language/cssMode.js +0 -198
- package/dist/workers/language/cssWorker.js +0 -183
- package/dist/workers/language/htmlMode.js +0 -213
- package/dist/workers/language/htmlWorker.js +0 -126
- package/dist/workers/language/jsonMode.js +0 -224
- package/dist/workers/language/jsonWorker.js +0 -187
- package/dist/workers/language/languageFeatures.js +0 -1009
- package/dist/workers/language/lib.index.js +0 -103
- package/dist/workers/language/lib.js +0 -1107
- package/dist/workers/language/lspLanguageFeatures.js +0 -716
- package/dist/workers/language/monaco.contribution.js +0 -144
- package/dist/workers/language/tokenization.js +0 -189
- package/dist/workers/language/tsMode.js +0 -212
- package/dist/workers/language/tsWorker.js +0 -352
- package/dist/workers/language/typescriptServices.js +0 -210154
- package/dist/workers/language/typescriptServicesMetadata.js +0 -3
- package/dist/workers/language/workerManager.js +0 -65
- /package/dist/workers/{language/css.worker.js → css.worker.js} +0 -0
- /package/dist/workers/{editor/editor.worker.js → editor.worker.js} +0 -0
- /package/dist/workers/{language/html.worker.js → html.worker.js} +0 -0
- /package/dist/workers/{language/json.worker.js → json.worker.js} +0 -0
- /package/dist/workers/{language/ts.worker.js → ts.worker.js} +0 -0
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { isHighSurrogate } from '../../../base/common/strings.js';
|
|
2
|
-
|
|
3
|
-
/*---------------------------------------------------------------------------------------------
|
|
4
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
6
|
-
*--------------------------------------------------------------------------------------------*/
|
|
7
|
-
class LineDecoration {
|
|
8
|
-
constructor(startColumn, endColumn, className, type) {
|
|
9
|
-
this.startColumn = startColumn;
|
|
10
|
-
this.endColumn = endColumn;
|
|
11
|
-
this.className = className;
|
|
12
|
-
this.type = type;
|
|
13
|
-
this._lineDecorationBrand = undefined;
|
|
14
|
-
}
|
|
15
|
-
static _equals(a, b) {
|
|
16
|
-
return (a.startColumn === b.startColumn
|
|
17
|
-
&& a.endColumn === b.endColumn
|
|
18
|
-
&& a.className === b.className
|
|
19
|
-
&& a.type === b.type);
|
|
20
|
-
}
|
|
21
|
-
static equalsArr(a, b) {
|
|
22
|
-
const aLen = a.length;
|
|
23
|
-
const bLen = b.length;
|
|
24
|
-
if (aLen !== bLen) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
for (let i = 0; i < aLen; i++) {
|
|
28
|
-
if (!LineDecoration._equals(a[i], b[i])) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
static extractWrapped(arr, startOffset, endOffset) {
|
|
35
|
-
if (arr.length === 0) {
|
|
36
|
-
return arr;
|
|
37
|
-
}
|
|
38
|
-
const startColumn = startOffset + 1;
|
|
39
|
-
const endColumn = endOffset + 1;
|
|
40
|
-
const lineLength = endOffset - startOffset;
|
|
41
|
-
const r = [];
|
|
42
|
-
let rLength = 0;
|
|
43
|
-
for (const dec of arr) {
|
|
44
|
-
if (dec.endColumn <= startColumn || dec.startColumn >= endColumn) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
r[rLength++] = new LineDecoration(Math.max(1, dec.startColumn - startColumn + 1), Math.min(lineLength + 1, dec.endColumn - startColumn + 1), dec.className, dec.type);
|
|
48
|
-
}
|
|
49
|
-
return r;
|
|
50
|
-
}
|
|
51
|
-
static filter(lineDecorations, lineNumber, minLineColumn, maxLineColumn) {
|
|
52
|
-
if (lineDecorations.length === 0) {
|
|
53
|
-
return [];
|
|
54
|
-
}
|
|
55
|
-
const result = [];
|
|
56
|
-
let resultLen = 0;
|
|
57
|
-
for (let i = 0, len = lineDecorations.length; i < len; i++) {
|
|
58
|
-
const d = lineDecorations[i];
|
|
59
|
-
const range = d.range;
|
|
60
|
-
if (range.endLineNumber < lineNumber || range.startLineNumber > lineNumber) {
|
|
61
|
-
// Ignore decorations that sit outside this line
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (range.isEmpty() && (d.type === 0 /* InlineDecorationType.Regular */ || d.type === 3 /* InlineDecorationType.RegularAffectingLetterSpacing */)) {
|
|
65
|
-
// Ignore empty range decorations
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
const startColumn = (range.startLineNumber === lineNumber ? range.startColumn : minLineColumn);
|
|
69
|
-
const endColumn = (range.endLineNumber === lineNumber ? range.endColumn : maxLineColumn);
|
|
70
|
-
result[resultLen++] = new LineDecoration(startColumn, endColumn, d.inlineClassName, d.type);
|
|
71
|
-
}
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
static _typeCompare(a, b) {
|
|
75
|
-
const ORDER = [2, 0, 1, 3];
|
|
76
|
-
return ORDER[a] - ORDER[b];
|
|
77
|
-
}
|
|
78
|
-
static compare(a, b) {
|
|
79
|
-
if (a.startColumn !== b.startColumn) {
|
|
80
|
-
return a.startColumn - b.startColumn;
|
|
81
|
-
}
|
|
82
|
-
if (a.endColumn !== b.endColumn) {
|
|
83
|
-
return a.endColumn - b.endColumn;
|
|
84
|
-
}
|
|
85
|
-
const typeCmp = LineDecoration._typeCompare(a.type, b.type);
|
|
86
|
-
if (typeCmp !== 0) {
|
|
87
|
-
return typeCmp;
|
|
88
|
-
}
|
|
89
|
-
if (a.className !== b.className) {
|
|
90
|
-
return a.className < b.className ? -1 : 1;
|
|
91
|
-
}
|
|
92
|
-
return 0;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
class DecorationSegment {
|
|
96
|
-
constructor(startOffset, endOffset, className, metadata) {
|
|
97
|
-
this.startOffset = startOffset;
|
|
98
|
-
this.endOffset = endOffset;
|
|
99
|
-
this.className = className;
|
|
100
|
-
this.metadata = metadata;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
class Stack {
|
|
104
|
-
constructor() {
|
|
105
|
-
this.stopOffsets = [];
|
|
106
|
-
this.classNames = [];
|
|
107
|
-
this.metadata = [];
|
|
108
|
-
this.count = 0;
|
|
109
|
-
}
|
|
110
|
-
static _metadata(metadata) {
|
|
111
|
-
let result = 0;
|
|
112
|
-
for (let i = 0, len = metadata.length; i < len; i++) {
|
|
113
|
-
result |= metadata[i];
|
|
114
|
-
}
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
consumeLowerThan(maxStopOffset, nextStartOffset, result) {
|
|
118
|
-
while (this.count > 0 && this.stopOffsets[0] < maxStopOffset) {
|
|
119
|
-
let i = 0;
|
|
120
|
-
// Take all equal stopping offsets
|
|
121
|
-
while (i + 1 < this.count && this.stopOffsets[i] === this.stopOffsets[i + 1]) {
|
|
122
|
-
i++;
|
|
123
|
-
}
|
|
124
|
-
// Basically we are consuming the first i + 1 elements of the stack
|
|
125
|
-
result.push(new DecorationSegment(nextStartOffset, this.stopOffsets[i], this.classNames.join(' '), Stack._metadata(this.metadata)));
|
|
126
|
-
nextStartOffset = this.stopOffsets[i] + 1;
|
|
127
|
-
// Consume them
|
|
128
|
-
this.stopOffsets.splice(0, i + 1);
|
|
129
|
-
this.classNames.splice(0, i + 1);
|
|
130
|
-
this.metadata.splice(0, i + 1);
|
|
131
|
-
this.count -= (i + 1);
|
|
132
|
-
}
|
|
133
|
-
if (this.count > 0 && nextStartOffset < maxStopOffset) {
|
|
134
|
-
result.push(new DecorationSegment(nextStartOffset, maxStopOffset - 1, this.classNames.join(' '), Stack._metadata(this.metadata)));
|
|
135
|
-
nextStartOffset = maxStopOffset;
|
|
136
|
-
}
|
|
137
|
-
return nextStartOffset;
|
|
138
|
-
}
|
|
139
|
-
insert(stopOffset, className, metadata) {
|
|
140
|
-
if (this.count === 0 || this.stopOffsets[this.count - 1] <= stopOffset) {
|
|
141
|
-
// Insert at the end
|
|
142
|
-
this.stopOffsets.push(stopOffset);
|
|
143
|
-
this.classNames.push(className);
|
|
144
|
-
this.metadata.push(metadata);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
// Find the insertion position for `stopOffset`
|
|
148
|
-
for (let i = 0; i < this.count; i++) {
|
|
149
|
-
if (this.stopOffsets[i] >= stopOffset) {
|
|
150
|
-
this.stopOffsets.splice(i, 0, stopOffset);
|
|
151
|
-
this.classNames.splice(i, 0, className);
|
|
152
|
-
this.metadata.splice(i, 0, metadata);
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
this.count++;
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
class LineDecorationsNormalizer {
|
|
162
|
-
/**
|
|
163
|
-
* Normalize line decorations. Overlapping decorations will generate multiple segments
|
|
164
|
-
*/
|
|
165
|
-
static normalize(lineContent, lineDecorations) {
|
|
166
|
-
if (lineDecorations.length === 0) {
|
|
167
|
-
return [];
|
|
168
|
-
}
|
|
169
|
-
const result = [];
|
|
170
|
-
const stack = new Stack();
|
|
171
|
-
let nextStartOffset = 0;
|
|
172
|
-
for (let i = 0, len = lineDecorations.length; i < len; i++) {
|
|
173
|
-
const d = lineDecorations[i];
|
|
174
|
-
let startColumn = d.startColumn;
|
|
175
|
-
let endColumn = d.endColumn;
|
|
176
|
-
const className = d.className;
|
|
177
|
-
const metadata = (d.type === 1 /* InlineDecorationType.Before */
|
|
178
|
-
? 2 /* LinePartMetadata.PSEUDO_BEFORE */
|
|
179
|
-
: d.type === 2 /* InlineDecorationType.After */
|
|
180
|
-
? 4 /* LinePartMetadata.PSEUDO_AFTER */
|
|
181
|
-
: 0);
|
|
182
|
-
// If the position would end up in the middle of a high-low surrogate pair, we move it to before the pair
|
|
183
|
-
if (startColumn > 1) {
|
|
184
|
-
const charCodeBefore = lineContent.charCodeAt(startColumn - 2);
|
|
185
|
-
if (isHighSurrogate(charCodeBefore)) {
|
|
186
|
-
startColumn--;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (endColumn > 1) {
|
|
190
|
-
const charCodeBefore = lineContent.charCodeAt(endColumn - 2);
|
|
191
|
-
if (isHighSurrogate(charCodeBefore)) {
|
|
192
|
-
endColumn--;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const currentStartOffset = startColumn - 1;
|
|
196
|
-
const currentEndOffset = endColumn - 2;
|
|
197
|
-
nextStartOffset = stack.consumeLowerThan(currentStartOffset, nextStartOffset, result);
|
|
198
|
-
if (stack.count === 0) {
|
|
199
|
-
nextStartOffset = currentStartOffset;
|
|
200
|
-
}
|
|
201
|
-
stack.insert(currentEndOffset, className, metadata);
|
|
202
|
-
}
|
|
203
|
-
stack.consumeLowerThan(1073741824 /* Constants.MAX_SAFE_SMALL_INTEGER */, nextStartOffset, result);
|
|
204
|
-
return result;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export { DecorationSegment, LineDecoration, LineDecorationsNormalizer };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { assert, checkAdjacentItems } from '../../../../base/common/assert.js';
|
|
2
|
-
import { splitLines } from '../../../../base/common/strings.js';
|
|
3
|
-
import { LineRange } from '../ranges/lineRange.js';
|
|
4
|
-
import { Position } from '../position.js';
|
|
5
|
-
import { Range } from '../range.js';
|
|
6
|
-
|
|
7
|
-
class LineEdit {
|
|
8
|
-
static { this.empty = new LineEdit([]); }
|
|
9
|
-
constructor(
|
|
10
|
-
/**
|
|
11
|
-
* Have to be sorted by start line number and non-intersecting.
|
|
12
|
-
*/
|
|
13
|
-
replacements) {
|
|
14
|
-
this.replacements = replacements;
|
|
15
|
-
assert(checkAdjacentItems(replacements, (i1, i2) => i1.lineRange.endLineNumberExclusive <= i2.lineRange.startLineNumber));
|
|
16
|
-
}
|
|
17
|
-
toString() {
|
|
18
|
-
return this.replacements.map(e => e.toString()).join(',');
|
|
19
|
-
}
|
|
20
|
-
getNewLineRanges() {
|
|
21
|
-
const ranges = [];
|
|
22
|
-
let offset = 0;
|
|
23
|
-
for (const e of this.replacements) {
|
|
24
|
-
ranges.push(LineRange.ofLength(e.lineRange.startLineNumber + offset, e.newLines.length));
|
|
25
|
-
offset += e.newLines.length - e.lineRange.length;
|
|
26
|
-
}
|
|
27
|
-
return ranges;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
class LineReplacement {
|
|
31
|
-
static fromSingleTextEdit(edit, initialValue) {
|
|
32
|
-
// 1: ab[cde
|
|
33
|
-
// 2: fghijk
|
|
34
|
-
// 3: lmn]opq
|
|
35
|
-
// replaced with
|
|
36
|
-
// 1n: 123
|
|
37
|
-
// 2n: 456
|
|
38
|
-
// 3n: 789
|
|
39
|
-
// simple solution: replace [1..4) with [1n..4n)
|
|
40
|
-
const newLines = splitLines(edit.text);
|
|
41
|
-
let startLineNumber = edit.range.startLineNumber;
|
|
42
|
-
const survivingFirstLineText = initialValue.getValueOfRange(Range.fromPositions(new Position(edit.range.startLineNumber, 1), edit.range.getStartPosition()));
|
|
43
|
-
newLines[0] = survivingFirstLineText + newLines[0];
|
|
44
|
-
let endLineNumberEx = edit.range.endLineNumber + 1;
|
|
45
|
-
const editEndLineNumberMaxColumn = initialValue.getTransformer().getLineLength(edit.range.endLineNumber) + 1;
|
|
46
|
-
const survivingEndLineText = initialValue.getValueOfRange(Range.fromPositions(edit.range.getEndPosition(), new Position(edit.range.endLineNumber, editEndLineNumberMaxColumn)));
|
|
47
|
-
newLines[newLines.length - 1] = newLines[newLines.length - 1] + survivingEndLineText;
|
|
48
|
-
// Replacing [startLineNumber, endLineNumberEx) with newLines would be correct, however it might not be minimal.
|
|
49
|
-
const startBeforeNewLine = edit.range.startColumn === initialValue.getTransformer().getLineLength(edit.range.startLineNumber) + 1;
|
|
50
|
-
const endAfterNewLine = edit.range.endColumn === 1;
|
|
51
|
-
if (startBeforeNewLine && newLines[0].length === survivingFirstLineText.length) {
|
|
52
|
-
// the replacement would not delete any text on the first line
|
|
53
|
-
startLineNumber++;
|
|
54
|
-
newLines.shift();
|
|
55
|
-
}
|
|
56
|
-
if (newLines.length > 0 && startLineNumber < endLineNumberEx && endAfterNewLine && newLines[newLines.length - 1].length === survivingEndLineText.length) {
|
|
57
|
-
// the replacement would not delete any text on the last line
|
|
58
|
-
endLineNumberEx--;
|
|
59
|
-
newLines.pop();
|
|
60
|
-
}
|
|
61
|
-
return new LineReplacement(new LineRange(startLineNumber, endLineNumberEx), newLines);
|
|
62
|
-
}
|
|
63
|
-
constructor(lineRange, newLines) {
|
|
64
|
-
this.lineRange = lineRange;
|
|
65
|
-
this.newLines = newLines;
|
|
66
|
-
}
|
|
67
|
-
toString() {
|
|
68
|
-
return `${this.lineRange}->${JSON.stringify(this.newLines)}`;
|
|
69
|
-
}
|
|
70
|
-
toLineEdit() {
|
|
71
|
-
return new LineEdit([this]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { LineEdit, LineReplacement };
|
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import { binarySearch2 } from '../../../base/common/arrays.js';
|
|
2
|
-
import { intersection } from '../../../base/common/collections.js';
|
|
3
|
-
|
|
4
|
-
/*---------------------------------------------------------------------------------------------
|
|
5
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
7
|
-
*--------------------------------------------------------------------------------------------*/
|
|
8
|
-
class CustomLine {
|
|
9
|
-
constructor(decorationId, index, lineNumber, specialHeight, prefixSum) {
|
|
10
|
-
this.decorationId = decorationId;
|
|
11
|
-
this.index = index;
|
|
12
|
-
this.lineNumber = lineNumber;
|
|
13
|
-
this.specialHeight = specialHeight;
|
|
14
|
-
this.prefixSum = prefixSum;
|
|
15
|
-
this.maximumSpecialHeight = specialHeight;
|
|
16
|
-
this.deleted = false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Manages line heights in the editor with support for custom line heights from decorations.
|
|
21
|
-
*
|
|
22
|
-
* This class maintains an ordered collection of line heights, where each line can have either
|
|
23
|
-
* the default height or a custom height specified by decorations. It supports efficient querying
|
|
24
|
-
* of individual line heights as well as accumulated heights up to a specific line.
|
|
25
|
-
*
|
|
26
|
-
* Line heights are stored in a sorted array for efficient binary search operations. Each line
|
|
27
|
-
* with custom height is represented by a {@link CustomLine} object which tracks its special height,
|
|
28
|
-
* accumulated height prefix sum, and associated decoration ID.
|
|
29
|
-
*
|
|
30
|
-
* The class optimizes performance by:
|
|
31
|
-
* - Using binary search to locate lines in the ordered array
|
|
32
|
-
* - Batching updates through a pending changes mechanism
|
|
33
|
-
* - Computing prefix sums for O(1) accumulated height lookup
|
|
34
|
-
* - Tracking maximum height for lines with multiple decorations
|
|
35
|
-
* - Efficiently handling document changes (line insertions and deletions)
|
|
36
|
-
*
|
|
37
|
-
* When lines are inserted or deleted, the manager updates line numbers and prefix sums
|
|
38
|
-
* for all affected lines. It also handles special cases like decorations that span
|
|
39
|
-
* the insertion/deletion points by re-applying those decorations appropriately.
|
|
40
|
-
*
|
|
41
|
-
* All query operations automatically commit pending changes to ensure consistent results.
|
|
42
|
-
* Clients can modify line heights by adding or removing custom line height decorations,
|
|
43
|
-
* which are tracked by their unique decoration IDs.
|
|
44
|
-
*/
|
|
45
|
-
class LineHeightsManager {
|
|
46
|
-
constructor(defaultLineHeight, customLineHeightData) {
|
|
47
|
-
this._decorationIDToCustomLine = new ArrayMap();
|
|
48
|
-
this._orderedCustomLines = [];
|
|
49
|
-
this._pendingSpecialLinesToInsert = [];
|
|
50
|
-
this._invalidIndex = 0;
|
|
51
|
-
this._hasPending = false;
|
|
52
|
-
this._defaultLineHeight = defaultLineHeight;
|
|
53
|
-
if (customLineHeightData.length > 0) {
|
|
54
|
-
for (const data of customLineHeightData) {
|
|
55
|
-
this.insertOrChangeCustomLineHeight(data.decorationId, data.startLineNumber, data.endLineNumber, data.lineHeight);
|
|
56
|
-
}
|
|
57
|
-
this.commit();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
set defaultLineHeight(defaultLineHeight) {
|
|
61
|
-
this._defaultLineHeight = defaultLineHeight;
|
|
62
|
-
}
|
|
63
|
-
get defaultLineHeight() {
|
|
64
|
-
return this._defaultLineHeight;
|
|
65
|
-
}
|
|
66
|
-
removeCustomLineHeight(decorationID) {
|
|
67
|
-
const customLines = this._decorationIDToCustomLine.get(decorationID);
|
|
68
|
-
if (!customLines) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this._decorationIDToCustomLine.delete(decorationID);
|
|
72
|
-
for (const customLine of customLines) {
|
|
73
|
-
customLine.deleted = true;
|
|
74
|
-
this._invalidIndex = Math.min(this._invalidIndex, customLine.index);
|
|
75
|
-
}
|
|
76
|
-
this._hasPending = true;
|
|
77
|
-
}
|
|
78
|
-
insertOrChangeCustomLineHeight(decorationId, startLineNumber, endLineNumber, lineHeight) {
|
|
79
|
-
this.removeCustomLineHeight(decorationId);
|
|
80
|
-
for (let lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
|
|
81
|
-
const customLine = new CustomLine(decorationId, -1, lineNumber, lineHeight, 0);
|
|
82
|
-
this._pendingSpecialLinesToInsert.push(customLine);
|
|
83
|
-
}
|
|
84
|
-
this._hasPending = true;
|
|
85
|
-
}
|
|
86
|
-
heightForLineNumber(lineNumber) {
|
|
87
|
-
const searchIndex = this._binarySearchOverOrderedCustomLinesArray(lineNumber);
|
|
88
|
-
if (searchIndex >= 0) {
|
|
89
|
-
return this._orderedCustomLines[searchIndex].maximumSpecialHeight;
|
|
90
|
-
}
|
|
91
|
-
return this._defaultLineHeight;
|
|
92
|
-
}
|
|
93
|
-
getAccumulatedLineHeightsIncludingLineNumber(lineNumber) {
|
|
94
|
-
const searchIndex = this._binarySearchOverOrderedCustomLinesArray(lineNumber);
|
|
95
|
-
if (searchIndex >= 0) {
|
|
96
|
-
return this._orderedCustomLines[searchIndex].prefixSum + this._orderedCustomLines[searchIndex].maximumSpecialHeight;
|
|
97
|
-
}
|
|
98
|
-
if (searchIndex === -1) {
|
|
99
|
-
return this._defaultLineHeight * lineNumber;
|
|
100
|
-
}
|
|
101
|
-
const modifiedIndex = -(searchIndex + 1);
|
|
102
|
-
const previousSpecialLine = this._orderedCustomLines[modifiedIndex - 1];
|
|
103
|
-
return previousSpecialLine.prefixSum + previousSpecialLine.maximumSpecialHeight + this._defaultLineHeight * (lineNumber - previousSpecialLine.lineNumber);
|
|
104
|
-
}
|
|
105
|
-
onLinesDeleted(fromLineNumber, toLineNumber) {
|
|
106
|
-
const deleteCount = toLineNumber - fromLineNumber + 1;
|
|
107
|
-
const numberOfCustomLines = this._orderedCustomLines.length;
|
|
108
|
-
const candidateStartIndexOfDeletion = this._binarySearchOverOrderedCustomLinesArray(fromLineNumber);
|
|
109
|
-
let startIndexOfDeletion;
|
|
110
|
-
if (candidateStartIndexOfDeletion >= 0) {
|
|
111
|
-
startIndexOfDeletion = candidateStartIndexOfDeletion;
|
|
112
|
-
for (let i = candidateStartIndexOfDeletion - 1; i >= 0; i--) {
|
|
113
|
-
if (this._orderedCustomLines[i].lineNumber === fromLineNumber) {
|
|
114
|
-
startIndexOfDeletion--;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
startIndexOfDeletion = candidateStartIndexOfDeletion === -(numberOfCustomLines + 1) && candidateStartIndexOfDeletion !== -1 ? numberOfCustomLines - 1 : -(candidateStartIndexOfDeletion + 1);
|
|
123
|
-
}
|
|
124
|
-
const candidateEndIndexOfDeletion = this._binarySearchOverOrderedCustomLinesArray(toLineNumber);
|
|
125
|
-
let endIndexOfDeletion;
|
|
126
|
-
if (candidateEndIndexOfDeletion >= 0) {
|
|
127
|
-
endIndexOfDeletion = candidateEndIndexOfDeletion;
|
|
128
|
-
for (let i = candidateEndIndexOfDeletion + 1; i < numberOfCustomLines; i++) {
|
|
129
|
-
if (this._orderedCustomLines[i].lineNumber === toLineNumber) {
|
|
130
|
-
endIndexOfDeletion++;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
endIndexOfDeletion = candidateEndIndexOfDeletion === -(numberOfCustomLines + 1) && candidateEndIndexOfDeletion !== -1 ? numberOfCustomLines - 1 : -(candidateEndIndexOfDeletion + 1);
|
|
139
|
-
}
|
|
140
|
-
const isEndIndexBiggerThanStartIndex = endIndexOfDeletion > startIndexOfDeletion;
|
|
141
|
-
const isEndIndexEqualToStartIndexAndCoversCustomLine = endIndexOfDeletion === startIndexOfDeletion
|
|
142
|
-
&& this._orderedCustomLines[startIndexOfDeletion]
|
|
143
|
-
&& this._orderedCustomLines[startIndexOfDeletion].lineNumber >= fromLineNumber
|
|
144
|
-
&& this._orderedCustomLines[startIndexOfDeletion].lineNumber <= toLineNumber;
|
|
145
|
-
if (isEndIndexBiggerThanStartIndex || isEndIndexEqualToStartIndexAndCoversCustomLine) {
|
|
146
|
-
let maximumSpecialHeightOnDeletedInterval = 0;
|
|
147
|
-
for (let i = startIndexOfDeletion; i <= endIndexOfDeletion; i++) {
|
|
148
|
-
maximumSpecialHeightOnDeletedInterval = Math.max(maximumSpecialHeightOnDeletedInterval, this._orderedCustomLines[i].maximumSpecialHeight);
|
|
149
|
-
}
|
|
150
|
-
let prefixSumOnDeletedInterval = 0;
|
|
151
|
-
if (startIndexOfDeletion > 0) {
|
|
152
|
-
const previousSpecialLine = this._orderedCustomLines[startIndexOfDeletion - 1];
|
|
153
|
-
prefixSumOnDeletedInterval = previousSpecialLine.prefixSum + previousSpecialLine.maximumSpecialHeight + this._defaultLineHeight * (fromLineNumber - previousSpecialLine.lineNumber - 1);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
prefixSumOnDeletedInterval = fromLineNumber > 0 ? (fromLineNumber - 1) * this._defaultLineHeight : 0;
|
|
157
|
-
}
|
|
158
|
-
const firstSpecialLineDeleted = this._orderedCustomLines[startIndexOfDeletion];
|
|
159
|
-
const lastSpecialLineDeleted = this._orderedCustomLines[endIndexOfDeletion];
|
|
160
|
-
const firstSpecialLineAfterDeletion = this._orderedCustomLines[endIndexOfDeletion + 1];
|
|
161
|
-
const heightOfFirstLineAfterDeletion = firstSpecialLineAfterDeletion && firstSpecialLineAfterDeletion.lineNumber === toLineNumber + 1 ? firstSpecialLineAfterDeletion.maximumSpecialHeight : this._defaultLineHeight;
|
|
162
|
-
const totalHeightDeleted = lastSpecialLineDeleted.prefixSum
|
|
163
|
-
+ lastSpecialLineDeleted.maximumSpecialHeight
|
|
164
|
-
- firstSpecialLineDeleted.prefixSum
|
|
165
|
-
+ this._defaultLineHeight * (toLineNumber - lastSpecialLineDeleted.lineNumber)
|
|
166
|
-
+ this._defaultLineHeight * (firstSpecialLineDeleted.lineNumber - fromLineNumber)
|
|
167
|
-
+ heightOfFirstLineAfterDeletion - maximumSpecialHeightOnDeletedInterval;
|
|
168
|
-
const decorationIdsSeen = new Set();
|
|
169
|
-
const newOrderedCustomLines = [];
|
|
170
|
-
const newDecorationIDToSpecialLine = new ArrayMap();
|
|
171
|
-
let numberOfDeletions = 0;
|
|
172
|
-
for (let i = 0; i < this._orderedCustomLines.length; i++) {
|
|
173
|
-
const customLine = this._orderedCustomLines[i];
|
|
174
|
-
if (i < startIndexOfDeletion) {
|
|
175
|
-
newOrderedCustomLines.push(customLine);
|
|
176
|
-
newDecorationIDToSpecialLine.add(customLine.decorationId, customLine);
|
|
177
|
-
}
|
|
178
|
-
else if (i >= startIndexOfDeletion && i <= endIndexOfDeletion) {
|
|
179
|
-
const decorationId = customLine.decorationId;
|
|
180
|
-
if (!decorationIdsSeen.has(decorationId)) {
|
|
181
|
-
customLine.index -= numberOfDeletions;
|
|
182
|
-
customLine.lineNumber = fromLineNumber;
|
|
183
|
-
customLine.prefixSum = prefixSumOnDeletedInterval;
|
|
184
|
-
customLine.maximumSpecialHeight = maximumSpecialHeightOnDeletedInterval;
|
|
185
|
-
newOrderedCustomLines.push(customLine);
|
|
186
|
-
newDecorationIDToSpecialLine.add(customLine.decorationId, customLine);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
numberOfDeletions++;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
else if (i > endIndexOfDeletion) {
|
|
193
|
-
customLine.index -= numberOfDeletions;
|
|
194
|
-
customLine.lineNumber -= deleteCount;
|
|
195
|
-
customLine.prefixSum -= totalHeightDeleted;
|
|
196
|
-
newOrderedCustomLines.push(customLine);
|
|
197
|
-
newDecorationIDToSpecialLine.add(customLine.decorationId, customLine);
|
|
198
|
-
}
|
|
199
|
-
decorationIdsSeen.add(customLine.decorationId);
|
|
200
|
-
}
|
|
201
|
-
this._orderedCustomLines = newOrderedCustomLines;
|
|
202
|
-
this._decorationIDToCustomLine = newDecorationIDToSpecialLine;
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
const totalHeightDeleted = deleteCount * this._defaultLineHeight;
|
|
206
|
-
for (let i = endIndexOfDeletion; i < this._orderedCustomLines.length; i++) {
|
|
207
|
-
const customLine = this._orderedCustomLines[i];
|
|
208
|
-
if (customLine.lineNumber > toLineNumber) {
|
|
209
|
-
customLine.lineNumber -= deleteCount;
|
|
210
|
-
customLine.prefixSum -= totalHeightDeleted;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
onLinesInserted(fromLineNumber, toLineNumber) {
|
|
216
|
-
const insertCount = toLineNumber - fromLineNumber + 1;
|
|
217
|
-
const candidateStartIndexOfInsertion = this._binarySearchOverOrderedCustomLinesArray(fromLineNumber);
|
|
218
|
-
let startIndexOfInsertion;
|
|
219
|
-
if (candidateStartIndexOfInsertion >= 0) {
|
|
220
|
-
startIndexOfInsertion = candidateStartIndexOfInsertion;
|
|
221
|
-
for (let i = candidateStartIndexOfInsertion - 1; i >= 0; i--) {
|
|
222
|
-
if (this._orderedCustomLines[i].lineNumber === fromLineNumber) {
|
|
223
|
-
startIndexOfInsertion--;
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
startIndexOfInsertion = -(candidateStartIndexOfInsertion + 1);
|
|
232
|
-
}
|
|
233
|
-
const toReAdd = [];
|
|
234
|
-
const decorationsImmediatelyAfter = new Set();
|
|
235
|
-
for (let i = startIndexOfInsertion; i < this._orderedCustomLines.length; i++) {
|
|
236
|
-
if (this._orderedCustomLines[i].lineNumber === fromLineNumber) {
|
|
237
|
-
decorationsImmediatelyAfter.add(this._orderedCustomLines[i].decorationId);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const decorationsImmediatelyBefore = new Set();
|
|
241
|
-
for (let i = startIndexOfInsertion - 1; i >= 0; i--) {
|
|
242
|
-
if (this._orderedCustomLines[i].lineNumber === fromLineNumber - 1) {
|
|
243
|
-
decorationsImmediatelyBefore.add(this._orderedCustomLines[i].decorationId);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
const decorationsWithGaps = intersection(decorationsImmediatelyBefore, decorationsImmediatelyAfter);
|
|
247
|
-
for (let i = startIndexOfInsertion; i < this._orderedCustomLines.length; i++) {
|
|
248
|
-
this._orderedCustomLines[i].lineNumber += insertCount;
|
|
249
|
-
this._orderedCustomLines[i].prefixSum += this._defaultLineHeight * insertCount;
|
|
250
|
-
}
|
|
251
|
-
if (decorationsWithGaps.size > 0) {
|
|
252
|
-
for (const decorationId of decorationsWithGaps) {
|
|
253
|
-
const decoration = this._decorationIDToCustomLine.get(decorationId);
|
|
254
|
-
if (decoration) {
|
|
255
|
-
const startLineNumber = decoration.reduce((min, l) => Math.min(min, l.lineNumber), fromLineNumber); // min
|
|
256
|
-
const endLineNumber = decoration.reduce((max, l) => Math.max(max, l.lineNumber), fromLineNumber); // max
|
|
257
|
-
const lineHeight = decoration.reduce((max, l) => Math.max(max, l.specialHeight), 0);
|
|
258
|
-
toReAdd.push({
|
|
259
|
-
decorationId,
|
|
260
|
-
startLineNumber,
|
|
261
|
-
endLineNumber,
|
|
262
|
-
lineHeight
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
for (const dec of toReAdd) {
|
|
267
|
-
this.insertOrChangeCustomLineHeight(dec.decorationId, dec.startLineNumber, dec.endLineNumber, dec.lineHeight);
|
|
268
|
-
}
|
|
269
|
-
this.commit();
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
commit() {
|
|
273
|
-
if (!this._hasPending) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
for (const pendingChange of this._pendingSpecialLinesToInsert) {
|
|
277
|
-
const candidateInsertionIndex = this._binarySearchOverOrderedCustomLinesArray(pendingChange.lineNumber);
|
|
278
|
-
const insertionIndex = candidateInsertionIndex >= 0 ? candidateInsertionIndex : -(candidateInsertionIndex + 1);
|
|
279
|
-
this._orderedCustomLines.splice(insertionIndex, 0, pendingChange);
|
|
280
|
-
this._invalidIndex = Math.min(this._invalidIndex, insertionIndex);
|
|
281
|
-
}
|
|
282
|
-
this._pendingSpecialLinesToInsert = [];
|
|
283
|
-
const newDecorationIDToSpecialLine = new ArrayMap();
|
|
284
|
-
const newOrderedSpecialLines = [];
|
|
285
|
-
for (let i = 0; i < this._invalidIndex; i++) {
|
|
286
|
-
const customLine = this._orderedCustomLines[i];
|
|
287
|
-
newOrderedSpecialLines.push(customLine);
|
|
288
|
-
newDecorationIDToSpecialLine.add(customLine.decorationId, customLine);
|
|
289
|
-
}
|
|
290
|
-
let numberOfDeletions = 0;
|
|
291
|
-
let previousSpecialLine = (this._invalidIndex > 0) ? newOrderedSpecialLines[this._invalidIndex - 1] : undefined;
|
|
292
|
-
for (let i = this._invalidIndex; i < this._orderedCustomLines.length; i++) {
|
|
293
|
-
const customLine = this._orderedCustomLines[i];
|
|
294
|
-
if (customLine.deleted) {
|
|
295
|
-
numberOfDeletions++;
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
customLine.index = i - numberOfDeletions;
|
|
299
|
-
if (previousSpecialLine && previousSpecialLine.lineNumber === customLine.lineNumber) {
|
|
300
|
-
customLine.maximumSpecialHeight = previousSpecialLine.maximumSpecialHeight;
|
|
301
|
-
customLine.prefixSum = previousSpecialLine.prefixSum;
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
let maximumSpecialHeight = customLine.specialHeight;
|
|
305
|
-
for (let j = i; j < this._orderedCustomLines.length; j++) {
|
|
306
|
-
const nextSpecialLine = this._orderedCustomLines[j];
|
|
307
|
-
if (nextSpecialLine.deleted) {
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
if (nextSpecialLine.lineNumber !== customLine.lineNumber) {
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
maximumSpecialHeight = Math.max(maximumSpecialHeight, nextSpecialLine.specialHeight);
|
|
314
|
-
}
|
|
315
|
-
customLine.maximumSpecialHeight = maximumSpecialHeight;
|
|
316
|
-
let prefixSum;
|
|
317
|
-
if (previousSpecialLine) {
|
|
318
|
-
prefixSum = previousSpecialLine.prefixSum + previousSpecialLine.maximumSpecialHeight + this._defaultLineHeight * (customLine.lineNumber - previousSpecialLine.lineNumber - 1);
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
prefixSum = this._defaultLineHeight * (customLine.lineNumber - 1);
|
|
322
|
-
}
|
|
323
|
-
customLine.prefixSum = prefixSum;
|
|
324
|
-
}
|
|
325
|
-
previousSpecialLine = customLine;
|
|
326
|
-
newOrderedSpecialLines.push(customLine);
|
|
327
|
-
newDecorationIDToSpecialLine.add(customLine.decorationId, customLine);
|
|
328
|
-
}
|
|
329
|
-
this._orderedCustomLines = newOrderedSpecialLines;
|
|
330
|
-
this._decorationIDToCustomLine = newDecorationIDToSpecialLine;
|
|
331
|
-
this._invalidIndex = Infinity;
|
|
332
|
-
this._hasPending = false;
|
|
333
|
-
}
|
|
334
|
-
_binarySearchOverOrderedCustomLinesArray(lineNumber) {
|
|
335
|
-
return binarySearch2(this._orderedCustomLines.length, (index) => {
|
|
336
|
-
const line = this._orderedCustomLines[index];
|
|
337
|
-
if (line.lineNumber === lineNumber) {
|
|
338
|
-
return 0;
|
|
339
|
-
}
|
|
340
|
-
else if (line.lineNumber < lineNumber) {
|
|
341
|
-
return -1;
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
return 1;
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
class ArrayMap {
|
|
350
|
-
constructor() {
|
|
351
|
-
this._map = new Map();
|
|
352
|
-
}
|
|
353
|
-
add(key, value) {
|
|
354
|
-
const array = this._map.get(key);
|
|
355
|
-
if (!array) {
|
|
356
|
-
this._map.set(key, [value]);
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
array.push(value);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
get(key) {
|
|
363
|
-
return this._map.get(key);
|
|
364
|
-
}
|
|
365
|
-
delete(key) {
|
|
366
|
-
this._map.delete(key);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
export { CustomLine, LineHeightsManager };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
class LinePart {
|
|
6
|
-
constructor(
|
|
7
|
-
/**
|
|
8
|
-
* last char index of this token (not inclusive).
|
|
9
|
-
*/
|
|
10
|
-
endIndex, type, metadata, containsRTL) {
|
|
11
|
-
this.endIndex = endIndex;
|
|
12
|
-
this.type = type;
|
|
13
|
-
this.metadata = metadata;
|
|
14
|
-
this.containsRTL = containsRTL;
|
|
15
|
-
this._linePartBrand = undefined;
|
|
16
|
-
}
|
|
17
|
-
isWhitespace() {
|
|
18
|
-
return (this.metadata & 1 /* LinePartMetadata.IS_WHITESPACE_MASK */ ? true : false);
|
|
19
|
-
}
|
|
20
|
-
isPseudoAfter() {
|
|
21
|
-
return (this.metadata & 4 /* LinePartMetadata.PSEUDO_AFTER_MASK */ ? true : false);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { LinePart };
|