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,350 +0,0 @@
1
- import { LineTokens } from '../tokens/lineTokens.js';
2
- import { Position } from '../core/position.js';
3
- import { LineInjectedText } from '../textModelEvents.js';
4
- import { ViewLineData } from '../viewModel.js';
5
- import { SingleLineInlineDecoration } from './inlineDecorations.js';
6
-
7
- /*---------------------------------------------------------------------------------------------
8
- * Copyright (c) Microsoft Corporation. All rights reserved.
9
- * Licensed under the MIT License. See License.txt in the project root for license information.
10
- *--------------------------------------------------------------------------------------------*/
11
- function createModelLineProjection(lineBreakData, isVisible) {
12
- if (lineBreakData === null) {
13
- // No mapping needed
14
- if (isVisible) {
15
- return IdentityModelLineProjection.INSTANCE;
16
- }
17
- return HiddenModelLineProjection.INSTANCE;
18
- }
19
- else {
20
- return new ModelLineProjection(lineBreakData, isVisible);
21
- }
22
- }
23
- /**
24
- * This projection is used to
25
- * * wrap model lines
26
- * * inject text
27
- */
28
- class ModelLineProjection {
29
- constructor(lineBreakData, isVisible) {
30
- this._projectionData = lineBreakData;
31
- this._isVisible = isVisible;
32
- }
33
- isVisible() {
34
- return this._isVisible;
35
- }
36
- setVisible(isVisible) {
37
- this._isVisible = isVisible;
38
- return this;
39
- }
40
- getProjectionData() {
41
- return this._projectionData;
42
- }
43
- getViewLineCount() {
44
- if (!this._isVisible) {
45
- return 0;
46
- }
47
- return this._projectionData.getOutputLineCount();
48
- }
49
- getViewLineContent(model, modelLineNumber, outputLineIndex) {
50
- this._assertVisible();
51
- const startOffsetInInputWithInjections = outputLineIndex > 0 ? this._projectionData.breakOffsets[outputLineIndex - 1] : 0;
52
- const endOffsetInInputWithInjections = this._projectionData.breakOffsets[outputLineIndex];
53
- let r;
54
- if (this._projectionData.injectionOffsets !== null) {
55
- const injectedTexts = this._projectionData.injectionOffsets.map((offset, idx) => new LineInjectedText(0, 0, offset + 1, this._projectionData.injectionOptions[idx], 0));
56
- const lineWithInjections = LineInjectedText.applyInjectedText(model.getLineContent(modelLineNumber), injectedTexts);
57
- r = lineWithInjections.substring(startOffsetInInputWithInjections, endOffsetInInputWithInjections);
58
- }
59
- else {
60
- r = model.getValueInRange({
61
- startLineNumber: modelLineNumber,
62
- startColumn: startOffsetInInputWithInjections + 1,
63
- endLineNumber: modelLineNumber,
64
- endColumn: endOffsetInInputWithInjections + 1
65
- });
66
- }
67
- if (outputLineIndex > 0) {
68
- r = spaces(this._projectionData.wrappedTextIndentLength) + r;
69
- }
70
- return r;
71
- }
72
- getViewLineLength(model, modelLineNumber, outputLineIndex) {
73
- this._assertVisible();
74
- return this._projectionData.getLineLength(outputLineIndex);
75
- }
76
- getViewLineMinColumn(_model, _modelLineNumber, outputLineIndex) {
77
- this._assertVisible();
78
- return this._projectionData.getMinOutputOffset(outputLineIndex) + 1;
79
- }
80
- getViewLineMaxColumn(model, modelLineNumber, outputLineIndex) {
81
- this._assertVisible();
82
- return this._projectionData.getMaxOutputOffset(outputLineIndex) + 1;
83
- }
84
- /**
85
- * Try using {@link getViewLinesData} instead.
86
- */
87
- getViewLineData(model, modelLineNumber, outputLineIndex) {
88
- const arr = new Array();
89
- this.getViewLinesData(model, modelLineNumber, outputLineIndex, 1, 0, [true], arr);
90
- return arr[0];
91
- }
92
- getViewLinesData(model, modelLineNumber, outputLineIdx, lineCount, globalStartIndex, needed, result) {
93
- this._assertVisible();
94
- const lineBreakData = this._projectionData;
95
- const injectionOffsets = lineBreakData.injectionOffsets;
96
- const injectionOptions = lineBreakData.injectionOptions;
97
- let inlineDecorationsPerOutputLine = null;
98
- if (injectionOffsets) {
99
- inlineDecorationsPerOutputLine = [];
100
- let totalInjectedTextLengthBefore = 0;
101
- let currentInjectedOffset = 0;
102
- for (let outputLineIndex = 0; outputLineIndex < lineBreakData.getOutputLineCount(); outputLineIndex++) {
103
- const inlineDecorations = new Array();
104
- inlineDecorationsPerOutputLine[outputLineIndex] = inlineDecorations;
105
- const lineStartOffsetInInputWithInjections = outputLineIndex > 0 ? lineBreakData.breakOffsets[outputLineIndex - 1] : 0;
106
- const lineEndOffsetInInputWithInjections = lineBreakData.breakOffsets[outputLineIndex];
107
- while (currentInjectedOffset < injectionOffsets.length) {
108
- const length = injectionOptions[currentInjectedOffset].content.length;
109
- const injectedTextStartOffsetInInputWithInjections = injectionOffsets[currentInjectedOffset] + totalInjectedTextLengthBefore;
110
- const injectedTextEndOffsetInInputWithInjections = injectedTextStartOffsetInInputWithInjections + length;
111
- if (injectedTextStartOffsetInInputWithInjections > lineEndOffsetInInputWithInjections) {
112
- // Injected text only starts in later wrapped lines.
113
- break;
114
- }
115
- if (lineStartOffsetInInputWithInjections < injectedTextEndOffsetInInputWithInjections) {
116
- // Injected text ends after or in this line (but also starts in or before this line).
117
- const options = injectionOptions[currentInjectedOffset];
118
- if (options.inlineClassName) {
119
- const offset = (outputLineIndex > 0 ? lineBreakData.wrappedTextIndentLength : 0);
120
- const start = offset + Math.max(injectedTextStartOffsetInInputWithInjections - lineStartOffsetInInputWithInjections, 0);
121
- const end = offset + Math.min(injectedTextEndOffsetInInputWithInjections - lineStartOffsetInInputWithInjections, lineEndOffsetInInputWithInjections - lineStartOffsetInInputWithInjections);
122
- if (start !== end) {
123
- inlineDecorations.push(new SingleLineInlineDecoration(start, end, options.inlineClassName, options.inlineClassNameAffectsLetterSpacing));
124
- }
125
- }
126
- }
127
- if (injectedTextEndOffsetInInputWithInjections <= lineEndOffsetInInputWithInjections) {
128
- totalInjectedTextLengthBefore += length;
129
- currentInjectedOffset++;
130
- }
131
- else {
132
- // injected text breaks into next line, process it again
133
- break;
134
- }
135
- }
136
- }
137
- }
138
- let lineWithInjections;
139
- if (injectionOffsets) {
140
- const tokensToInsert = [];
141
- for (let idx = 0; idx < injectionOffsets.length; idx++) {
142
- const offset = injectionOffsets[idx];
143
- const tokens = injectionOptions[idx].tokens;
144
- if (tokens) {
145
- tokens.forEach((range, info) => {
146
- tokensToInsert.push({
147
- offset,
148
- text: range.substring(injectionOptions[idx].content),
149
- tokenMetadata: info.metadata,
150
- });
151
- });
152
- }
153
- else {
154
- tokensToInsert.push({
155
- offset,
156
- text: injectionOptions[idx].content,
157
- tokenMetadata: LineTokens.defaultTokenMetadata,
158
- });
159
- }
160
- }
161
- lineWithInjections = model.tokenization.getLineTokens(modelLineNumber).withInserted(tokensToInsert);
162
- }
163
- else {
164
- lineWithInjections = model.tokenization.getLineTokens(modelLineNumber);
165
- }
166
- for (let outputLineIndex = outputLineIdx; outputLineIndex < outputLineIdx + lineCount; outputLineIndex++) {
167
- const globalIndex = globalStartIndex + outputLineIndex - outputLineIdx;
168
- if (!needed[globalIndex]) {
169
- result[globalIndex] = null;
170
- continue;
171
- }
172
- result[globalIndex] = this._getViewLineData(lineWithInjections, inlineDecorationsPerOutputLine ? inlineDecorationsPerOutputLine[outputLineIndex] : null, outputLineIndex);
173
- }
174
- }
175
- _getViewLineData(lineWithInjections, inlineDecorations, outputLineIndex) {
176
- this._assertVisible();
177
- const lineBreakData = this._projectionData;
178
- const deltaStartIndex = (outputLineIndex > 0 ? lineBreakData.wrappedTextIndentLength : 0);
179
- const lineStartOffsetInInputWithInjections = outputLineIndex > 0 ? lineBreakData.breakOffsets[outputLineIndex - 1] : 0;
180
- const lineEndOffsetInInputWithInjections = lineBreakData.breakOffsets[outputLineIndex];
181
- const tokens = lineWithInjections.sliceAndInflate(lineStartOffsetInInputWithInjections, lineEndOffsetInInputWithInjections, deltaStartIndex);
182
- let lineContent = tokens.getLineContent();
183
- if (outputLineIndex > 0) {
184
- lineContent = spaces(lineBreakData.wrappedTextIndentLength) + lineContent;
185
- }
186
- const minColumn = this._projectionData.getMinOutputOffset(outputLineIndex) + 1;
187
- const maxColumn = lineContent.length + 1;
188
- const continuesWithWrappedLine = (outputLineIndex + 1 < this.getViewLineCount());
189
- const startVisibleColumn = (outputLineIndex === 0 ? 0 : lineBreakData.breakOffsetsVisibleColumn[outputLineIndex - 1]);
190
- return new ViewLineData(lineContent, continuesWithWrappedLine, minColumn, maxColumn, startVisibleColumn, tokens, inlineDecorations);
191
- }
192
- getModelColumnOfViewPosition(outputLineIndex, outputColumn) {
193
- this._assertVisible();
194
- return this._projectionData.translateToInputOffset(outputLineIndex, outputColumn - 1) + 1;
195
- }
196
- getViewPositionOfModelPosition(deltaLineNumber, inputColumn, affinity = 2 /* PositionAffinity.None */) {
197
- this._assertVisible();
198
- const r = this._projectionData.translateToOutputPosition(inputColumn - 1, affinity);
199
- return r.toPosition(deltaLineNumber);
200
- }
201
- getViewLineNumberOfModelPosition(deltaLineNumber, inputColumn) {
202
- this._assertVisible();
203
- const r = this._projectionData.translateToOutputPosition(inputColumn - 1);
204
- return deltaLineNumber + r.outputLineIndex;
205
- }
206
- normalizePosition(outputLineIndex, outputPosition, affinity) {
207
- const baseViewLineNumber = outputPosition.lineNumber - outputLineIndex;
208
- const normalizedOutputPosition = this._projectionData.normalizeOutputPosition(outputLineIndex, outputPosition.column - 1, affinity);
209
- const result = normalizedOutputPosition.toPosition(baseViewLineNumber);
210
- return result;
211
- }
212
- getInjectedTextAt(outputLineIndex, outputColumn) {
213
- return this._projectionData.getInjectedText(outputLineIndex, outputColumn - 1);
214
- }
215
- _assertVisible() {
216
- if (!this._isVisible) {
217
- throw new Error('Not supported');
218
- }
219
- }
220
- }
221
- /**
222
- * This projection does not change the model line.
223
- */
224
- class IdentityModelLineProjection {
225
- static { this.INSTANCE = new IdentityModelLineProjection(); }
226
- constructor() { }
227
- isVisible() {
228
- return true;
229
- }
230
- setVisible(isVisible) {
231
- if (isVisible) {
232
- return this;
233
- }
234
- return HiddenModelLineProjection.INSTANCE;
235
- }
236
- getProjectionData() {
237
- return null;
238
- }
239
- getViewLineCount() {
240
- return 1;
241
- }
242
- getViewLineContent(model, modelLineNumber, _outputLineIndex) {
243
- return model.getLineContent(modelLineNumber);
244
- }
245
- getViewLineLength(model, modelLineNumber, _outputLineIndex) {
246
- return model.getLineLength(modelLineNumber);
247
- }
248
- getViewLineMinColumn(model, modelLineNumber, _outputLineIndex) {
249
- return model.getLineMinColumn(modelLineNumber);
250
- }
251
- getViewLineMaxColumn(model, modelLineNumber, _outputLineIndex) {
252
- return model.getLineMaxColumn(modelLineNumber);
253
- }
254
- getViewLineData(model, modelLineNumber, _outputLineIndex) {
255
- const lineTokens = model.tokenization.getLineTokens(modelLineNumber);
256
- const lineContent = lineTokens.getLineContent();
257
- return new ViewLineData(lineContent, false, 1, lineContent.length + 1, 0, lineTokens.inflate(), null);
258
- }
259
- getViewLinesData(model, modelLineNumber, _fromOuputLineIndex, _toOutputLineIndex, globalStartIndex, needed, result) {
260
- if (!needed[globalStartIndex]) {
261
- result[globalStartIndex] = null;
262
- return;
263
- }
264
- result[globalStartIndex] = this.getViewLineData(model, modelLineNumber, 0);
265
- }
266
- getModelColumnOfViewPosition(_outputLineIndex, outputColumn) {
267
- return outputColumn;
268
- }
269
- getViewPositionOfModelPosition(deltaLineNumber, inputColumn) {
270
- return new Position(deltaLineNumber, inputColumn);
271
- }
272
- getViewLineNumberOfModelPosition(deltaLineNumber, _inputColumn) {
273
- return deltaLineNumber;
274
- }
275
- normalizePosition(outputLineIndex, outputPosition, affinity) {
276
- return outputPosition;
277
- }
278
- getInjectedTextAt(_outputLineIndex, _outputColumn) {
279
- return null;
280
- }
281
- }
282
- /**
283
- * This projection hides the model line.
284
- */
285
- class HiddenModelLineProjection {
286
- static { this.INSTANCE = new HiddenModelLineProjection(); }
287
- constructor() { }
288
- isVisible() {
289
- return false;
290
- }
291
- setVisible(isVisible) {
292
- if (!isVisible) {
293
- return this;
294
- }
295
- return IdentityModelLineProjection.INSTANCE;
296
- }
297
- getProjectionData() {
298
- return null;
299
- }
300
- getViewLineCount() {
301
- return 0;
302
- }
303
- getViewLineContent(_model, _modelLineNumber, _outputLineIndex) {
304
- throw new Error('Not supported');
305
- }
306
- getViewLineLength(_model, _modelLineNumber, _outputLineIndex) {
307
- throw new Error('Not supported');
308
- }
309
- getViewLineMinColumn(_model, _modelLineNumber, _outputLineIndex) {
310
- throw new Error('Not supported');
311
- }
312
- getViewLineMaxColumn(_model, _modelLineNumber, _outputLineIndex) {
313
- throw new Error('Not supported');
314
- }
315
- getViewLineData(_model, _modelLineNumber, _outputLineIndex) {
316
- throw new Error('Not supported');
317
- }
318
- getViewLinesData(_model, _modelLineNumber, _fromOuputLineIndex, _toOutputLineIndex, _globalStartIndex, _needed, _result) {
319
- throw new Error('Not supported');
320
- }
321
- getModelColumnOfViewPosition(_outputLineIndex, _outputColumn) {
322
- throw new Error('Not supported');
323
- }
324
- getViewPositionOfModelPosition(_deltaLineNumber, _inputColumn) {
325
- throw new Error('Not supported');
326
- }
327
- getViewLineNumberOfModelPosition(_deltaLineNumber, _inputColumn) {
328
- throw new Error('Not supported');
329
- }
330
- normalizePosition(outputLineIndex, outputPosition, affinity) {
331
- throw new Error('Not supported');
332
- }
333
- getInjectedTextAt(_outputLineIndex, _outputColumn) {
334
- throw new Error('Not supported');
335
- }
336
- }
337
- const _spaces = [''];
338
- function spaces(count) {
339
- if (count >= _spaces.length) {
340
- for (let i = 1; i <= count; i++) {
341
- _spaces[i] = _makeSpaces(i);
342
- }
343
- }
344
- return _spaces[count];
345
- }
346
- function _makeSpaces(count) {
347
- return new Array(count + 1).join(' ');
348
- }
349
-
350
- export { createModelLineProjection };
@@ -1,297 +0,0 @@
1
- import { assertNever } from '../../base/common/assert.js';
2
- import { Position } from './core/position.js';
3
- import { InjectedTextCursorStops } from './model.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
- /**
10
- * *input*:
11
- * ```
12
- * xxxxxxxxxxxxxxxxxxxxxxxxxxx
13
- * ```
14
- *
15
- * -> Applying injections `[i...i]`, *inputWithInjections*:
16
- * ```
17
- * xxxxxx[iiiiiiiiii]xxxxxxxxxxxxxxxxx[ii]xxxx
18
- * ```
19
- *
20
- * -> breaking at offsets `|` in `xxxxxx[iiiiiii|iii]xxxxxxxxxxx|xxxxxx[ii]xxxx|`:
21
- * ```
22
- * xxxxxx[iiiiiii
23
- * iii]xxxxxxxxxxx
24
- * xxxxxx[ii]xxxx
25
- * ```
26
- *
27
- * -> applying wrappedTextIndentLength, *output*:
28
- * ```
29
- * xxxxxx[iiiiiii
30
- * iii]xxxxxxxxxxx
31
- * xxxxxx[ii]xxxx
32
- * ```
33
- */
34
- class ModelLineProjectionData {
35
- constructor(injectionOffsets,
36
- /**
37
- * `injectionOptions.length` must equal `injectionOffsets.length`
38
- */
39
- injectionOptions,
40
- /**
41
- * Refers to offsets after applying injections to the source.
42
- * The last break offset indicates the length of the source after applying injections.
43
- */
44
- breakOffsets,
45
- /**
46
- * Refers to offsets after applying injections
47
- */
48
- breakOffsetsVisibleColumn, wrappedTextIndentLength) {
49
- this.injectionOffsets = injectionOffsets;
50
- this.injectionOptions = injectionOptions;
51
- this.breakOffsets = breakOffsets;
52
- this.breakOffsetsVisibleColumn = breakOffsetsVisibleColumn;
53
- this.wrappedTextIndentLength = wrappedTextIndentLength;
54
- }
55
- getOutputLineCount() {
56
- return this.breakOffsets.length;
57
- }
58
- getMinOutputOffset(outputLineIndex) {
59
- if (outputLineIndex > 0) {
60
- return this.wrappedTextIndentLength;
61
- }
62
- return 0;
63
- }
64
- getLineLength(outputLineIndex) {
65
- // These offsets refer to model text with injected text.
66
- const startOffset = outputLineIndex > 0 ? this.breakOffsets[outputLineIndex - 1] : 0;
67
- const endOffset = this.breakOffsets[outputLineIndex];
68
- let lineLength = endOffset - startOffset;
69
- if (outputLineIndex > 0) {
70
- lineLength += this.wrappedTextIndentLength;
71
- }
72
- return lineLength;
73
- }
74
- getMaxOutputOffset(outputLineIndex) {
75
- return this.getLineLength(outputLineIndex);
76
- }
77
- translateToInputOffset(outputLineIndex, outputOffset) {
78
- if (outputLineIndex > 0) {
79
- outputOffset = Math.max(0, outputOffset - this.wrappedTextIndentLength);
80
- }
81
- const offsetInInputWithInjection = outputLineIndex === 0 ? outputOffset : this.breakOffsets[outputLineIndex - 1] + outputOffset;
82
- let offsetInInput = offsetInInputWithInjection;
83
- if (this.injectionOffsets !== null) {
84
- for (let i = 0; i < this.injectionOffsets.length; i++) {
85
- if (offsetInInput > this.injectionOffsets[i]) {
86
- if (offsetInInput < this.injectionOffsets[i] + this.injectionOptions[i].content.length) {
87
- // `inputOffset` is within injected text
88
- offsetInInput = this.injectionOffsets[i];
89
- }
90
- else {
91
- offsetInInput -= this.injectionOptions[i].content.length;
92
- }
93
- }
94
- else {
95
- break;
96
- }
97
- }
98
- }
99
- return offsetInInput;
100
- }
101
- translateToOutputPosition(inputOffset, affinity = 2 /* PositionAffinity.None */) {
102
- let inputOffsetInInputWithInjection = inputOffset;
103
- if (this.injectionOffsets !== null) {
104
- for (let i = 0; i < this.injectionOffsets.length; i++) {
105
- if (inputOffset < this.injectionOffsets[i]) {
106
- break;
107
- }
108
- if (affinity !== 1 /* PositionAffinity.Right */ && inputOffset === this.injectionOffsets[i]) {
109
- break;
110
- }
111
- inputOffsetInInputWithInjection += this.injectionOptions[i].content.length;
112
- }
113
- }
114
- return this.offsetInInputWithInjectionsToOutputPosition(inputOffsetInInputWithInjection, affinity);
115
- }
116
- offsetInInputWithInjectionsToOutputPosition(offsetInInputWithInjections, affinity = 2 /* PositionAffinity.None */) {
117
- let low = 0;
118
- let high = this.breakOffsets.length - 1;
119
- let mid = 0;
120
- let midStart = 0;
121
- while (low <= high) {
122
- mid = low + ((high - low) / 2) | 0;
123
- const midStop = this.breakOffsets[mid];
124
- midStart = mid > 0 ? this.breakOffsets[mid - 1] : 0;
125
- if (affinity === 0 /* PositionAffinity.Left */) {
126
- if (offsetInInputWithInjections <= midStart) {
127
- high = mid - 1;
128
- }
129
- else if (offsetInInputWithInjections > midStop) {
130
- low = mid + 1;
131
- }
132
- else {
133
- break;
134
- }
135
- }
136
- else {
137
- if (offsetInInputWithInjections < midStart) {
138
- high = mid - 1;
139
- }
140
- else if (offsetInInputWithInjections >= midStop) {
141
- low = mid + 1;
142
- }
143
- else {
144
- break;
145
- }
146
- }
147
- }
148
- let outputOffset = offsetInInputWithInjections - midStart;
149
- if (mid > 0) {
150
- outputOffset += this.wrappedTextIndentLength;
151
- }
152
- return new OutputPosition(mid, outputOffset);
153
- }
154
- normalizeOutputPosition(outputLineIndex, outputOffset, affinity) {
155
- if (this.injectionOffsets !== null) {
156
- const offsetInInputWithInjections = this.outputPositionToOffsetInInputWithInjections(outputLineIndex, outputOffset);
157
- const normalizedOffsetInUnwrappedLine = this.normalizeOffsetInInputWithInjectionsAroundInjections(offsetInInputWithInjections, affinity);
158
- if (normalizedOffsetInUnwrappedLine !== offsetInInputWithInjections) {
159
- // injected text caused a change
160
- return this.offsetInInputWithInjectionsToOutputPosition(normalizedOffsetInUnwrappedLine, affinity);
161
- }
162
- }
163
- if (affinity === 0 /* PositionAffinity.Left */) {
164
- if (outputLineIndex > 0 && outputOffset === this.getMinOutputOffset(outputLineIndex)) {
165
- return new OutputPosition(outputLineIndex - 1, this.getMaxOutputOffset(outputLineIndex - 1));
166
- }
167
- }
168
- else if (affinity === 1 /* PositionAffinity.Right */) {
169
- const maxOutputLineIndex = this.getOutputLineCount() - 1;
170
- if (outputLineIndex < maxOutputLineIndex && outputOffset === this.getMaxOutputOffset(outputLineIndex)) {
171
- return new OutputPosition(outputLineIndex + 1, this.getMinOutputOffset(outputLineIndex + 1));
172
- }
173
- }
174
- return new OutputPosition(outputLineIndex, outputOffset);
175
- }
176
- outputPositionToOffsetInInputWithInjections(outputLineIndex, outputOffset) {
177
- if (outputLineIndex > 0) {
178
- outputOffset = Math.max(0, outputOffset - this.wrappedTextIndentLength);
179
- }
180
- const result = (outputLineIndex > 0 ? this.breakOffsets[outputLineIndex - 1] : 0) + outputOffset;
181
- return result;
182
- }
183
- normalizeOffsetInInputWithInjectionsAroundInjections(offsetInInputWithInjections, affinity) {
184
- const injectedText = this.getInjectedTextAtOffset(offsetInInputWithInjections);
185
- if (!injectedText) {
186
- return offsetInInputWithInjections;
187
- }
188
- if (affinity === 2 /* PositionAffinity.None */) {
189
- if (offsetInInputWithInjections === injectedText.offsetInInputWithInjections + injectedText.length
190
- && hasRightCursorStop(this.injectionOptions[injectedText.injectedTextIndex].cursorStops)) {
191
- return injectedText.offsetInInputWithInjections + injectedText.length;
192
- }
193
- else {
194
- let result = injectedText.offsetInInputWithInjections;
195
- if (hasLeftCursorStop(this.injectionOptions[injectedText.injectedTextIndex].cursorStops)) {
196
- return result;
197
- }
198
- let index = injectedText.injectedTextIndex - 1;
199
- while (index >= 0 && this.injectionOffsets[index] === this.injectionOffsets[injectedText.injectedTextIndex]) {
200
- if (hasRightCursorStop(this.injectionOptions[index].cursorStops)) {
201
- break;
202
- }
203
- result -= this.injectionOptions[index].content.length;
204
- if (hasLeftCursorStop(this.injectionOptions[index].cursorStops)) {
205
- break;
206
- }
207
- index--;
208
- }
209
- return result;
210
- }
211
- }
212
- else if (affinity === 1 /* PositionAffinity.Right */ || affinity === 4 /* PositionAffinity.RightOfInjectedText */) {
213
- let result = injectedText.offsetInInputWithInjections + injectedText.length;
214
- let index = injectedText.injectedTextIndex;
215
- // traverse all injected text that touch each other
216
- while (index + 1 < this.injectionOffsets.length && this.injectionOffsets[index + 1] === this.injectionOffsets[index]) {
217
- result += this.injectionOptions[index + 1].content.length;
218
- index++;
219
- }
220
- return result;
221
- }
222
- else if (affinity === 0 /* PositionAffinity.Left */ || affinity === 3 /* PositionAffinity.LeftOfInjectedText */) {
223
- // affinity is left
224
- let result = injectedText.offsetInInputWithInjections;
225
- let index = injectedText.injectedTextIndex;
226
- // traverse all injected text that touch each other
227
- while (index - 1 >= 0 && this.injectionOffsets[index - 1] === this.injectionOffsets[index]) {
228
- result -= this.injectionOptions[index - 1].content.length;
229
- index--;
230
- }
231
- return result;
232
- }
233
- assertNever();
234
- }
235
- getInjectedText(outputLineIndex, outputOffset) {
236
- const offset = this.outputPositionToOffsetInInputWithInjections(outputLineIndex, outputOffset);
237
- const injectedText = this.getInjectedTextAtOffset(offset);
238
- if (!injectedText) {
239
- return null;
240
- }
241
- return {
242
- options: this.injectionOptions[injectedText.injectedTextIndex]
243
- };
244
- }
245
- getInjectedTextAtOffset(offsetInInputWithInjections) {
246
- const injectionOffsets = this.injectionOffsets;
247
- const injectionOptions = this.injectionOptions;
248
- if (injectionOffsets !== null) {
249
- let totalInjectedTextLengthBefore = 0;
250
- for (let i = 0; i < injectionOffsets.length; i++) {
251
- const length = injectionOptions[i].content.length;
252
- const injectedTextStartOffsetInInputWithInjections = injectionOffsets[i] + totalInjectedTextLengthBefore;
253
- const injectedTextEndOffsetInInputWithInjections = injectionOffsets[i] + totalInjectedTextLengthBefore + length;
254
- if (injectedTextStartOffsetInInputWithInjections > offsetInInputWithInjections) {
255
- // Injected text starts later.
256
- break; // All later injected texts have an even larger offset.
257
- }
258
- if (offsetInInputWithInjections <= injectedTextEndOffsetInInputWithInjections) {
259
- // Injected text ends after or with the given position (but also starts with or before it).
260
- return {
261
- injectedTextIndex: i,
262
- offsetInInputWithInjections: injectedTextStartOffsetInInputWithInjections,
263
- length
264
- };
265
- }
266
- totalInjectedTextLengthBefore += length;
267
- }
268
- }
269
- return undefined;
270
- }
271
- }
272
- function hasRightCursorStop(cursorStop) {
273
- if (cursorStop === null || cursorStop === undefined) {
274
- return true;
275
- }
276
- return cursorStop === InjectedTextCursorStops.Right || cursorStop === InjectedTextCursorStops.Both;
277
- }
278
- function hasLeftCursorStop(cursorStop) {
279
- if (cursorStop === null || cursorStop === undefined) {
280
- return true;
281
- }
282
- return cursorStop === InjectedTextCursorStops.Left || cursorStop === InjectedTextCursorStops.Both;
283
- }
284
- class OutputPosition {
285
- constructor(outputLineIndex, outputOffset) {
286
- this.outputLineIndex = outputLineIndex;
287
- this.outputOffset = outputOffset;
288
- }
289
- toString() {
290
- return `${this.outputLineIndex}:${this.outputOffset}`;
291
- }
292
- toPosition(baseLineNumber) {
293
- return new Position(baseLineNumber + this.outputLineIndex, this.outputOffset + 1);
294
- }
295
- }
296
-
297
- export { ModelLineProjectionData, OutputPosition };