monaco-editor11 1.0.7 → 1.0.9

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.
Files changed (237) hide show
  1. package/dist/assets/css.worker-C7FogG4G.js +93 -0
  2. package/dist/assets/editor.worker-iXcRX1Tq.js +26 -0
  3. package/dist/assets/html.worker-C8VxctEJ.js +470 -0
  4. package/dist/assets/json.worker-CMC9kgPL.js +58 -0
  5. package/dist/assets/ts.worker-CtTJ3hNN.js +67731 -0
  6. package/dist/index.d.ts +0 -6
  7. package/dist/monaco-editor11.es.js +49 -78
  8. package/dist/monaco-editor11.umd.js +1 -50
  9. package/dist/monaco.d.ts +8 -0
  10. package/dist/workers/common/initialize.js +16 -0
  11. package/dist/workers/common/workers.js +141 -0
  12. package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +128 -0
  13. package/dist/workers/editor/common/abstractText.js +89 -0
  14. package/dist/workers/editor/common/ast.js +485 -0
  15. package/dist/workers/editor/common/autoIndent.js +390 -0
  16. package/dist/workers/editor/common/beforeEditPositionMapper.js +110 -0
  17. package/dist/workers/editor/common/bracketPairsImpl.js +717 -0
  18. package/dist/workers/editor/common/bracketPairsTree.js +343 -0
  19. package/dist/workers/editor/common/brackets.js +108 -0
  20. package/dist/workers/editor/common/characterClassifier.js +59 -0
  21. package/dist/workers/editor/common/characterPair.js +40 -0
  22. package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +97 -0
  23. package/dist/workers/editor/common/columnRange.js +35 -0
  24. package/dist/workers/editor/common/combineTextEditInfos.js +124 -0
  25. package/dist/workers/editor/common/common.js +20 -0
  26. package/dist/workers/editor/common/computeMovedLines.js +249 -0
  27. package/dist/workers/editor/common/concat23Trees.js +192 -0
  28. package/dist/workers/editor/common/contiguousMultilineTokens.js +32 -0
  29. package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +23 -0
  30. package/dist/workers/editor/common/contiguousTokensEditing.js +128 -0
  31. package/dist/workers/editor/common/contiguousTokensStore.js +207 -0
  32. package/dist/workers/editor/common/coordinatesConverter.js +51 -0
  33. package/dist/workers/editor/common/cursor.js +899 -0
  34. package/dist/workers/editor/common/cursorAtomicMoveOperations.js +145 -0
  35. package/dist/workers/editor/common/cursorCollection.js +194 -0
  36. package/dist/workers/editor/common/cursorColumnSelection.js +93 -0
  37. package/dist/workers/editor/common/cursorColumns.js +112 -0
  38. package/dist/workers/editor/common/cursorCommon.js +250 -0
  39. package/dist/workers/editor/common/cursorContext.js +15 -0
  40. package/dist/workers/editor/common/cursorDeleteOperations.js +231 -0
  41. package/dist/workers/editor/common/cursorMoveCommands.js +676 -0
  42. package/dist/workers/editor/common/cursorMoveOperations.js +290 -0
  43. package/dist/workers/editor/common/cursorTypeEditOperations.js +968 -0
  44. package/dist/workers/editor/common/cursorTypeOperations.js +173 -0
  45. package/dist/workers/editor/common/cursorUtils.js +75 -0
  46. package/dist/workers/editor/common/cursorWordOperations.js +720 -0
  47. package/dist/workers/editor/common/defaultDocumentColorsComputer.js +138 -0
  48. package/dist/workers/editor/common/defaultLinesDiffComputer.js +188 -0
  49. package/dist/workers/editor/common/diffAlgorithm.js +139 -0
  50. package/dist/workers/editor/common/diffEditor.js +38 -0
  51. package/dist/workers/editor/common/dynamicProgrammingDiffing.js +101 -0
  52. package/dist/workers/editor/common/edit.js +183 -0
  53. package/dist/workers/editor/common/editOperation.js +36 -0
  54. package/dist/workers/editor/common/editStack.js +363 -0
  55. package/dist/workers/editor/common/editorAction.js +26 -0
  56. package/dist/workers/editor/common/editorBaseApi.js +43 -0
  57. package/dist/workers/editor/common/editorColorRegistry.js +102 -0
  58. package/dist/workers/editor/common/editorCommon.js +13 -0
  59. package/dist/workers/editor/common/editorConfigurationSchema.js +338 -0
  60. package/dist/workers/editor/common/editorContextKeys.js +84 -0
  61. package/dist/workers/editor/common/editorFeatures.js +17 -0
  62. package/dist/workers/editor/common/editorOptions.js +3440 -0
  63. package/dist/workers/editor/common/editorTheme.js +23 -0
  64. package/dist/workers/editor/common/editorWebWorker.js +299 -0
  65. package/dist/workers/editor/common/editorWorker.js +9 -0
  66. package/dist/workers/editor/common/editorWorkerHost.js +15 -0
  67. package/dist/workers/editor/common/editorZoom.js +26 -0
  68. package/dist/workers/editor/common/electricCharacter.js +55 -0
  69. package/dist/workers/editor/common/encodedTokenAttributes.js +79 -0
  70. package/dist/workers/editor/common/enterAction.js +53 -0
  71. package/dist/workers/editor/common/eolCounter.js +44 -0
  72. package/dist/workers/editor/common/findSectionHeaders.js +128 -0
  73. package/dist/workers/editor/common/fixBrackets.js +67 -0
  74. package/dist/workers/editor/common/fixedArray.js +70 -0
  75. package/dist/workers/editor/common/fontInfo.js +172 -0
  76. package/dist/workers/editor/common/fontInfoFromSettings.js +29 -0
  77. package/dist/workers/editor/common/getIconClasses.js +106 -0
  78. package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +24 -0
  79. package/dist/workers/editor/common/glyphLanesModel.js +61 -0
  80. package/dist/workers/editor/common/guidesTextModelPart.js +405 -0
  81. package/dist/workers/editor/common/heuristicSequenceOptimizations.js +374 -0
  82. package/dist/workers/editor/common/indentRules.js +63 -0
  83. package/dist/workers/editor/common/indentation.js +39 -0
  84. package/dist/workers/editor/common/indentationGuesser.js +178 -0
  85. package/dist/workers/editor/common/indentationLineProcessor.js +193 -0
  86. package/dist/workers/editor/common/inlineDecorations.js +26 -0
  87. package/dist/workers/editor/common/inplaceReplaceSupport.js +87 -0
  88. package/dist/workers/editor/common/inputMode.js +22 -0
  89. package/dist/workers/editor/common/intervalTree.js +1002 -0
  90. package/dist/workers/editor/common/language.js +9 -0
  91. package/dist/workers/editor/common/languageBracketsConfiguration.js +133 -0
  92. package/dist/workers/editor/common/languageConfiguration.js +138 -0
  93. package/dist/workers/editor/common/languageConfigurationRegistry.js +361 -0
  94. package/dist/workers/editor/common/languageFeatureDebounce.js +137 -0
  95. package/dist/workers/editor/common/languageFeatureRegistry.js +180 -0
  96. package/dist/workers/editor/common/languageFeatures.js +9 -0
  97. package/dist/workers/editor/common/languageFeaturesService.js +47 -0
  98. package/dist/workers/editor/common/languageSelector.js +112 -0
  99. package/dist/workers/editor/common/languageService.js +92 -0
  100. package/dist/workers/editor/common/languages.js +522 -0
  101. package/dist/workers/editor/common/languagesAssociations.js +193 -0
  102. package/dist/workers/editor/common/languagesRegistry.js +237 -0
  103. package/dist/workers/editor/common/legacyLinesDiffComputer.js +468 -0
  104. package/dist/workers/editor/common/length.js +129 -0
  105. package/dist/workers/editor/common/lineDecorations.js +208 -0
  106. package/dist/workers/editor/common/lineEdit.js +75 -0
  107. package/dist/workers/editor/common/lineHeights.js +370 -0
  108. package/dist/workers/editor/common/linePart.js +25 -0
  109. package/dist/workers/editor/common/lineRange.js +312 -0
  110. package/dist/workers/editor/common/lineSequence.js +36 -0
  111. package/dist/workers/editor/common/lineTokens.js +405 -0
  112. package/dist/workers/editor/common/linesDiffComputer.js +29 -0
  113. package/dist/workers/editor/common/linesDiffComputers.js +13 -0
  114. package/dist/workers/editor/common/linesLayout.js +765 -0
  115. package/dist/workers/editor/common/linesSliceCharSequence.js +205 -0
  116. package/dist/workers/editor/common/linkComputer.js +269 -0
  117. package/dist/workers/editor/common/markerDecorations.js +9 -0
  118. package/dist/workers/editor/common/markerDecorationsService.js +248 -0
  119. package/dist/workers/editor/common/minimapTokensColorTracker.js +58 -0
  120. package/dist/workers/editor/common/mirrorTextModel.js +117 -0
  121. package/dist/workers/editor/common/model.js +9 -0
  122. package/dist/workers/editor/common/modelLineProjection.js +350 -0
  123. package/dist/workers/editor/common/modelLineProjectionData.js +297 -0
  124. package/dist/workers/editor/common/modelService.js +413 -0
  125. package/dist/workers/editor/common/modesRegistry.js +75 -0
  126. package/dist/workers/editor/common/monospaceLineBreaksComputer.js +473 -0
  127. package/dist/workers/editor/common/myersDiffAlgorithm.js +159 -0
  128. package/dist/workers/editor/common/nodeReader.js +127 -0
  129. package/dist/workers/editor/common/nullTokenize.js +29 -0
  130. package/dist/workers/editor/common/offsetRange.js +225 -0
  131. package/dist/workers/editor/common/onEnter.js +109 -0
  132. package/dist/workers/editor/common/oneCursor.js +117 -0
  133. package/dist/workers/editor/common/overviewZoneManager.js +176 -0
  134. package/dist/workers/editor/common/parser.js +121 -0
  135. package/dist/workers/editor/common/pieceTreeBase.js +1473 -0
  136. package/dist/workers/editor/common/pieceTreeTextBuffer.js +461 -0
  137. package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +140 -0
  138. package/dist/workers/editor/common/point.js +50 -0
  139. package/dist/workers/editor/common/position.js +142 -0
  140. package/dist/workers/editor/common/positionToOffset.js +17 -0
  141. package/dist/workers/editor/common/positionToOffsetImpl.js +98 -0
  142. package/dist/workers/editor/common/prefixSumComputer.js +226 -0
  143. package/dist/workers/editor/common/range.js +421 -0
  144. package/dist/workers/editor/common/rangeMapping.js +229 -0
  145. package/dist/workers/editor/common/rangeSingleLine.js +17 -0
  146. package/dist/workers/editor/common/rbTreeBase.js +362 -0
  147. package/dist/workers/editor/common/rect.js +163 -0
  148. package/dist/workers/editor/common/replaceCommand.js +158 -0
  149. package/dist/workers/editor/common/resolverService.js +5 -0
  150. package/dist/workers/editor/common/rgba.js +35 -0
  151. package/dist/workers/editor/common/richEditBrackets.js +356 -0
  152. package/dist/workers/editor/common/selection.js +145 -0
  153. package/dist/workers/editor/common/semanticTokensDto.js +82 -0
  154. package/dist/workers/editor/common/semanticTokensProviderStyling.js +263 -0
  155. package/dist/workers/editor/common/semanticTokensStyling.js +9 -0
  156. package/dist/workers/editor/common/semanticTokensStylingService.js +47 -0
  157. package/dist/workers/editor/common/shiftCommand.js +241 -0
  158. package/dist/workers/editor/common/smallImmutableSet.js +108 -0
  159. package/dist/workers/editor/common/sparseMultilineTokens.js +548 -0
  160. package/dist/workers/editor/common/sparseTokensStore.js +210 -0
  161. package/dist/workers/editor/common/standaloneEnums.js +1017 -0
  162. package/dist/workers/editor/common/standaloneStrings.js +42 -0
  163. package/dist/workers/editor/common/stringBuilder.js +122 -0
  164. package/dist/workers/editor/common/stringEdit.js +165 -0
  165. package/dist/workers/editor/common/supports.js +58 -0
  166. package/dist/workers/editor/common/surroundSelectionCommand.js +44 -0
  167. package/dist/workers/editor/common/textChange.js +248 -0
  168. package/dist/workers/editor/common/textEdit.js +269 -0
  169. package/dist/workers/editor/common/textLength.js +87 -0
  170. package/dist/workers/editor/common/textModel.js +2031 -0
  171. package/dist/workers/editor/common/textModelBracketPairs.js +45 -0
  172. package/dist/workers/editor/common/textModelDefaults.js +18 -0
  173. package/dist/workers/editor/common/textModelEditSource.js +166 -0
  174. package/dist/workers/editor/common/textModelEvents.js +216 -0
  175. package/dist/workers/editor/common/textModelGuides.js +40 -0
  176. package/dist/workers/editor/common/textModelPart.js +23 -0
  177. package/dist/workers/editor/common/textModelSearch.js +455 -0
  178. package/dist/workers/editor/common/textModelStringEdit.js +11 -0
  179. package/dist/workers/editor/common/textModelSync.impl.js +307 -0
  180. package/dist/workers/editor/common/textModelText.js +26 -0
  181. package/dist/workers/editor/common/textModelTokens.js +436 -0
  182. package/dist/workers/editor/common/textResourceConfiguration.js +6 -0
  183. package/dist/workers/editor/common/textToHtmlTokenizer.js +139 -0
  184. package/dist/workers/editor/common/tokenStore.js +407 -0
  185. package/dist/workers/editor/common/tokenWithTextArray.js +73 -0
  186. package/dist/workers/editor/common/tokenization.js +287 -0
  187. package/dist/workers/editor/common/tokenizationRegistry.js +123 -0
  188. package/dist/workers/editor/common/tokenizationTextModelPart.js +275 -0
  189. package/dist/workers/editor/common/tokenizer.js +301 -0
  190. package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +261 -0
  191. package/dist/workers/editor/common/treeSitterLibraryService.js +9 -0
  192. package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +167 -0
  193. package/dist/workers/editor/common/treeSitterThemeService.js +9 -0
  194. package/dist/workers/editor/common/treeSitterTokenizationImpl.js +713 -0
  195. package/dist/workers/editor/common/treeSitterTree.js +395 -0
  196. package/dist/workers/editor/common/treeViewsDnd.js +24 -0
  197. package/dist/workers/editor/common/treeViewsDndService.js +12 -0
  198. package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +98 -0
  199. package/dist/workers/editor/common/unicodeTextModelHighlighter.js +188 -0
  200. package/dist/workers/editor/common/utils.js +62 -0
  201. package/dist/workers/editor/common/viewContext.js +22 -0
  202. package/dist/workers/editor/common/viewEventHandler.js +186 -0
  203. package/dist/workers/editor/common/viewEvents.js +180 -0
  204. package/dist/workers/editor/common/viewLayout.js +368 -0
  205. package/dist/workers/editor/common/viewLineRenderer.js +948 -0
  206. package/dist/workers/editor/common/viewLinesViewportData.js +30 -0
  207. package/dist/workers/editor/common/viewModel.js +98 -0
  208. package/dist/workers/editor/common/viewModelDecoration.js +55 -0
  209. package/dist/workers/editor/common/viewModelDecorations.js +132 -0
  210. package/dist/workers/editor/common/viewModelEventDispatcher.js +398 -0
  211. package/dist/workers/editor/common/viewModelImpl.js +1163 -0
  212. package/dist/workers/editor/common/viewModelLines.js +938 -0
  213. package/dist/workers/editor/common/wordCharacterClassifier.js +87 -0
  214. package/dist/workers/editor/common/wordHelper.js +127 -0
  215. package/dist/workers/editor/editor.worker.js +11 -0
  216. package/dist/workers/language/css.worker.js +8 -0
  217. package/dist/workers/language/cssMode.js +198 -0
  218. package/dist/workers/language/cssWorker.js +183 -0
  219. package/dist/workers/language/html.worker.js +8 -0
  220. package/dist/workers/language/htmlMode.js +213 -0
  221. package/dist/workers/language/htmlWorker.js +126 -0
  222. package/dist/workers/language/json.worker.js +8 -0
  223. package/dist/workers/language/jsonMode.js +224 -0
  224. package/dist/workers/language/jsonWorker.js +187 -0
  225. package/dist/workers/language/languageFeatures.js +1009 -0
  226. package/dist/workers/language/lib.index.js +103 -0
  227. package/dist/workers/language/lib.js +1107 -0
  228. package/dist/workers/language/lspLanguageFeatures.js +716 -0
  229. package/dist/workers/language/monaco.contribution.js +144 -0
  230. package/dist/workers/language/tokenization.js +189 -0
  231. package/dist/workers/language/ts.worker.js +14 -0
  232. package/dist/workers/language/tsMode.js +212 -0
  233. package/dist/workers/language/tsWorker.js +352 -0
  234. package/dist/workers/language/typescriptServices.js +210154 -0
  235. package/dist/workers/language/typescriptServicesMetadata.js +3 -0
  236. package/dist/workers/language/workerManager.js +65 -0
  237. package/package.json +3 -2
@@ -0,0 +1,362 @@
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 };
@@ -0,0 +1,163 @@
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 };
@@ -0,0 +1,158 @@
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 };
@@ -0,0 +1,5 @@
1
+ import { createDecorator } from '../../../platform/instantiation/common/instantiation.js';
2
+
3
+ const ITextModelService = createDecorator('textModelService');
4
+
5
+ export { ITextModelService };