monaco-editor11 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/monaco-editor11.es.js +11 -16
  3. package/dist/monaco-editor11.umd.js +1 -1
  4. package/package.json +2 -2
  5. package/dist/monaco.d.ts +0 -8
  6. package/dist/workers/common/initialize.js +0 -16
  7. package/dist/workers/common/workers.js +0 -141
  8. package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +0 -128
  9. package/dist/workers/editor/common/abstractText.js +0 -89
  10. package/dist/workers/editor/common/ast.js +0 -485
  11. package/dist/workers/editor/common/autoIndent.js +0 -390
  12. package/dist/workers/editor/common/beforeEditPositionMapper.js +0 -110
  13. package/dist/workers/editor/common/bracketPairsImpl.js +0 -717
  14. package/dist/workers/editor/common/bracketPairsTree.js +0 -343
  15. package/dist/workers/editor/common/brackets.js +0 -108
  16. package/dist/workers/editor/common/characterClassifier.js +0 -59
  17. package/dist/workers/editor/common/characterPair.js +0 -40
  18. package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +0 -97
  19. package/dist/workers/editor/common/columnRange.js +0 -35
  20. package/dist/workers/editor/common/combineTextEditInfos.js +0 -124
  21. package/dist/workers/editor/common/common.js +0 -20
  22. package/dist/workers/editor/common/computeMovedLines.js +0 -249
  23. package/dist/workers/editor/common/concat23Trees.js +0 -192
  24. package/dist/workers/editor/common/contiguousMultilineTokens.js +0 -32
  25. package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +0 -23
  26. package/dist/workers/editor/common/contiguousTokensEditing.js +0 -128
  27. package/dist/workers/editor/common/contiguousTokensStore.js +0 -207
  28. package/dist/workers/editor/common/coordinatesConverter.js +0 -51
  29. package/dist/workers/editor/common/cursor.js +0 -899
  30. package/dist/workers/editor/common/cursorAtomicMoveOperations.js +0 -145
  31. package/dist/workers/editor/common/cursorCollection.js +0 -194
  32. package/dist/workers/editor/common/cursorColumnSelection.js +0 -93
  33. package/dist/workers/editor/common/cursorColumns.js +0 -112
  34. package/dist/workers/editor/common/cursorCommon.js +0 -250
  35. package/dist/workers/editor/common/cursorContext.js +0 -15
  36. package/dist/workers/editor/common/cursorDeleteOperations.js +0 -231
  37. package/dist/workers/editor/common/cursorMoveCommands.js +0 -676
  38. package/dist/workers/editor/common/cursorMoveOperations.js +0 -290
  39. package/dist/workers/editor/common/cursorTypeEditOperations.js +0 -968
  40. package/dist/workers/editor/common/cursorTypeOperations.js +0 -173
  41. package/dist/workers/editor/common/cursorUtils.js +0 -75
  42. package/dist/workers/editor/common/cursorWordOperations.js +0 -720
  43. package/dist/workers/editor/common/defaultDocumentColorsComputer.js +0 -138
  44. package/dist/workers/editor/common/defaultLinesDiffComputer.js +0 -188
  45. package/dist/workers/editor/common/diffAlgorithm.js +0 -139
  46. package/dist/workers/editor/common/diffEditor.js +0 -38
  47. package/dist/workers/editor/common/dynamicProgrammingDiffing.js +0 -101
  48. package/dist/workers/editor/common/edit.js +0 -183
  49. package/dist/workers/editor/common/editOperation.js +0 -36
  50. package/dist/workers/editor/common/editStack.js +0 -363
  51. package/dist/workers/editor/common/editorAction.js +0 -26
  52. package/dist/workers/editor/common/editorBaseApi.js +0 -43
  53. package/dist/workers/editor/common/editorColorRegistry.js +0 -102
  54. package/dist/workers/editor/common/editorCommon.js +0 -13
  55. package/dist/workers/editor/common/editorConfigurationSchema.js +0 -338
  56. package/dist/workers/editor/common/editorContextKeys.js +0 -84
  57. package/dist/workers/editor/common/editorFeatures.js +0 -17
  58. package/dist/workers/editor/common/editorOptions.js +0 -3440
  59. package/dist/workers/editor/common/editorTheme.js +0 -23
  60. package/dist/workers/editor/common/editorWebWorker.js +0 -299
  61. package/dist/workers/editor/common/editorWorker.js +0 -9
  62. package/dist/workers/editor/common/editorWorkerHost.js +0 -15
  63. package/dist/workers/editor/common/editorZoom.js +0 -26
  64. package/dist/workers/editor/common/electricCharacter.js +0 -55
  65. package/dist/workers/editor/common/encodedTokenAttributes.js +0 -79
  66. package/dist/workers/editor/common/enterAction.js +0 -53
  67. package/dist/workers/editor/common/eolCounter.js +0 -44
  68. package/dist/workers/editor/common/findSectionHeaders.js +0 -128
  69. package/dist/workers/editor/common/fixBrackets.js +0 -67
  70. package/dist/workers/editor/common/fixedArray.js +0 -70
  71. package/dist/workers/editor/common/fontInfo.js +0 -172
  72. package/dist/workers/editor/common/fontInfoFromSettings.js +0 -29
  73. package/dist/workers/editor/common/getIconClasses.js +0 -106
  74. package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +0 -24
  75. package/dist/workers/editor/common/glyphLanesModel.js +0 -61
  76. package/dist/workers/editor/common/guidesTextModelPart.js +0 -405
  77. package/dist/workers/editor/common/heuristicSequenceOptimizations.js +0 -374
  78. package/dist/workers/editor/common/indentRules.js +0 -63
  79. package/dist/workers/editor/common/indentation.js +0 -39
  80. package/dist/workers/editor/common/indentationGuesser.js +0 -178
  81. package/dist/workers/editor/common/indentationLineProcessor.js +0 -193
  82. package/dist/workers/editor/common/inlineDecorations.js +0 -26
  83. package/dist/workers/editor/common/inplaceReplaceSupport.js +0 -87
  84. package/dist/workers/editor/common/inputMode.js +0 -22
  85. package/dist/workers/editor/common/intervalTree.js +0 -1002
  86. package/dist/workers/editor/common/language.js +0 -9
  87. package/dist/workers/editor/common/languageBracketsConfiguration.js +0 -133
  88. package/dist/workers/editor/common/languageConfiguration.js +0 -138
  89. package/dist/workers/editor/common/languageConfigurationRegistry.js +0 -361
  90. package/dist/workers/editor/common/languageFeatureDebounce.js +0 -137
  91. package/dist/workers/editor/common/languageFeatureRegistry.js +0 -180
  92. package/dist/workers/editor/common/languageFeatures.js +0 -9
  93. package/dist/workers/editor/common/languageFeaturesService.js +0 -47
  94. package/dist/workers/editor/common/languageSelector.js +0 -112
  95. package/dist/workers/editor/common/languageService.js +0 -92
  96. package/dist/workers/editor/common/languages.js +0 -522
  97. package/dist/workers/editor/common/languagesAssociations.js +0 -193
  98. package/dist/workers/editor/common/languagesRegistry.js +0 -237
  99. package/dist/workers/editor/common/legacyLinesDiffComputer.js +0 -468
  100. package/dist/workers/editor/common/length.js +0 -129
  101. package/dist/workers/editor/common/lineDecorations.js +0 -208
  102. package/dist/workers/editor/common/lineEdit.js +0 -75
  103. package/dist/workers/editor/common/lineHeights.js +0 -370
  104. package/dist/workers/editor/common/linePart.js +0 -25
  105. package/dist/workers/editor/common/lineRange.js +0 -312
  106. package/dist/workers/editor/common/lineSequence.js +0 -36
  107. package/dist/workers/editor/common/lineTokens.js +0 -405
  108. package/dist/workers/editor/common/linesDiffComputer.js +0 -29
  109. package/dist/workers/editor/common/linesDiffComputers.js +0 -13
  110. package/dist/workers/editor/common/linesLayout.js +0 -765
  111. package/dist/workers/editor/common/linesSliceCharSequence.js +0 -205
  112. package/dist/workers/editor/common/linkComputer.js +0 -269
  113. package/dist/workers/editor/common/markerDecorations.js +0 -9
  114. package/dist/workers/editor/common/markerDecorationsService.js +0 -248
  115. package/dist/workers/editor/common/minimapTokensColorTracker.js +0 -58
  116. package/dist/workers/editor/common/mirrorTextModel.js +0 -117
  117. package/dist/workers/editor/common/model.js +0 -9
  118. package/dist/workers/editor/common/modelLineProjection.js +0 -350
  119. package/dist/workers/editor/common/modelLineProjectionData.js +0 -297
  120. package/dist/workers/editor/common/modelService.js +0 -413
  121. package/dist/workers/editor/common/modesRegistry.js +0 -75
  122. package/dist/workers/editor/common/monospaceLineBreaksComputer.js +0 -473
  123. package/dist/workers/editor/common/myersDiffAlgorithm.js +0 -159
  124. package/dist/workers/editor/common/nodeReader.js +0 -127
  125. package/dist/workers/editor/common/nullTokenize.js +0 -29
  126. package/dist/workers/editor/common/offsetRange.js +0 -225
  127. package/dist/workers/editor/common/onEnter.js +0 -109
  128. package/dist/workers/editor/common/oneCursor.js +0 -117
  129. package/dist/workers/editor/common/overviewZoneManager.js +0 -176
  130. package/dist/workers/editor/common/parser.js +0 -121
  131. package/dist/workers/editor/common/pieceTreeBase.js +0 -1473
  132. package/dist/workers/editor/common/pieceTreeTextBuffer.js +0 -461
  133. package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +0 -140
  134. package/dist/workers/editor/common/point.js +0 -50
  135. package/dist/workers/editor/common/position.js +0 -142
  136. package/dist/workers/editor/common/positionToOffset.js +0 -17
  137. package/dist/workers/editor/common/positionToOffsetImpl.js +0 -98
  138. package/dist/workers/editor/common/prefixSumComputer.js +0 -226
  139. package/dist/workers/editor/common/range.js +0 -421
  140. package/dist/workers/editor/common/rangeMapping.js +0 -229
  141. package/dist/workers/editor/common/rangeSingleLine.js +0 -17
  142. package/dist/workers/editor/common/rbTreeBase.js +0 -362
  143. package/dist/workers/editor/common/rect.js +0 -163
  144. package/dist/workers/editor/common/replaceCommand.js +0 -158
  145. package/dist/workers/editor/common/resolverService.js +0 -5
  146. package/dist/workers/editor/common/rgba.js +0 -35
  147. package/dist/workers/editor/common/richEditBrackets.js +0 -356
  148. package/dist/workers/editor/common/selection.js +0 -145
  149. package/dist/workers/editor/common/semanticTokensDto.js +0 -82
  150. package/dist/workers/editor/common/semanticTokensProviderStyling.js +0 -263
  151. package/dist/workers/editor/common/semanticTokensStyling.js +0 -9
  152. package/dist/workers/editor/common/semanticTokensStylingService.js +0 -47
  153. package/dist/workers/editor/common/shiftCommand.js +0 -241
  154. package/dist/workers/editor/common/smallImmutableSet.js +0 -108
  155. package/dist/workers/editor/common/sparseMultilineTokens.js +0 -548
  156. package/dist/workers/editor/common/sparseTokensStore.js +0 -210
  157. package/dist/workers/editor/common/standaloneEnums.js +0 -1017
  158. package/dist/workers/editor/common/standaloneStrings.js +0 -42
  159. package/dist/workers/editor/common/stringBuilder.js +0 -122
  160. package/dist/workers/editor/common/stringEdit.js +0 -165
  161. package/dist/workers/editor/common/supports.js +0 -58
  162. package/dist/workers/editor/common/surroundSelectionCommand.js +0 -44
  163. package/dist/workers/editor/common/textChange.js +0 -248
  164. package/dist/workers/editor/common/textEdit.js +0 -269
  165. package/dist/workers/editor/common/textLength.js +0 -87
  166. package/dist/workers/editor/common/textModel.js +0 -2031
  167. package/dist/workers/editor/common/textModelBracketPairs.js +0 -45
  168. package/dist/workers/editor/common/textModelDefaults.js +0 -18
  169. package/dist/workers/editor/common/textModelEditSource.js +0 -166
  170. package/dist/workers/editor/common/textModelEvents.js +0 -216
  171. package/dist/workers/editor/common/textModelGuides.js +0 -40
  172. package/dist/workers/editor/common/textModelPart.js +0 -23
  173. package/dist/workers/editor/common/textModelSearch.js +0 -455
  174. package/dist/workers/editor/common/textModelStringEdit.js +0 -11
  175. package/dist/workers/editor/common/textModelSync.impl.js +0 -307
  176. package/dist/workers/editor/common/textModelText.js +0 -26
  177. package/dist/workers/editor/common/textModelTokens.js +0 -436
  178. package/dist/workers/editor/common/textResourceConfiguration.js +0 -6
  179. package/dist/workers/editor/common/textToHtmlTokenizer.js +0 -139
  180. package/dist/workers/editor/common/tokenStore.js +0 -407
  181. package/dist/workers/editor/common/tokenWithTextArray.js +0 -73
  182. package/dist/workers/editor/common/tokenization.js +0 -287
  183. package/dist/workers/editor/common/tokenizationRegistry.js +0 -123
  184. package/dist/workers/editor/common/tokenizationTextModelPart.js +0 -275
  185. package/dist/workers/editor/common/tokenizer.js +0 -301
  186. package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +0 -261
  187. package/dist/workers/editor/common/treeSitterLibraryService.js +0 -9
  188. package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +0 -167
  189. package/dist/workers/editor/common/treeSitterThemeService.js +0 -9
  190. package/dist/workers/editor/common/treeSitterTokenizationImpl.js +0 -713
  191. package/dist/workers/editor/common/treeSitterTree.js +0 -395
  192. package/dist/workers/editor/common/treeViewsDnd.js +0 -24
  193. package/dist/workers/editor/common/treeViewsDndService.js +0 -12
  194. package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +0 -98
  195. package/dist/workers/editor/common/unicodeTextModelHighlighter.js +0 -188
  196. package/dist/workers/editor/common/utils.js +0 -62
  197. package/dist/workers/editor/common/viewContext.js +0 -22
  198. package/dist/workers/editor/common/viewEventHandler.js +0 -186
  199. package/dist/workers/editor/common/viewEvents.js +0 -180
  200. package/dist/workers/editor/common/viewLayout.js +0 -368
  201. package/dist/workers/editor/common/viewLineRenderer.js +0 -948
  202. package/dist/workers/editor/common/viewLinesViewportData.js +0 -30
  203. package/dist/workers/editor/common/viewModel.js +0 -98
  204. package/dist/workers/editor/common/viewModelDecoration.js +0 -55
  205. package/dist/workers/editor/common/viewModelDecorations.js +0 -132
  206. package/dist/workers/editor/common/viewModelEventDispatcher.js +0 -398
  207. package/dist/workers/editor/common/viewModelImpl.js +0 -1163
  208. package/dist/workers/editor/common/viewModelLines.js +0 -938
  209. package/dist/workers/editor/common/wordCharacterClassifier.js +0 -87
  210. package/dist/workers/editor/common/wordHelper.js +0 -127
  211. package/dist/workers/language/cssMode.js +0 -198
  212. package/dist/workers/language/cssWorker.js +0 -183
  213. package/dist/workers/language/htmlMode.js +0 -213
  214. package/dist/workers/language/htmlWorker.js +0 -126
  215. package/dist/workers/language/jsonMode.js +0 -224
  216. package/dist/workers/language/jsonWorker.js +0 -187
  217. package/dist/workers/language/languageFeatures.js +0 -1009
  218. package/dist/workers/language/lib.index.js +0 -103
  219. package/dist/workers/language/lib.js +0 -1107
  220. package/dist/workers/language/lspLanguageFeatures.js +0 -716
  221. package/dist/workers/language/monaco.contribution.js +0 -144
  222. package/dist/workers/language/tokenization.js +0 -189
  223. package/dist/workers/language/tsMode.js +0 -212
  224. package/dist/workers/language/tsWorker.js +0 -352
  225. package/dist/workers/language/typescriptServices.js +0 -210154
  226. package/dist/workers/language/typescriptServicesMetadata.js +0 -3
  227. package/dist/workers/language/workerManager.js +0 -65
  228. /package/dist/workers/{language/css.worker.js → css.worker.js} +0 -0
  229. /package/dist/workers/{editor/editor.worker.js → editor.worker.js} +0 -0
  230. /package/dist/workers/{language/html.worker.js → html.worker.js} +0 -0
  231. /package/dist/workers/{language/json.worker.js → json.worker.js} +0 -0
  232. /package/dist/workers/{language/ts.worker.js → ts.worker.js} +0 -0
@@ -1,548 +0,0 @@
1
- import { Position } from '../core/position.js';
2
- import { Range } from '../core/range.js';
3
- import { countEOL } from '../core/misc/eolCounter.js';
4
- import { RateLimiter } from './common.js';
5
-
6
- /*---------------------------------------------------------------------------------------------
7
- * Copyright (c) Microsoft Corporation. All rights reserved.
8
- * Licensed under the MIT License. See License.txt in the project root for license information.
9
- *--------------------------------------------------------------------------------------------*/
10
- /**
11
- * Represents sparse tokens over a contiguous range of lines.
12
- */
13
- class SparseMultilineTokens {
14
- static create(startLineNumber, tokens) {
15
- return new SparseMultilineTokens(startLineNumber, new SparseMultilineTokensStorage(tokens));
16
- }
17
- /**
18
- * (Inclusive) start line number for these tokens.
19
- */
20
- get startLineNumber() {
21
- return this._startLineNumber;
22
- }
23
- /**
24
- * (Inclusive) end line number for these tokens.
25
- */
26
- get endLineNumber() {
27
- return this._endLineNumber;
28
- }
29
- constructor(startLineNumber, tokens) {
30
- this._startLineNumber = startLineNumber;
31
- this._tokens = tokens;
32
- this._endLineNumber = this._startLineNumber + this._tokens.getMaxDeltaLine();
33
- }
34
- toString() {
35
- return this._tokens.toString(this._startLineNumber);
36
- }
37
- _updateEndLineNumber() {
38
- this._endLineNumber = this._startLineNumber + this._tokens.getMaxDeltaLine();
39
- }
40
- isEmpty() {
41
- return this._tokens.isEmpty();
42
- }
43
- getLineTokens(lineNumber) {
44
- if (this._startLineNumber <= lineNumber && lineNumber <= this._endLineNumber) {
45
- return this._tokens.getLineTokens(lineNumber - this._startLineNumber);
46
- }
47
- return null;
48
- }
49
- getRange() {
50
- const deltaRange = this._tokens.getRange();
51
- if (!deltaRange) {
52
- return deltaRange;
53
- }
54
- return new Range(this._startLineNumber + deltaRange.startLineNumber, deltaRange.startColumn, this._startLineNumber + deltaRange.endLineNumber, deltaRange.endColumn);
55
- }
56
- removeTokens(range) {
57
- const startLineIndex = range.startLineNumber - this._startLineNumber;
58
- const endLineIndex = range.endLineNumber - this._startLineNumber;
59
- this._startLineNumber += this._tokens.removeTokens(startLineIndex, range.startColumn - 1, endLineIndex, range.endColumn - 1);
60
- this._updateEndLineNumber();
61
- }
62
- split(range) {
63
- // split tokens to two:
64
- // a) all the tokens before `range`
65
- // b) all the tokens after `range`
66
- const startLineIndex = range.startLineNumber - this._startLineNumber;
67
- const endLineIndex = range.endLineNumber - this._startLineNumber;
68
- const [a, b, bDeltaLine] = this._tokens.split(startLineIndex, range.startColumn - 1, endLineIndex, range.endColumn - 1);
69
- return [new SparseMultilineTokens(this._startLineNumber, a), new SparseMultilineTokens(this._startLineNumber + bDeltaLine, b)];
70
- }
71
- applyEdit(range, text) {
72
- const [eolCount, firstLineLength, lastLineLength] = countEOL(text);
73
- this.acceptEdit(range, eolCount, firstLineLength, lastLineLength, text.length > 0 ? text.charCodeAt(0) : 0 /* CharCode.Null */);
74
- }
75
- acceptEdit(range, eolCount, firstLineLength, lastLineLength, firstCharCode) {
76
- this._acceptDeleteRange(range);
77
- this._acceptInsertText(new Position(range.startLineNumber, range.startColumn), eolCount, firstLineLength, lastLineLength, firstCharCode);
78
- this._updateEndLineNumber();
79
- }
80
- _acceptDeleteRange(range) {
81
- if (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn) {
82
- // Nothing to delete
83
- return;
84
- }
85
- const firstLineIndex = range.startLineNumber - this._startLineNumber;
86
- const lastLineIndex = range.endLineNumber - this._startLineNumber;
87
- if (lastLineIndex < 0) {
88
- // this deletion occurs entirely before this block, so we only need to adjust line numbers
89
- const deletedLinesCount = lastLineIndex - firstLineIndex;
90
- this._startLineNumber -= deletedLinesCount;
91
- return;
92
- }
93
- const tokenMaxDeltaLine = this._tokens.getMaxDeltaLine();
94
- if (firstLineIndex >= tokenMaxDeltaLine + 1) {
95
- // this deletion occurs entirely after this block, so there is nothing to do
96
- return;
97
- }
98
- if (firstLineIndex < 0 && lastLineIndex >= tokenMaxDeltaLine + 1) {
99
- // this deletion completely encompasses this block
100
- this._startLineNumber = 0;
101
- this._tokens.clear();
102
- return;
103
- }
104
- if (firstLineIndex < 0) {
105
- const deletedBefore = -firstLineIndex;
106
- this._startLineNumber -= deletedBefore;
107
- this._tokens.acceptDeleteRange(range.startColumn - 1, 0, 0, lastLineIndex, range.endColumn - 1);
108
- }
109
- else {
110
- this._tokens.acceptDeleteRange(0, firstLineIndex, range.startColumn - 1, lastLineIndex, range.endColumn - 1);
111
- }
112
- }
113
- _acceptInsertText(position, eolCount, firstLineLength, lastLineLength, firstCharCode) {
114
- if (eolCount === 0 && firstLineLength === 0) {
115
- // Nothing to insert
116
- return;
117
- }
118
- const lineIndex = position.lineNumber - this._startLineNumber;
119
- if (lineIndex < 0) {
120
- // this insertion occurs before this block, so we only need to adjust line numbers
121
- this._startLineNumber += eolCount;
122
- return;
123
- }
124
- const tokenMaxDeltaLine = this._tokens.getMaxDeltaLine();
125
- if (lineIndex >= tokenMaxDeltaLine + 1) {
126
- // this insertion occurs after this block, so there is nothing to do
127
- return;
128
- }
129
- this._tokens.acceptInsertText(lineIndex, position.column - 1, eolCount, firstLineLength, lastLineLength, firstCharCode);
130
- }
131
- reportIfInvalid(model) {
132
- this._tokens.reportIfInvalid(model, this._startLineNumber);
133
- }
134
- }
135
- class SparseMultilineTokensStorage {
136
- constructor(tokens) {
137
- this._tokens = tokens;
138
- this._tokenCount = tokens.length / 4;
139
- }
140
- toString(startLineNumber) {
141
- const pieces = [];
142
- for (let i = 0; i < this._tokenCount; i++) {
143
- pieces.push(`(${this._getDeltaLine(i) + startLineNumber},${this._getStartCharacter(i)}-${this._getEndCharacter(i)})`);
144
- }
145
- return `[${pieces.join(',')}]`;
146
- }
147
- getMaxDeltaLine() {
148
- const tokenCount = this._getTokenCount();
149
- if (tokenCount === 0) {
150
- return -1;
151
- }
152
- return this._getDeltaLine(tokenCount - 1);
153
- }
154
- getRange() {
155
- const tokenCount = this._getTokenCount();
156
- if (tokenCount === 0) {
157
- return null;
158
- }
159
- const startChar = this._getStartCharacter(0);
160
- const maxDeltaLine = this._getDeltaLine(tokenCount - 1);
161
- const endChar = this._getEndCharacter(tokenCount - 1);
162
- return new Range(0, startChar + 1, maxDeltaLine, endChar + 1);
163
- }
164
- _getTokenCount() {
165
- return this._tokenCount;
166
- }
167
- _getDeltaLine(tokenIndex) {
168
- return this._tokens[4 * tokenIndex];
169
- }
170
- _getStartCharacter(tokenIndex) {
171
- return this._tokens[4 * tokenIndex + 1];
172
- }
173
- _getEndCharacter(tokenIndex) {
174
- return this._tokens[4 * tokenIndex + 2];
175
- }
176
- isEmpty() {
177
- return (this._getTokenCount() === 0);
178
- }
179
- getLineTokens(deltaLine) {
180
- let low = 0;
181
- let high = this._getTokenCount() - 1;
182
- while (low < high) {
183
- const mid = low + Math.floor((high - low) / 2);
184
- const midDeltaLine = this._getDeltaLine(mid);
185
- if (midDeltaLine < deltaLine) {
186
- low = mid + 1;
187
- }
188
- else if (midDeltaLine > deltaLine) {
189
- high = mid - 1;
190
- }
191
- else {
192
- let min = mid;
193
- while (min > low && this._getDeltaLine(min - 1) === deltaLine) {
194
- min--;
195
- }
196
- let max = mid;
197
- while (max < high && this._getDeltaLine(max + 1) === deltaLine) {
198
- max++;
199
- }
200
- return new SparseLineTokens(this._tokens.subarray(4 * min, 4 * max + 4));
201
- }
202
- }
203
- if (this._getDeltaLine(low) === deltaLine) {
204
- return new SparseLineTokens(this._tokens.subarray(4 * low, 4 * low + 4));
205
- }
206
- return null;
207
- }
208
- clear() {
209
- this._tokenCount = 0;
210
- }
211
- removeTokens(startDeltaLine, startChar, endDeltaLine, endChar) {
212
- const tokens = this._tokens;
213
- const tokenCount = this._tokenCount;
214
- let newTokenCount = 0;
215
- let hasDeletedTokens = false;
216
- let firstDeltaLine = 0;
217
- for (let i = 0; i < tokenCount; i++) {
218
- const srcOffset = 4 * i;
219
- const tokenDeltaLine = tokens[srcOffset];
220
- const tokenStartCharacter = tokens[srcOffset + 1];
221
- const tokenEndCharacter = tokens[srcOffset + 2];
222
- const tokenMetadata = tokens[srcOffset + 3];
223
- if ((tokenDeltaLine > startDeltaLine || (tokenDeltaLine === startDeltaLine && tokenEndCharacter >= startChar))
224
- && (tokenDeltaLine < endDeltaLine || (tokenDeltaLine === endDeltaLine && tokenStartCharacter <= endChar))) {
225
- hasDeletedTokens = true;
226
- }
227
- else {
228
- if (newTokenCount === 0) {
229
- firstDeltaLine = tokenDeltaLine;
230
- }
231
- if (hasDeletedTokens) {
232
- // must move the token to the left
233
- const destOffset = 4 * newTokenCount;
234
- tokens[destOffset] = tokenDeltaLine - firstDeltaLine;
235
- tokens[destOffset + 1] = tokenStartCharacter;
236
- tokens[destOffset + 2] = tokenEndCharacter;
237
- tokens[destOffset + 3] = tokenMetadata;
238
- }
239
- else if (firstDeltaLine !== 0) {
240
- // must adjust the delta line in place
241
- tokens[srcOffset] = tokenDeltaLine - firstDeltaLine;
242
- }
243
- newTokenCount++;
244
- }
245
- }
246
- this._tokenCount = newTokenCount;
247
- return firstDeltaLine;
248
- }
249
- split(startDeltaLine, startChar, endDeltaLine, endChar) {
250
- const tokens = this._tokens;
251
- const tokenCount = this._tokenCount;
252
- const aTokens = [];
253
- const bTokens = [];
254
- let destTokens = aTokens;
255
- let destOffset = 0;
256
- let destFirstDeltaLine = 0;
257
- for (let i = 0; i < tokenCount; i++) {
258
- const srcOffset = 4 * i;
259
- const tokenDeltaLine = tokens[srcOffset];
260
- const tokenStartCharacter = tokens[srcOffset + 1];
261
- const tokenEndCharacter = tokens[srcOffset + 2];
262
- const tokenMetadata = tokens[srcOffset + 3];
263
- if ((tokenDeltaLine > startDeltaLine || (tokenDeltaLine === startDeltaLine && tokenEndCharacter >= startChar))) {
264
- if ((tokenDeltaLine < endDeltaLine || (tokenDeltaLine === endDeltaLine && tokenStartCharacter <= endChar))) {
265
- // this token is touching the range
266
- continue;
267
- }
268
- else {
269
- // this token is after the range
270
- if (destTokens !== bTokens) {
271
- // this token is the first token after the range
272
- destTokens = bTokens;
273
- destOffset = 0;
274
- destFirstDeltaLine = tokenDeltaLine;
275
- }
276
- }
277
- }
278
- destTokens[destOffset++] = tokenDeltaLine - destFirstDeltaLine;
279
- destTokens[destOffset++] = tokenStartCharacter;
280
- destTokens[destOffset++] = tokenEndCharacter;
281
- destTokens[destOffset++] = tokenMetadata;
282
- }
283
- return [new SparseMultilineTokensStorage(new Uint32Array(aTokens)), new SparseMultilineTokensStorage(new Uint32Array(bTokens)), destFirstDeltaLine];
284
- }
285
- acceptDeleteRange(horizontalShiftForFirstLineTokens, startDeltaLine, startCharacter, endDeltaLine, endCharacter) {
286
- // This is a bit complex, here are the cases I used to think about this:
287
- //
288
- // 1. The token starts before the deletion range
289
- // 1a. The token is completely before the deletion range
290
- // -----------
291
- // xxxxxxxxxxx
292
- // 1b. The token starts before, the deletion range ends after the token
293
- // -----------
294
- // xxxxxxxxxxx
295
- // 1c. The token starts before, the deletion range ends precisely with the token
296
- // ---------------
297
- // xxxxxxxx
298
- // 1d. The token starts before, the deletion range is inside the token
299
- // ---------------
300
- // xxxxx
301
- //
302
- // 2. The token starts at the same position with the deletion range
303
- // 2a. The token starts at the same position, and ends inside the deletion range
304
- // -------
305
- // xxxxxxxxxxx
306
- // 2b. The token starts at the same position, and ends at the same position as the deletion range
307
- // ----------
308
- // xxxxxxxxxx
309
- // 2c. The token starts at the same position, and ends after the deletion range
310
- // -------------
311
- // xxxxxxx
312
- //
313
- // 3. The token starts inside the deletion range
314
- // 3a. The token is inside the deletion range
315
- // -------
316
- // xxxxxxxxxxxxx
317
- // 3b. The token starts inside the deletion range, and ends at the same position as the deletion range
318
- // ----------
319
- // xxxxxxxxxxxxx
320
- // 3c. The token starts inside the deletion range, and ends after the deletion range
321
- // ------------
322
- // xxxxxxxxxxx
323
- //
324
- // 4. The token starts after the deletion range
325
- // -----------
326
- // xxxxxxxx
327
- //
328
- const tokens = this._tokens;
329
- const tokenCount = this._tokenCount;
330
- const deletedLineCount = (endDeltaLine - startDeltaLine);
331
- let newTokenCount = 0;
332
- let hasDeletedTokens = false;
333
- for (let i = 0; i < tokenCount; i++) {
334
- const srcOffset = 4 * i;
335
- let tokenDeltaLine = tokens[srcOffset];
336
- let tokenStartCharacter = tokens[srcOffset + 1];
337
- let tokenEndCharacter = tokens[srcOffset + 2];
338
- const tokenMetadata = tokens[srcOffset + 3];
339
- if (tokenDeltaLine < startDeltaLine || (tokenDeltaLine === startDeltaLine && tokenEndCharacter <= startCharacter)) {
340
- // 1a. The token is completely before the deletion range
341
- // => nothing to do
342
- newTokenCount++;
343
- continue;
344
- }
345
- else if (tokenDeltaLine === startDeltaLine && tokenStartCharacter < startCharacter) {
346
- // 1b, 1c, 1d
347
- // => the token survives, but it needs to shrink
348
- if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
349
- // 1d. The token starts before, the deletion range is inside the token
350
- // => the token shrinks by the deletion character count
351
- tokenEndCharacter -= (endCharacter - startCharacter);
352
- }
353
- else {
354
- // 1b. The token starts before, the deletion range ends after the token
355
- // 1c. The token starts before, the deletion range ends precisely with the token
356
- // => the token shrinks its ending to the deletion start
357
- tokenEndCharacter = startCharacter;
358
- }
359
- }
360
- else if (tokenDeltaLine === startDeltaLine && tokenStartCharacter === startCharacter) {
361
- // 2a, 2b, 2c
362
- if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
363
- // 2c. The token starts at the same position, and ends after the deletion range
364
- // => the token shrinks by the deletion character count
365
- tokenEndCharacter -= (endCharacter - startCharacter);
366
- }
367
- else {
368
- // 2a. The token starts at the same position, and ends inside the deletion range
369
- // 2b. The token starts at the same position, and ends at the same position as the deletion range
370
- // => the token is deleted
371
- hasDeletedTokens = true;
372
- continue;
373
- }
374
- }
375
- else if (tokenDeltaLine < endDeltaLine || (tokenDeltaLine === endDeltaLine && tokenStartCharacter < endCharacter)) {
376
- // 3a, 3b, 3c
377
- if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
378
- // 3c. The token starts inside the deletion range, and ends after the deletion range
379
- // => the token moves to continue right after the deletion
380
- tokenDeltaLine = startDeltaLine;
381
- tokenStartCharacter = startCharacter;
382
- tokenEndCharacter = tokenStartCharacter + (tokenEndCharacter - endCharacter);
383
- }
384
- else {
385
- // 3a. The token is inside the deletion range
386
- // 3b. The token starts inside the deletion range, and ends at the same position as the deletion range
387
- // => the token is deleted
388
- hasDeletedTokens = true;
389
- continue;
390
- }
391
- }
392
- else if (tokenDeltaLine > endDeltaLine) {
393
- // 4. (partial) The token starts after the deletion range, on a line below...
394
- if (deletedLineCount === 0 && !hasDeletedTokens) {
395
- // early stop, there is no need to walk all the tokens and do nothing...
396
- newTokenCount = tokenCount;
397
- break;
398
- }
399
- tokenDeltaLine -= deletedLineCount;
400
- }
401
- else if (tokenDeltaLine === endDeltaLine && tokenStartCharacter >= endCharacter) {
402
- // 4. (continued) The token starts after the deletion range, on the last line where a deletion occurs
403
- if (horizontalShiftForFirstLineTokens && tokenDeltaLine === 0) {
404
- tokenStartCharacter += horizontalShiftForFirstLineTokens;
405
- tokenEndCharacter += horizontalShiftForFirstLineTokens;
406
- }
407
- tokenDeltaLine -= deletedLineCount;
408
- tokenStartCharacter -= (endCharacter - startCharacter);
409
- tokenEndCharacter -= (endCharacter - startCharacter);
410
- }
411
- else {
412
- throw new Error(`Not possible!`);
413
- }
414
- const destOffset = 4 * newTokenCount;
415
- tokens[destOffset] = tokenDeltaLine;
416
- tokens[destOffset + 1] = tokenStartCharacter;
417
- tokens[destOffset + 2] = tokenEndCharacter;
418
- tokens[destOffset + 3] = tokenMetadata;
419
- newTokenCount++;
420
- }
421
- this._tokenCount = newTokenCount;
422
- }
423
- acceptInsertText(deltaLine, character, eolCount, firstLineLength, lastLineLength, firstCharCode) {
424
- // Here are the cases I used to think about this:
425
- //
426
- // 1. The token is completely before the insertion point
427
- // ----------- |
428
- // 2. The token ends precisely at the insertion point
429
- // -----------|
430
- // 3. The token contains the insertion point
431
- // -----|------
432
- // 4. The token starts precisely at the insertion point
433
- // |-----------
434
- // 5. The token is completely after the insertion point
435
- // | -----------
436
- //
437
- const isInsertingPreciselyOneWordCharacter = (eolCount === 0
438
- && firstLineLength === 1
439
- && ((firstCharCode >= 48 /* CharCode.Digit0 */ && firstCharCode <= 57 /* CharCode.Digit9 */)
440
- || (firstCharCode >= 65 /* CharCode.A */ && firstCharCode <= 90 /* CharCode.Z */)
441
- || (firstCharCode >= 97 /* CharCode.a */ && firstCharCode <= 122 /* CharCode.z */)));
442
- const tokens = this._tokens;
443
- const tokenCount = this._tokenCount;
444
- for (let i = 0; i < tokenCount; i++) {
445
- const offset = 4 * i;
446
- let tokenDeltaLine = tokens[offset];
447
- let tokenStartCharacter = tokens[offset + 1];
448
- let tokenEndCharacter = tokens[offset + 2];
449
- if (tokenDeltaLine < deltaLine || (tokenDeltaLine === deltaLine && tokenEndCharacter < character)) {
450
- // 1. The token is completely before the insertion point
451
- // => nothing to do
452
- continue;
453
- }
454
- else if (tokenDeltaLine === deltaLine && tokenEndCharacter === character) {
455
- // 2. The token ends precisely at the insertion point
456
- // => expand the end character only if inserting precisely one character that is a word character
457
- if (isInsertingPreciselyOneWordCharacter) {
458
- tokenEndCharacter += 1;
459
- }
460
- else {
461
- continue;
462
- }
463
- }
464
- else if (tokenDeltaLine === deltaLine && tokenStartCharacter < character && character < tokenEndCharacter) {
465
- // 3. The token contains the insertion point
466
- if (eolCount === 0) {
467
- // => just expand the end character
468
- tokenEndCharacter += firstLineLength;
469
- }
470
- else {
471
- // => cut off the token
472
- tokenEndCharacter = character;
473
- }
474
- }
475
- else {
476
- // 4. or 5.
477
- if (tokenDeltaLine === deltaLine && tokenStartCharacter === character) {
478
- // 4. The token starts precisely at the insertion point
479
- // => grow the token (by keeping its start constant) only if inserting precisely one character that is a word character
480
- // => otherwise behave as in case 5.
481
- if (isInsertingPreciselyOneWordCharacter) {
482
- continue;
483
- }
484
- }
485
- // => the token must move and keep its size constant
486
- if (tokenDeltaLine === deltaLine) {
487
- tokenDeltaLine += eolCount;
488
- // this token is on the line where the insertion is taking place
489
- if (eolCount === 0) {
490
- tokenStartCharacter += firstLineLength;
491
- tokenEndCharacter += firstLineLength;
492
- }
493
- else {
494
- const tokenLength = tokenEndCharacter - tokenStartCharacter;
495
- tokenStartCharacter = lastLineLength + (tokenStartCharacter - character);
496
- tokenEndCharacter = tokenStartCharacter + tokenLength;
497
- }
498
- }
499
- else {
500
- tokenDeltaLine += eolCount;
501
- }
502
- }
503
- tokens[offset] = tokenDeltaLine;
504
- tokens[offset + 1] = tokenStartCharacter;
505
- tokens[offset + 2] = tokenEndCharacter;
506
- }
507
- }
508
- static { this._rateLimiter = new RateLimiter(10 / 60); } // limit to 10 times per minute
509
- reportIfInvalid(model, startLineNumber) {
510
- for (let i = 0; i < this._tokenCount; i++) {
511
- const lineNumber = this._getDeltaLine(i) + startLineNumber;
512
- if (lineNumber < 1) {
513
- SparseMultilineTokensStorage._rateLimiter.runIfNotLimited(() => {
514
- console.error('Invalid Semantic Tokens Data From Extension: lineNumber < 1');
515
- });
516
- }
517
- else if (lineNumber > model.getLineCount()) {
518
- SparseMultilineTokensStorage._rateLimiter.runIfNotLimited(() => {
519
- console.error('Invalid Semantic Tokens Data From Extension: lineNumber > model.getLineCount()');
520
- });
521
- }
522
- else if (this._getEndCharacter(i) > model.getLineLength(lineNumber)) {
523
- SparseMultilineTokensStorage._rateLimiter.runIfNotLimited(() => {
524
- console.error('Invalid Semantic Tokens Data From Extension: end character > model.getLineLength(lineNumber)');
525
- });
526
- }
527
- }
528
- }
529
- }
530
- class SparseLineTokens {
531
- constructor(tokens) {
532
- this._tokens = tokens;
533
- }
534
- getCount() {
535
- return this._tokens.length / 4;
536
- }
537
- getStartCharacter(tokenIndex) {
538
- return this._tokens[4 * tokenIndex + 1];
539
- }
540
- getEndCharacter(tokenIndex) {
541
- return this._tokens[4 * tokenIndex + 2];
542
- }
543
- getMetadata(tokenIndex) {
544
- return this._tokens[4 * tokenIndex + 3];
545
- }
546
- }
547
-
548
- export { SparseLineTokens, SparseMultilineTokens };