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,362 +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 TreeNode {
|
|
6
|
-
constructor(piece, color) {
|
|
7
|
-
this.piece = piece;
|
|
8
|
-
this.color = color;
|
|
9
|
-
this.size_left = 0;
|
|
10
|
-
this.lf_left = 0;
|
|
11
|
-
this.parent = this;
|
|
12
|
-
this.left = this;
|
|
13
|
-
this.right = this;
|
|
14
|
-
}
|
|
15
|
-
next() {
|
|
16
|
-
if (this.right !== SENTINEL) {
|
|
17
|
-
return leftest(this.right);
|
|
18
|
-
}
|
|
19
|
-
let node = this;
|
|
20
|
-
while (node.parent !== SENTINEL) {
|
|
21
|
-
if (node.parent.left === node) {
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
node = node.parent;
|
|
25
|
-
}
|
|
26
|
-
if (node.parent === SENTINEL) {
|
|
27
|
-
return SENTINEL;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return node.parent;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
prev() {
|
|
34
|
-
if (this.left !== SENTINEL) {
|
|
35
|
-
return righttest(this.left);
|
|
36
|
-
}
|
|
37
|
-
let node = this;
|
|
38
|
-
while (node.parent !== SENTINEL) {
|
|
39
|
-
if (node.parent.right === node) {
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
node = node.parent;
|
|
43
|
-
}
|
|
44
|
-
if (node.parent === SENTINEL) {
|
|
45
|
-
return SENTINEL;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return node.parent;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
detach() {
|
|
52
|
-
this.parent = null;
|
|
53
|
-
this.left = null;
|
|
54
|
-
this.right = null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const SENTINEL = new TreeNode(null, 0 /* NodeColor.Black */);
|
|
58
|
-
SENTINEL.parent = SENTINEL;
|
|
59
|
-
SENTINEL.left = SENTINEL;
|
|
60
|
-
SENTINEL.right = SENTINEL;
|
|
61
|
-
SENTINEL.color = 0 /* NodeColor.Black */;
|
|
62
|
-
function leftest(node) {
|
|
63
|
-
while (node.left !== SENTINEL) {
|
|
64
|
-
node = node.left;
|
|
65
|
-
}
|
|
66
|
-
return node;
|
|
67
|
-
}
|
|
68
|
-
function righttest(node) {
|
|
69
|
-
while (node.right !== SENTINEL) {
|
|
70
|
-
node = node.right;
|
|
71
|
-
}
|
|
72
|
-
return node;
|
|
73
|
-
}
|
|
74
|
-
function calculateSize(node) {
|
|
75
|
-
if (node === SENTINEL) {
|
|
76
|
-
return 0;
|
|
77
|
-
}
|
|
78
|
-
return node.size_left + node.piece.length + calculateSize(node.right);
|
|
79
|
-
}
|
|
80
|
-
function calculateLF(node) {
|
|
81
|
-
if (node === SENTINEL) {
|
|
82
|
-
return 0;
|
|
83
|
-
}
|
|
84
|
-
return node.lf_left + node.piece.lineFeedCnt + calculateLF(node.right);
|
|
85
|
-
}
|
|
86
|
-
function resetSentinel() {
|
|
87
|
-
SENTINEL.parent = SENTINEL;
|
|
88
|
-
}
|
|
89
|
-
function leftRotate(tree, x) {
|
|
90
|
-
const y = x.right;
|
|
91
|
-
// fix size_left
|
|
92
|
-
y.size_left += x.size_left + (x.piece ? x.piece.length : 0);
|
|
93
|
-
y.lf_left += x.lf_left + (x.piece ? x.piece.lineFeedCnt : 0);
|
|
94
|
-
x.right = y.left;
|
|
95
|
-
if (y.left !== SENTINEL) {
|
|
96
|
-
y.left.parent = x;
|
|
97
|
-
}
|
|
98
|
-
y.parent = x.parent;
|
|
99
|
-
if (x.parent === SENTINEL) {
|
|
100
|
-
tree.root = y;
|
|
101
|
-
}
|
|
102
|
-
else if (x.parent.left === x) {
|
|
103
|
-
x.parent.left = y;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
x.parent.right = y;
|
|
107
|
-
}
|
|
108
|
-
y.left = x;
|
|
109
|
-
x.parent = y;
|
|
110
|
-
}
|
|
111
|
-
function rightRotate(tree, y) {
|
|
112
|
-
const x = y.left;
|
|
113
|
-
y.left = x.right;
|
|
114
|
-
if (x.right !== SENTINEL) {
|
|
115
|
-
x.right.parent = y;
|
|
116
|
-
}
|
|
117
|
-
x.parent = y.parent;
|
|
118
|
-
// fix size_left
|
|
119
|
-
y.size_left -= x.size_left + (x.piece ? x.piece.length : 0);
|
|
120
|
-
y.lf_left -= x.lf_left + (x.piece ? x.piece.lineFeedCnt : 0);
|
|
121
|
-
if (y.parent === SENTINEL) {
|
|
122
|
-
tree.root = x;
|
|
123
|
-
}
|
|
124
|
-
else if (y === y.parent.right) {
|
|
125
|
-
y.parent.right = x;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
y.parent.left = x;
|
|
129
|
-
}
|
|
130
|
-
x.right = y;
|
|
131
|
-
y.parent = x;
|
|
132
|
-
}
|
|
133
|
-
function rbDelete(tree, z) {
|
|
134
|
-
let x;
|
|
135
|
-
let y;
|
|
136
|
-
if (z.left === SENTINEL) {
|
|
137
|
-
y = z;
|
|
138
|
-
x = y.right;
|
|
139
|
-
}
|
|
140
|
-
else if (z.right === SENTINEL) {
|
|
141
|
-
y = z;
|
|
142
|
-
x = y.left;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
y = leftest(z.right);
|
|
146
|
-
x = y.right;
|
|
147
|
-
}
|
|
148
|
-
if (y === tree.root) {
|
|
149
|
-
tree.root = x;
|
|
150
|
-
// if x is null, we are removing the only node
|
|
151
|
-
x.color = 0 /* NodeColor.Black */;
|
|
152
|
-
z.detach();
|
|
153
|
-
resetSentinel();
|
|
154
|
-
tree.root.parent = SENTINEL;
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const yWasRed = (y.color === 1 /* NodeColor.Red */);
|
|
158
|
-
if (y === y.parent.left) {
|
|
159
|
-
y.parent.left = x;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
y.parent.right = x;
|
|
163
|
-
}
|
|
164
|
-
if (y === z) {
|
|
165
|
-
x.parent = y.parent;
|
|
166
|
-
recomputeTreeMetadata(tree, x);
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
if (y.parent === z) {
|
|
170
|
-
x.parent = y;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
x.parent = y.parent;
|
|
174
|
-
}
|
|
175
|
-
// as we make changes to x's hierarchy, update size_left of subtree first
|
|
176
|
-
recomputeTreeMetadata(tree, x);
|
|
177
|
-
y.left = z.left;
|
|
178
|
-
y.right = z.right;
|
|
179
|
-
y.parent = z.parent;
|
|
180
|
-
y.color = z.color;
|
|
181
|
-
if (z === tree.root) {
|
|
182
|
-
tree.root = y;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
if (z === z.parent.left) {
|
|
186
|
-
z.parent.left = y;
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
z.parent.right = y;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (y.left !== SENTINEL) {
|
|
193
|
-
y.left.parent = y;
|
|
194
|
-
}
|
|
195
|
-
if (y.right !== SENTINEL) {
|
|
196
|
-
y.right.parent = y;
|
|
197
|
-
}
|
|
198
|
-
// update metadata
|
|
199
|
-
// we replace z with y, so in this sub tree, the length change is z.item.length
|
|
200
|
-
y.size_left = z.size_left;
|
|
201
|
-
y.lf_left = z.lf_left;
|
|
202
|
-
recomputeTreeMetadata(tree, y);
|
|
203
|
-
}
|
|
204
|
-
z.detach();
|
|
205
|
-
if (x.parent.left === x) {
|
|
206
|
-
const newSizeLeft = calculateSize(x);
|
|
207
|
-
const newLFLeft = calculateLF(x);
|
|
208
|
-
if (newSizeLeft !== x.parent.size_left || newLFLeft !== x.parent.lf_left) {
|
|
209
|
-
const delta = newSizeLeft - x.parent.size_left;
|
|
210
|
-
const lf_delta = newLFLeft - x.parent.lf_left;
|
|
211
|
-
x.parent.size_left = newSizeLeft;
|
|
212
|
-
x.parent.lf_left = newLFLeft;
|
|
213
|
-
updateTreeMetadata(tree, x.parent, delta, lf_delta);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
recomputeTreeMetadata(tree, x.parent);
|
|
217
|
-
if (yWasRed) {
|
|
218
|
-
resetSentinel();
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
// RB-DELETE-FIXUP
|
|
222
|
-
let w;
|
|
223
|
-
while (x !== tree.root && x.color === 0 /* NodeColor.Black */) {
|
|
224
|
-
if (x === x.parent.left) {
|
|
225
|
-
w = x.parent.right;
|
|
226
|
-
if (w.color === 1 /* NodeColor.Red */) {
|
|
227
|
-
w.color = 0 /* NodeColor.Black */;
|
|
228
|
-
x.parent.color = 1 /* NodeColor.Red */;
|
|
229
|
-
leftRotate(tree, x.parent);
|
|
230
|
-
w = x.parent.right;
|
|
231
|
-
}
|
|
232
|
-
if (w.left.color === 0 /* NodeColor.Black */ && w.right.color === 0 /* NodeColor.Black */) {
|
|
233
|
-
w.color = 1 /* NodeColor.Red */;
|
|
234
|
-
x = x.parent;
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
if (w.right.color === 0 /* NodeColor.Black */) {
|
|
238
|
-
w.left.color = 0 /* NodeColor.Black */;
|
|
239
|
-
w.color = 1 /* NodeColor.Red */;
|
|
240
|
-
rightRotate(tree, w);
|
|
241
|
-
w = x.parent.right;
|
|
242
|
-
}
|
|
243
|
-
w.color = x.parent.color;
|
|
244
|
-
x.parent.color = 0 /* NodeColor.Black */;
|
|
245
|
-
w.right.color = 0 /* NodeColor.Black */;
|
|
246
|
-
leftRotate(tree, x.parent);
|
|
247
|
-
x = tree.root;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
w = x.parent.left;
|
|
252
|
-
if (w.color === 1 /* NodeColor.Red */) {
|
|
253
|
-
w.color = 0 /* NodeColor.Black */;
|
|
254
|
-
x.parent.color = 1 /* NodeColor.Red */;
|
|
255
|
-
rightRotate(tree, x.parent);
|
|
256
|
-
w = x.parent.left;
|
|
257
|
-
}
|
|
258
|
-
if (w.left.color === 0 /* NodeColor.Black */ && w.right.color === 0 /* NodeColor.Black */) {
|
|
259
|
-
w.color = 1 /* NodeColor.Red */;
|
|
260
|
-
x = x.parent;
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
if (w.left.color === 0 /* NodeColor.Black */) {
|
|
264
|
-
w.right.color = 0 /* NodeColor.Black */;
|
|
265
|
-
w.color = 1 /* NodeColor.Red */;
|
|
266
|
-
leftRotate(tree, w);
|
|
267
|
-
w = x.parent.left;
|
|
268
|
-
}
|
|
269
|
-
w.color = x.parent.color;
|
|
270
|
-
x.parent.color = 0 /* NodeColor.Black */;
|
|
271
|
-
w.left.color = 0 /* NodeColor.Black */;
|
|
272
|
-
rightRotate(tree, x.parent);
|
|
273
|
-
x = tree.root;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
x.color = 0 /* NodeColor.Black */;
|
|
278
|
-
resetSentinel();
|
|
279
|
-
}
|
|
280
|
-
function fixInsert(tree, x) {
|
|
281
|
-
recomputeTreeMetadata(tree, x);
|
|
282
|
-
while (x !== tree.root && x.parent.color === 1 /* NodeColor.Red */) {
|
|
283
|
-
if (x.parent === x.parent.parent.left) {
|
|
284
|
-
const y = x.parent.parent.right;
|
|
285
|
-
if (y.color === 1 /* NodeColor.Red */) {
|
|
286
|
-
x.parent.color = 0 /* NodeColor.Black */;
|
|
287
|
-
y.color = 0 /* NodeColor.Black */;
|
|
288
|
-
x.parent.parent.color = 1 /* NodeColor.Red */;
|
|
289
|
-
x = x.parent.parent;
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
if (x === x.parent.right) {
|
|
293
|
-
x = x.parent;
|
|
294
|
-
leftRotate(tree, x);
|
|
295
|
-
}
|
|
296
|
-
x.parent.color = 0 /* NodeColor.Black */;
|
|
297
|
-
x.parent.parent.color = 1 /* NodeColor.Red */;
|
|
298
|
-
rightRotate(tree, x.parent.parent);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
const y = x.parent.parent.left;
|
|
303
|
-
if (y.color === 1 /* NodeColor.Red */) {
|
|
304
|
-
x.parent.color = 0 /* NodeColor.Black */;
|
|
305
|
-
y.color = 0 /* NodeColor.Black */;
|
|
306
|
-
x.parent.parent.color = 1 /* NodeColor.Red */;
|
|
307
|
-
x = x.parent.parent;
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
if (x === x.parent.left) {
|
|
311
|
-
x = x.parent;
|
|
312
|
-
rightRotate(tree, x);
|
|
313
|
-
}
|
|
314
|
-
x.parent.color = 0 /* NodeColor.Black */;
|
|
315
|
-
x.parent.parent.color = 1 /* NodeColor.Red */;
|
|
316
|
-
leftRotate(tree, x.parent.parent);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
tree.root.color = 0 /* NodeColor.Black */;
|
|
321
|
-
}
|
|
322
|
-
function updateTreeMetadata(tree, x, delta, lineFeedCntDelta) {
|
|
323
|
-
// node length change or line feed count change
|
|
324
|
-
while (x !== tree.root && x !== SENTINEL) {
|
|
325
|
-
if (x.parent.left === x) {
|
|
326
|
-
x.parent.size_left += delta;
|
|
327
|
-
x.parent.lf_left += lineFeedCntDelta;
|
|
328
|
-
}
|
|
329
|
-
x = x.parent;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
function recomputeTreeMetadata(tree, x) {
|
|
333
|
-
let delta = 0;
|
|
334
|
-
let lf_delta = 0;
|
|
335
|
-
if (x === tree.root) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
// go upwards till the node whose left subtree is changed.
|
|
339
|
-
while (x !== tree.root && x === x.parent.right) {
|
|
340
|
-
x = x.parent;
|
|
341
|
-
}
|
|
342
|
-
if (x === tree.root) {
|
|
343
|
-
// well, it means we add a node to the end (inorder)
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
// x is the node whose right subtree is changed.
|
|
347
|
-
x = x.parent;
|
|
348
|
-
delta = calculateSize(x.left) - x.size_left;
|
|
349
|
-
lf_delta = calculateLF(x.left) - x.lf_left;
|
|
350
|
-
x.size_left += delta;
|
|
351
|
-
x.lf_left += lf_delta;
|
|
352
|
-
// go upwards till root. O(logN)
|
|
353
|
-
while (x !== tree.root && (delta !== 0 || lf_delta !== 0)) {
|
|
354
|
-
if (x.parent.left === x) {
|
|
355
|
-
x.parent.size_left += delta;
|
|
356
|
-
x.parent.lf_left += lf_delta;
|
|
357
|
-
}
|
|
358
|
-
x = x.parent;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export { SENTINEL, TreeNode, fixInsert, leftRotate, leftest, rbDelete, recomputeTreeMetadata, rightRotate, righttest, updateTreeMetadata };
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { BugIndicatingError } from '../../../../base/common/errors.js';
|
|
2
|
-
import { Point } from './point.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 Rect {
|
|
9
|
-
static fromPoints(topLeft, bottomRight) {
|
|
10
|
-
return new Rect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
|
|
11
|
-
}
|
|
12
|
-
static fromPointSize(point, size) {
|
|
13
|
-
return new Rect(point.x, point.y, point.x + size.x, point.y + size.y);
|
|
14
|
-
}
|
|
15
|
-
static fromLeftTopRightBottom(left, top, right, bottom) {
|
|
16
|
-
return new Rect(left, top, right, bottom);
|
|
17
|
-
}
|
|
18
|
-
static fromLeftTopWidthHeight(left, top, width, height) {
|
|
19
|
-
return new Rect(left, top, left + width, top + height);
|
|
20
|
-
}
|
|
21
|
-
static fromRanges(leftRight, topBottom) {
|
|
22
|
-
return new Rect(leftRight.start, topBottom.start, leftRight.endExclusive, topBottom.endExclusive);
|
|
23
|
-
}
|
|
24
|
-
static hull(rects) {
|
|
25
|
-
let left = Number.MAX_SAFE_INTEGER;
|
|
26
|
-
let top = Number.MAX_SAFE_INTEGER;
|
|
27
|
-
let right = Number.MIN_SAFE_INTEGER;
|
|
28
|
-
let bottom = Number.MIN_SAFE_INTEGER;
|
|
29
|
-
for (const rect of rects) {
|
|
30
|
-
left = Math.min(left, rect.left);
|
|
31
|
-
top = Math.min(top, rect.top);
|
|
32
|
-
right = Math.max(right, rect.right);
|
|
33
|
-
bottom = Math.max(bottom, rect.bottom);
|
|
34
|
-
}
|
|
35
|
-
return new Rect(left, top, right, bottom);
|
|
36
|
-
}
|
|
37
|
-
get width() { return this.right - this.left; }
|
|
38
|
-
get height() { return this.bottom - this.top; }
|
|
39
|
-
constructor(left, top, right, bottom) {
|
|
40
|
-
this.left = left;
|
|
41
|
-
this.top = top;
|
|
42
|
-
this.right = right;
|
|
43
|
-
this.bottom = bottom;
|
|
44
|
-
if (left > right) {
|
|
45
|
-
throw new BugIndicatingError('Invalid arguments: Horizontally offset by ' + (left - right));
|
|
46
|
-
}
|
|
47
|
-
if (top > bottom) {
|
|
48
|
-
throw new BugIndicatingError('Invalid arguments: Vertically offset by ' + (top - bottom));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
withMargin(marginOrVerticalOrTop, rightOrHorizontal, bottom, left) {
|
|
52
|
-
let marginLeft, marginRight, marginTop, marginBottom;
|
|
53
|
-
// Single margin value
|
|
54
|
-
if (rightOrHorizontal === undefined && bottom === undefined && left === undefined) {
|
|
55
|
-
marginLeft = marginRight = marginTop = marginBottom = marginOrVerticalOrTop;
|
|
56
|
-
}
|
|
57
|
-
// Vertical and horizontal margins
|
|
58
|
-
else if (bottom === undefined && left === undefined) {
|
|
59
|
-
marginLeft = marginRight = rightOrHorizontal;
|
|
60
|
-
marginTop = marginBottom = marginOrVerticalOrTop;
|
|
61
|
-
}
|
|
62
|
-
// Individual margins for all sides
|
|
63
|
-
else {
|
|
64
|
-
marginLeft = left;
|
|
65
|
-
marginRight = rightOrHorizontal;
|
|
66
|
-
marginTop = marginOrVerticalOrTop;
|
|
67
|
-
marginBottom = bottom;
|
|
68
|
-
}
|
|
69
|
-
return new Rect(this.left - marginLeft, this.top - marginTop, this.right + marginRight, this.bottom + marginBottom);
|
|
70
|
-
}
|
|
71
|
-
intersectVertical(range) {
|
|
72
|
-
const newTop = Math.max(this.top, range.start);
|
|
73
|
-
const newBottom = Math.min(this.bottom, range.endExclusive);
|
|
74
|
-
return new Rect(this.left, newTop, this.right, Math.max(newTop, newBottom));
|
|
75
|
-
}
|
|
76
|
-
intersectHorizontal(range) {
|
|
77
|
-
const newLeft = Math.max(this.left, range.start);
|
|
78
|
-
const newRight = Math.min(this.right, range.endExclusive);
|
|
79
|
-
return new Rect(newLeft, this.top, Math.max(newLeft, newRight), this.bottom);
|
|
80
|
-
}
|
|
81
|
-
toString() {
|
|
82
|
-
return `Rect{(${this.left},${this.top}), (${this.right},${this.bottom})}`;
|
|
83
|
-
}
|
|
84
|
-
intersect(parent) {
|
|
85
|
-
const left = Math.max(this.left, parent.left);
|
|
86
|
-
const right = Math.min(this.right, parent.right);
|
|
87
|
-
const top = Math.max(this.top, parent.top);
|
|
88
|
-
const bottom = Math.min(this.bottom, parent.bottom);
|
|
89
|
-
if (left > right || top > bottom) {
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
return new Rect(left, top, right, bottom);
|
|
93
|
-
}
|
|
94
|
-
containsRect(other) {
|
|
95
|
-
return this.left <= other.left
|
|
96
|
-
&& this.top <= other.top
|
|
97
|
-
&& this.right >= other.right
|
|
98
|
-
&& this.bottom >= other.bottom;
|
|
99
|
-
}
|
|
100
|
-
containsPoint(point) {
|
|
101
|
-
return this.left <= point.x
|
|
102
|
-
&& this.top <= point.y
|
|
103
|
-
&& this.right >= point.x
|
|
104
|
-
&& this.bottom >= point.y;
|
|
105
|
-
}
|
|
106
|
-
moveToBeContainedIn(parent) {
|
|
107
|
-
const width = this.width;
|
|
108
|
-
const height = this.height;
|
|
109
|
-
let left = this.left;
|
|
110
|
-
let top = this.top;
|
|
111
|
-
if (left < parent.left) {
|
|
112
|
-
left = parent.left;
|
|
113
|
-
}
|
|
114
|
-
else if (left + width > parent.right) {
|
|
115
|
-
left = parent.right - width;
|
|
116
|
-
}
|
|
117
|
-
if (top < parent.top) {
|
|
118
|
-
top = parent.top;
|
|
119
|
-
}
|
|
120
|
-
else if (top + height > parent.bottom) {
|
|
121
|
-
top = parent.bottom - height;
|
|
122
|
-
}
|
|
123
|
-
return new Rect(left, top, left + width, top + height);
|
|
124
|
-
}
|
|
125
|
-
withWidth(width) {
|
|
126
|
-
return new Rect(this.left, this.top, this.left + width, this.bottom);
|
|
127
|
-
}
|
|
128
|
-
withHeight(height) {
|
|
129
|
-
return new Rect(this.left, this.top, this.right, this.top + height);
|
|
130
|
-
}
|
|
131
|
-
withTop(top) {
|
|
132
|
-
return new Rect(this.left, top, this.right, this.bottom);
|
|
133
|
-
}
|
|
134
|
-
withLeft(left) {
|
|
135
|
-
return new Rect(left, this.top, this.right, this.bottom);
|
|
136
|
-
}
|
|
137
|
-
translateX(delta) {
|
|
138
|
-
return new Rect(this.left + delta, this.top, this.right + delta, this.bottom);
|
|
139
|
-
}
|
|
140
|
-
translateY(delta) {
|
|
141
|
-
return new Rect(this.left, this.top + delta, this.right, this.bottom + delta);
|
|
142
|
-
}
|
|
143
|
-
getLeftBottom() {
|
|
144
|
-
return new Point(this.left, this.bottom);
|
|
145
|
-
}
|
|
146
|
-
getRightBottom() {
|
|
147
|
-
return new Point(this.right, this.bottom);
|
|
148
|
-
}
|
|
149
|
-
getRightTop() {
|
|
150
|
-
return new Point(this.right, this.top);
|
|
151
|
-
}
|
|
152
|
-
toStyles() {
|
|
153
|
-
return {
|
|
154
|
-
position: 'absolute',
|
|
155
|
-
left: `${this.left}px`,
|
|
156
|
-
top: `${this.top}px`,
|
|
157
|
-
width: `${this.width}px`,
|
|
158
|
-
height: `${this.height}px`,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export { Rect };
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { Position } from '../core/position.js';
|
|
2
|
-
import { Range } from '../core/range.js';
|
|
3
|
-
import { Selection } from '../core/selection.js';
|
|
4
|
-
|
|
5
|
-
/*---------------------------------------------------------------------------------------------
|
|
6
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
8
|
-
*--------------------------------------------------------------------------------------------*/
|
|
9
|
-
class ReplaceCommand {
|
|
10
|
-
constructor(range, text, insertsAutoWhitespace = false) {
|
|
11
|
-
this._range = range;
|
|
12
|
-
this._text = text;
|
|
13
|
-
this.insertsAutoWhitespace = insertsAutoWhitespace;
|
|
14
|
-
}
|
|
15
|
-
getEditOperations(model, builder) {
|
|
16
|
-
builder.addTrackedEditOperation(this._range, this._text);
|
|
17
|
-
}
|
|
18
|
-
computeCursorState(model, helper) {
|
|
19
|
-
const inverseEditOperations = helper.getInverseEditOperations();
|
|
20
|
-
const srcRange = inverseEditOperations[0].range;
|
|
21
|
-
return Selection.fromPositions(srcRange.getEndPosition());
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
class ReplaceOvertypeCommand {
|
|
25
|
-
constructor(range, text, insertsAutoWhitespace = false) {
|
|
26
|
-
this._range = range;
|
|
27
|
-
this._text = text;
|
|
28
|
-
this.insertsAutoWhitespace = insertsAutoWhitespace;
|
|
29
|
-
}
|
|
30
|
-
getEditOperations(model, builder) {
|
|
31
|
-
const intialStartPosition = this._range.getStartPosition();
|
|
32
|
-
const initialEndPosition = this._range.getEndPosition();
|
|
33
|
-
const initialEndLineNumber = initialEndPosition.lineNumber;
|
|
34
|
-
const offsetDelta = this._text.length + (this._range.isEmpty() ? 0 : -1);
|
|
35
|
-
let endPosition = addPositiveOffsetToModelPosition(model, initialEndPosition, offsetDelta);
|
|
36
|
-
if (endPosition.lineNumber > initialEndLineNumber) {
|
|
37
|
-
endPosition = new Position(initialEndLineNumber, model.getLineMaxColumn(initialEndLineNumber));
|
|
38
|
-
}
|
|
39
|
-
const replaceRange = Range.fromPositions(intialStartPosition, endPosition);
|
|
40
|
-
builder.addTrackedEditOperation(replaceRange, this._text);
|
|
41
|
-
}
|
|
42
|
-
computeCursorState(model, helper) {
|
|
43
|
-
const inverseEditOperations = helper.getInverseEditOperations();
|
|
44
|
-
const srcRange = inverseEditOperations[0].range;
|
|
45
|
-
return Selection.fromPositions(srcRange.getEndPosition());
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
class ReplaceCommandThatSelectsText {
|
|
49
|
-
constructor(range, text) {
|
|
50
|
-
this._range = range;
|
|
51
|
-
this._text = text;
|
|
52
|
-
}
|
|
53
|
-
getEditOperations(model, builder) {
|
|
54
|
-
builder.addTrackedEditOperation(this._range, this._text);
|
|
55
|
-
}
|
|
56
|
-
computeCursorState(model, helper) {
|
|
57
|
-
const inverseEditOperations = helper.getInverseEditOperations();
|
|
58
|
-
const srcRange = inverseEditOperations[0].range;
|
|
59
|
-
return Selection.fromRange(srcRange, 0 /* SelectionDirection.LTR */);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
class ReplaceCommandWithoutChangingPosition {
|
|
63
|
-
constructor(range, text, insertsAutoWhitespace = false) {
|
|
64
|
-
this._range = range;
|
|
65
|
-
this._text = text;
|
|
66
|
-
this.insertsAutoWhitespace = insertsAutoWhitespace;
|
|
67
|
-
}
|
|
68
|
-
getEditOperations(model, builder) {
|
|
69
|
-
builder.addTrackedEditOperation(this._range, this._text);
|
|
70
|
-
}
|
|
71
|
-
computeCursorState(model, helper) {
|
|
72
|
-
const inverseEditOperations = helper.getInverseEditOperations();
|
|
73
|
-
const srcRange = inverseEditOperations[0].range;
|
|
74
|
-
return Selection.fromPositions(srcRange.getStartPosition());
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
class ReplaceCommandWithOffsetCursorState {
|
|
78
|
-
constructor(range, text, lineNumberDeltaOffset, columnDeltaOffset, insertsAutoWhitespace = false) {
|
|
79
|
-
this._range = range;
|
|
80
|
-
this._text = text;
|
|
81
|
-
this._columnDeltaOffset = columnDeltaOffset;
|
|
82
|
-
this._lineNumberDeltaOffset = lineNumberDeltaOffset;
|
|
83
|
-
this.insertsAutoWhitespace = insertsAutoWhitespace;
|
|
84
|
-
}
|
|
85
|
-
getEditOperations(model, builder) {
|
|
86
|
-
builder.addTrackedEditOperation(this._range, this._text);
|
|
87
|
-
}
|
|
88
|
-
computeCursorState(model, helper) {
|
|
89
|
-
const inverseEditOperations = helper.getInverseEditOperations();
|
|
90
|
-
const srcRange = inverseEditOperations[0].range;
|
|
91
|
-
return Selection.fromPositions(srcRange.getEndPosition().delta(this._lineNumberDeltaOffset, this._columnDeltaOffset));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
class ReplaceOvertypeCommandOnCompositionEnd {
|
|
95
|
-
constructor(range) {
|
|
96
|
-
this._range = range;
|
|
97
|
-
}
|
|
98
|
-
getEditOperations(model, builder) {
|
|
99
|
-
const text = model.getValueInRange(this._range);
|
|
100
|
-
const initialEndPosition = this._range.getEndPosition();
|
|
101
|
-
const initialEndLineNumber = initialEndPosition.lineNumber;
|
|
102
|
-
let endPosition = addPositiveOffsetToModelPosition(model, initialEndPosition, text.length);
|
|
103
|
-
if (endPosition.lineNumber > initialEndLineNumber) {
|
|
104
|
-
endPosition = new Position(initialEndLineNumber, model.getLineMaxColumn(initialEndLineNumber));
|
|
105
|
-
}
|
|
106
|
-
const replaceRange = Range.fromPositions(initialEndPosition, endPosition);
|
|
107
|
-
builder.addTrackedEditOperation(replaceRange, '');
|
|
108
|
-
}
|
|
109
|
-
computeCursorState(model, helper) {
|
|
110
|
-
const inverseEditOperations = helper.getInverseEditOperations();
|
|
111
|
-
const srcRange = inverseEditOperations[0].range;
|
|
112
|
-
return Selection.fromPositions(srcRange.getEndPosition());
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
class ReplaceCommandThatPreservesSelection {
|
|
116
|
-
constructor(editRange, text, initialSelection, forceMoveMarkers = false) {
|
|
117
|
-
this._range = editRange;
|
|
118
|
-
this._text = text;
|
|
119
|
-
this._initialSelection = initialSelection;
|
|
120
|
-
this._forceMoveMarkers = forceMoveMarkers;
|
|
121
|
-
this._selectionId = null;
|
|
122
|
-
}
|
|
123
|
-
getEditOperations(model, builder) {
|
|
124
|
-
builder.addTrackedEditOperation(this._range, this._text, this._forceMoveMarkers);
|
|
125
|
-
this._selectionId = builder.trackSelection(this._initialSelection);
|
|
126
|
-
}
|
|
127
|
-
computeCursorState(model, helper) {
|
|
128
|
-
return helper.getTrackedSelection(this._selectionId);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function addPositiveOffsetToModelPosition(model, position, offset) {
|
|
132
|
-
if (offset < 0) {
|
|
133
|
-
throw new Error('Unexpected negative delta');
|
|
134
|
-
}
|
|
135
|
-
const lineCount = model.getLineCount();
|
|
136
|
-
let endPosition = new Position(lineCount, model.getLineMaxColumn(lineCount));
|
|
137
|
-
for (let lineNumber = position.lineNumber; lineNumber <= lineCount; lineNumber++) {
|
|
138
|
-
if (lineNumber === position.lineNumber) {
|
|
139
|
-
const futureOffset = offset - model.getLineMaxColumn(position.lineNumber) + position.column;
|
|
140
|
-
if (futureOffset <= 0) {
|
|
141
|
-
endPosition = new Position(position.lineNumber, position.column + offset);
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
offset = futureOffset;
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
const futureOffset = offset - model.getLineMaxColumn(lineNumber);
|
|
148
|
-
if (futureOffset <= 0) {
|
|
149
|
-
endPosition = new Position(lineNumber, offset);
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
offset = futureOffset;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return endPosition;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export { ReplaceCommand, ReplaceCommandThatPreservesSelection, ReplaceCommandThatSelectsText, ReplaceCommandWithOffsetCursorState, ReplaceCommandWithoutChangingPosition, ReplaceOvertypeCommand, ReplaceOvertypeCommandOnCompositionEnd };
|