monaco-editor11 1.0.9 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/monaco-editor11.es.js +12 -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,183 +0,0 @@
1
- import { BugIndicatingError } from '../../../../base/common/errors.js';
2
- import { OffsetRange } from '../ranges/offsetRange.js';
3
-
4
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
- class BaseEdit {
6
- constructor(replacements) {
7
- this.replacements = replacements;
8
- let lastEndEx = -1;
9
- for (const replacement of replacements) {
10
- if (!(replacement.replaceRange.start >= lastEndEx)) {
11
- throw new BugIndicatingError(`Edits must be disjoint and sorted. Found ${replacement} after ${lastEndEx}`);
12
- }
13
- lastEndEx = replacement.replaceRange.endExclusive;
14
- }
15
- }
16
- toString() {
17
- const edits = this.replacements.map(e => e.toString()).join(', ');
18
- return `[${edits}]`;
19
- }
20
- /**
21
- * Normalizes the edit by removing empty replacements and joining touching replacements (if the replacements allow joining).
22
- * Two edits have an equal normalized edit if and only if they have the same effect on any input.
23
- *
24
- * ![](https://raw.githubusercontent.com/microsoft/vscode/refs/heads/main/src/vs/editor/common/core/edits/docs/BaseEdit_normalize.drawio.png)
25
- *
26
- * Invariant:
27
- * ```
28
- * (forall base: TEdit.apply(base).equals(other.apply(base))) <-> this.normalize().equals(other.normalize())
29
- * ```
30
- * and
31
- * ```
32
- * forall base: TEdit.apply(base).equals(this.normalize().apply(base))
33
- * ```
34
- *
35
- */
36
- normalize() {
37
- const newReplacements = [];
38
- let lastReplacement;
39
- for (const r of this.replacements) {
40
- if (r.getNewLength() === 0 && r.replaceRange.length === 0) {
41
- continue;
42
- }
43
- if (lastReplacement && lastReplacement.replaceRange.endExclusive === r.replaceRange.start) {
44
- const joined = lastReplacement.tryJoinTouching(r);
45
- if (joined) {
46
- lastReplacement = joined;
47
- continue;
48
- }
49
- }
50
- if (lastReplacement) {
51
- newReplacements.push(lastReplacement);
52
- }
53
- lastReplacement = r;
54
- }
55
- if (lastReplacement) {
56
- newReplacements.push(lastReplacement);
57
- }
58
- return this._createNew(newReplacements);
59
- }
60
- /**
61
- * Combines two edits into one with the same effect.
62
- *
63
- * ![](https://raw.githubusercontent.com/microsoft/vscode/refs/heads/main/src/vs/editor/common/core/edits/docs/BaseEdit_compose.drawio.png)
64
- *
65
- * Invariant:
66
- * ```
67
- * other.apply(this.apply(s0)) = this.compose(other).apply(s0)
68
- * ```
69
- */
70
- compose(other) {
71
- const edits1 = this.normalize();
72
- const edits2 = other.normalize();
73
- if (edits1.isEmpty()) {
74
- return edits2;
75
- }
76
- if (edits2.isEmpty()) {
77
- return edits1;
78
- }
79
- const edit1Queue = [...edits1.replacements];
80
- const result = [];
81
- let edit1ToEdit2 = 0;
82
- for (const r2 of edits2.replacements) {
83
- // Copy over edit1 unmodified until it touches edit2.
84
- while (true) {
85
- const r1 = edit1Queue[0];
86
- if (!r1 || r1.replaceRange.start + edit1ToEdit2 + r1.getNewLength() >= r2.replaceRange.start) {
87
- break;
88
- }
89
- edit1Queue.shift();
90
- result.push(r1);
91
- edit1ToEdit2 += r1.getNewLength() - r1.replaceRange.length;
92
- }
93
- const firstEdit1ToEdit2 = edit1ToEdit2;
94
- let firstIntersecting; // or touching
95
- let lastIntersecting; // or touching
96
- while (true) {
97
- const r1 = edit1Queue[0];
98
- if (!r1 || r1.replaceRange.start + edit1ToEdit2 > r2.replaceRange.endExclusive) {
99
- break;
100
- }
101
- // else we intersect, because the new end of edit1 is after or equal to our start
102
- if (!firstIntersecting) {
103
- firstIntersecting = r1;
104
- }
105
- lastIntersecting = r1;
106
- edit1Queue.shift();
107
- edit1ToEdit2 += r1.getNewLength() - r1.replaceRange.length;
108
- }
109
- if (!firstIntersecting) {
110
- result.push(r2.delta(-edit1ToEdit2));
111
- }
112
- else {
113
- const newReplaceRangeStart = Math.min(firstIntersecting.replaceRange.start, r2.replaceRange.start - firstEdit1ToEdit2);
114
- const prefixLength = r2.replaceRange.start - (firstIntersecting.replaceRange.start + firstEdit1ToEdit2);
115
- if (prefixLength > 0) {
116
- const prefix = firstIntersecting.slice(OffsetRange.emptyAt(newReplaceRangeStart), new OffsetRange(0, prefixLength));
117
- result.push(prefix);
118
- }
119
- if (!lastIntersecting) {
120
- throw new BugIndicatingError(`Invariant violation: lastIntersecting is undefined`);
121
- }
122
- const suffixLength = (lastIntersecting.replaceRange.endExclusive + edit1ToEdit2) - r2.replaceRange.endExclusive;
123
- if (suffixLength > 0) {
124
- const e = lastIntersecting.slice(OffsetRange.ofStartAndLength(lastIntersecting.replaceRange.endExclusive, 0), new OffsetRange(lastIntersecting.getNewLength() - suffixLength, lastIntersecting.getNewLength()));
125
- edit1Queue.unshift(e);
126
- edit1ToEdit2 -= e.getNewLength() - e.replaceRange.length;
127
- }
128
- const newReplaceRange = new OffsetRange(newReplaceRangeStart, r2.replaceRange.endExclusive - edit1ToEdit2);
129
- const middle = r2.slice(newReplaceRange, new OffsetRange(0, r2.getNewLength()));
130
- result.push(middle);
131
- }
132
- }
133
- while (true) {
134
- const item = edit1Queue.shift();
135
- if (!item) {
136
- break;
137
- }
138
- result.push(item);
139
- }
140
- return this._createNew(result).normalize();
141
- }
142
- /**
143
- * Returns the range of each replacement in the applied value.
144
- */
145
- getNewRanges() {
146
- const ranges = [];
147
- let offset = 0;
148
- for (const e of this.replacements) {
149
- ranges.push(OffsetRange.ofStartAndLength(e.replaceRange.start + offset, e.getNewLength()));
150
- offset += e.getLengthDelta();
151
- }
152
- return ranges;
153
- }
154
- isEmpty() {
155
- return this.replacements.length === 0;
156
- }
157
- }
158
- class BaseReplacement {
159
- constructor(
160
- /**
161
- * The range to be replaced.
162
- */
163
- replaceRange) {
164
- this.replaceRange = replaceRange;
165
- }
166
- delta(offset) {
167
- return this.slice(this.replaceRange.delta(offset), new OffsetRange(0, this.getNewLength()));
168
- }
169
- getLengthDelta() {
170
- return this.getNewLength() - this.replaceRange.length;
171
- }
172
- toString() {
173
- return `{ ${this.replaceRange.toString()} -> ${this.getNewLength()} }`;
174
- }
175
- get isEmpty() {
176
- return this.getNewLength() === 0 && this.replaceRange.length === 0;
177
- }
178
- getRangeAfterReplace() {
179
- return new OffsetRange(this.replaceRange.start, this.replaceRange.start + this.getNewLength());
180
- }
181
- }
182
-
183
- export { BaseEdit, BaseReplacement };
@@ -1,36 +0,0 @@
1
- import { Range } from './range.js';
2
-
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Microsoft Corporation. All rights reserved.
5
- * Licensed under the MIT License. See License.txt in the project root for license information.
6
- *--------------------------------------------------------------------------------------------*/
7
- class EditOperation {
8
- static insert(position, text) {
9
- return {
10
- range: new Range(position.lineNumber, position.column, position.lineNumber, position.column),
11
- text: text,
12
- forceMoveMarkers: true
13
- };
14
- }
15
- static delete(range) {
16
- return {
17
- range: range,
18
- text: null
19
- };
20
- }
21
- static replace(range, text) {
22
- return {
23
- range: range,
24
- text: text
25
- };
26
- }
27
- static replaceMove(range, text) {
28
- return {
29
- range: range,
30
- text: text,
31
- forceMoveMarkers: true
32
- };
33
- }
34
- }
35
-
36
- export { EditOperation };
@@ -1,363 +0,0 @@
1
- import { localize } from '../../../nls.js';
2
- import { onUnexpectedError } from '../../../base/common/errors.js';
3
- import { Selection } from '../core/selection.js';
4
- import { URI } from '../../../base/common/uri.js';
5
- import { compressConsecutiveTextChanges, TextChange } from '../core/textChange.js';
6
- import { writeUInt32BE, readUInt32BE, writeUInt8, readUInt8 } from '../../../base/common/buffer.js';
7
- import { basename } from '../../../base/common/resources.js';
8
- import { EditSources } from '../textModelEditSource.js';
9
-
10
- /*---------------------------------------------------------------------------------------------
11
- * Copyright (c) Microsoft Corporation. All rights reserved.
12
- * Licensed under the MIT License. See License.txt in the project root for license information.
13
- *--------------------------------------------------------------------------------------------*/
14
- function uriGetComparisonKey(resource) {
15
- return resource.toString();
16
- }
17
- class SingleModelEditStackData {
18
- static create(model, beforeCursorState) {
19
- const alternativeVersionId = model.getAlternativeVersionId();
20
- const eol = getModelEOL(model);
21
- return new SingleModelEditStackData(alternativeVersionId, alternativeVersionId, eol, eol, beforeCursorState, beforeCursorState, []);
22
- }
23
- constructor(beforeVersionId, afterVersionId, beforeEOL, afterEOL, beforeCursorState, afterCursorState, changes) {
24
- this.beforeVersionId = beforeVersionId;
25
- this.afterVersionId = afterVersionId;
26
- this.beforeEOL = beforeEOL;
27
- this.afterEOL = afterEOL;
28
- this.beforeCursorState = beforeCursorState;
29
- this.afterCursorState = afterCursorState;
30
- this.changes = changes;
31
- }
32
- append(model, textChanges, afterEOL, afterVersionId, afterCursorState) {
33
- if (textChanges.length > 0) {
34
- this.changes = compressConsecutiveTextChanges(this.changes, textChanges);
35
- }
36
- this.afterEOL = afterEOL;
37
- this.afterVersionId = afterVersionId;
38
- this.afterCursorState = afterCursorState;
39
- }
40
- static _writeSelectionsSize(selections) {
41
- return 4 + 4 * 4 * (selections ? selections.length : 0);
42
- }
43
- static _writeSelections(b, selections, offset) {
44
- writeUInt32BE(b, (selections ? selections.length : 0), offset);
45
- offset += 4;
46
- if (selections) {
47
- for (const selection of selections) {
48
- writeUInt32BE(b, selection.selectionStartLineNumber, offset);
49
- offset += 4;
50
- writeUInt32BE(b, selection.selectionStartColumn, offset);
51
- offset += 4;
52
- writeUInt32BE(b, selection.positionLineNumber, offset);
53
- offset += 4;
54
- writeUInt32BE(b, selection.positionColumn, offset);
55
- offset += 4;
56
- }
57
- }
58
- return offset;
59
- }
60
- static _readSelections(b, offset, dest) {
61
- const count = readUInt32BE(b, offset);
62
- offset += 4;
63
- for (let i = 0; i < count; i++) {
64
- const selectionStartLineNumber = readUInt32BE(b, offset);
65
- offset += 4;
66
- const selectionStartColumn = readUInt32BE(b, offset);
67
- offset += 4;
68
- const positionLineNumber = readUInt32BE(b, offset);
69
- offset += 4;
70
- const positionColumn = readUInt32BE(b, offset);
71
- offset += 4;
72
- dest.push(new Selection(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn));
73
- }
74
- return offset;
75
- }
76
- serialize() {
77
- let necessarySize = (4 // beforeVersionId
78
- + 4 // afterVersionId
79
- + 1 // beforeEOL
80
- + 1 // afterEOL
81
- + SingleModelEditStackData._writeSelectionsSize(this.beforeCursorState)
82
- + SingleModelEditStackData._writeSelectionsSize(this.afterCursorState)
83
- + 4 // change count
84
- );
85
- for (const change of this.changes) {
86
- necessarySize += change.writeSize();
87
- }
88
- const b = new Uint8Array(necessarySize);
89
- let offset = 0;
90
- writeUInt32BE(b, this.beforeVersionId, offset);
91
- offset += 4;
92
- writeUInt32BE(b, this.afterVersionId, offset);
93
- offset += 4;
94
- writeUInt8(b, this.beforeEOL, offset);
95
- offset += 1;
96
- writeUInt8(b, this.afterEOL, offset);
97
- offset += 1;
98
- offset = SingleModelEditStackData._writeSelections(b, this.beforeCursorState, offset);
99
- offset = SingleModelEditStackData._writeSelections(b, this.afterCursorState, offset);
100
- writeUInt32BE(b, this.changes.length, offset);
101
- offset += 4;
102
- for (const change of this.changes) {
103
- offset = change.write(b, offset);
104
- }
105
- return b.buffer;
106
- }
107
- static deserialize(source) {
108
- const b = new Uint8Array(source);
109
- let offset = 0;
110
- const beforeVersionId = readUInt32BE(b, offset);
111
- offset += 4;
112
- const afterVersionId = readUInt32BE(b, offset);
113
- offset += 4;
114
- const beforeEOL = readUInt8(b, offset);
115
- offset += 1;
116
- const afterEOL = readUInt8(b, offset);
117
- offset += 1;
118
- const beforeCursorState = [];
119
- offset = SingleModelEditStackData._readSelections(b, offset, beforeCursorState);
120
- const afterCursorState = [];
121
- offset = SingleModelEditStackData._readSelections(b, offset, afterCursorState);
122
- const changeCount = readUInt32BE(b, offset);
123
- offset += 4;
124
- const changes = [];
125
- for (let i = 0; i < changeCount; i++) {
126
- offset = TextChange.read(b, offset, changes);
127
- }
128
- return new SingleModelEditStackData(beforeVersionId, afterVersionId, beforeEOL, afterEOL, beforeCursorState, afterCursorState, changes);
129
- }
130
- }
131
- class SingleModelEditStackElement {
132
- get type() {
133
- return 0 /* UndoRedoElementType.Resource */;
134
- }
135
- get resource() {
136
- if (URI.isUri(this.model)) {
137
- return this.model;
138
- }
139
- return this.model.uri;
140
- }
141
- constructor(label, code, model, beforeCursorState) {
142
- this.label = label;
143
- this.code = code;
144
- this.model = model;
145
- this._data = SingleModelEditStackData.create(model, beforeCursorState);
146
- }
147
- toString() {
148
- const data = (this._data instanceof SingleModelEditStackData ? this._data : SingleModelEditStackData.deserialize(this._data));
149
- return data.changes.map(change => change.toString()).join(', ');
150
- }
151
- matchesResource(resource) {
152
- const uri = (URI.isUri(this.model) ? this.model : this.model.uri);
153
- return (uri.toString() === resource.toString());
154
- }
155
- setModel(model) {
156
- this.model = model;
157
- }
158
- canAppend(model) {
159
- return (this.model === model && this._data instanceof SingleModelEditStackData);
160
- }
161
- append(model, textChanges, afterEOL, afterVersionId, afterCursorState) {
162
- if (this._data instanceof SingleModelEditStackData) {
163
- this._data.append(model, textChanges, afterEOL, afterVersionId, afterCursorState);
164
- }
165
- }
166
- close() {
167
- if (this._data instanceof SingleModelEditStackData) {
168
- this._data = this._data.serialize();
169
- }
170
- }
171
- open() {
172
- if (!(this._data instanceof SingleModelEditStackData)) {
173
- this._data = SingleModelEditStackData.deserialize(this._data);
174
- }
175
- }
176
- undo() {
177
- if (URI.isUri(this.model)) {
178
- // don't have a model
179
- throw new Error(`Invalid SingleModelEditStackElement`);
180
- }
181
- if (this._data instanceof SingleModelEditStackData) {
182
- this._data = this._data.serialize();
183
- }
184
- const data = SingleModelEditStackData.deserialize(this._data);
185
- this.model._applyUndo(data.changes, data.beforeEOL, data.beforeVersionId, data.beforeCursorState);
186
- }
187
- redo() {
188
- if (URI.isUri(this.model)) {
189
- // don't have a model
190
- throw new Error(`Invalid SingleModelEditStackElement`);
191
- }
192
- if (this._data instanceof SingleModelEditStackData) {
193
- this._data = this._data.serialize();
194
- }
195
- const data = SingleModelEditStackData.deserialize(this._data);
196
- this.model._applyRedo(data.changes, data.afterEOL, data.afterVersionId, data.afterCursorState);
197
- }
198
- heapSize() {
199
- if (this._data instanceof SingleModelEditStackData) {
200
- this._data = this._data.serialize();
201
- }
202
- return this._data.byteLength + 168 /*heap overhead*/;
203
- }
204
- }
205
- class MultiModelEditStackElement {
206
- get resources() {
207
- return this._editStackElementsArr.map(editStackElement => editStackElement.resource);
208
- }
209
- constructor(label, code, editStackElements) {
210
- this.label = label;
211
- this.code = code;
212
- this.type = 1 /* UndoRedoElementType.Workspace */;
213
- this._isOpen = true;
214
- this._editStackElementsArr = editStackElements.slice(0);
215
- this._editStackElementsMap = new Map();
216
- for (const editStackElement of this._editStackElementsArr) {
217
- const key = uriGetComparisonKey(editStackElement.resource);
218
- this._editStackElementsMap.set(key, editStackElement);
219
- }
220
- this._delegate = null;
221
- }
222
- prepareUndoRedo() {
223
- if (this._delegate) {
224
- return this._delegate.prepareUndoRedo(this);
225
- }
226
- }
227
- matchesResource(resource) {
228
- const key = uriGetComparisonKey(resource);
229
- return (this._editStackElementsMap.has(key));
230
- }
231
- setModel(model) {
232
- const key = uriGetComparisonKey(URI.isUri(model) ? model : model.uri);
233
- if (this._editStackElementsMap.has(key)) {
234
- this._editStackElementsMap.get(key).setModel(model);
235
- }
236
- }
237
- canAppend(model) {
238
- if (!this._isOpen) {
239
- return false;
240
- }
241
- const key = uriGetComparisonKey(model.uri);
242
- if (this._editStackElementsMap.has(key)) {
243
- const editStackElement = this._editStackElementsMap.get(key);
244
- return editStackElement.canAppend(model);
245
- }
246
- return false;
247
- }
248
- append(model, textChanges, afterEOL, afterVersionId, afterCursorState) {
249
- const key = uriGetComparisonKey(model.uri);
250
- const editStackElement = this._editStackElementsMap.get(key);
251
- editStackElement.append(model, textChanges, afterEOL, afterVersionId, afterCursorState);
252
- }
253
- close() {
254
- this._isOpen = false;
255
- }
256
- open() {
257
- // cannot reopen
258
- }
259
- undo() {
260
- this._isOpen = false;
261
- for (const editStackElement of this._editStackElementsArr) {
262
- editStackElement.undo();
263
- }
264
- }
265
- redo() {
266
- for (const editStackElement of this._editStackElementsArr) {
267
- editStackElement.redo();
268
- }
269
- }
270
- heapSize(resource) {
271
- const key = uriGetComparisonKey(resource);
272
- if (this._editStackElementsMap.has(key)) {
273
- const editStackElement = this._editStackElementsMap.get(key);
274
- return editStackElement.heapSize();
275
- }
276
- return 0;
277
- }
278
- split() {
279
- return this._editStackElementsArr;
280
- }
281
- toString() {
282
- const result = [];
283
- for (const editStackElement of this._editStackElementsArr) {
284
- result.push(`${basename(editStackElement.resource)}: ${editStackElement}`);
285
- }
286
- return `{${result.join(', ')}}`;
287
- }
288
- }
289
- function getModelEOL(model) {
290
- const eol = model.getEOL();
291
- if (eol === '\n') {
292
- return 0 /* EndOfLineSequence.LF */;
293
- }
294
- else {
295
- return 1 /* EndOfLineSequence.CRLF */;
296
- }
297
- }
298
- function isEditStackElement(element) {
299
- if (!element) {
300
- return false;
301
- }
302
- return ((element instanceof SingleModelEditStackElement) || (element instanceof MultiModelEditStackElement));
303
- }
304
- class EditStack {
305
- constructor(model, undoRedoService) {
306
- this._model = model;
307
- this._undoRedoService = undoRedoService;
308
- }
309
- pushStackElement() {
310
- const lastElement = this._undoRedoService.getLastElement(this._model.uri);
311
- if (isEditStackElement(lastElement)) {
312
- lastElement.close();
313
- }
314
- }
315
- popStackElement() {
316
- const lastElement = this._undoRedoService.getLastElement(this._model.uri);
317
- if (isEditStackElement(lastElement)) {
318
- lastElement.open();
319
- }
320
- }
321
- clear() {
322
- this._undoRedoService.removeElements(this._model.uri);
323
- }
324
- _getOrCreateEditStackElement(beforeCursorState, group) {
325
- const lastElement = this._undoRedoService.getLastElement(this._model.uri);
326
- if (isEditStackElement(lastElement) && lastElement.canAppend(this._model)) {
327
- return lastElement;
328
- }
329
- const newElement = new SingleModelEditStackElement(localize(785, "Typing"), 'undoredo.textBufferEdit', this._model, beforeCursorState);
330
- this._undoRedoService.pushElement(newElement, group);
331
- return newElement;
332
- }
333
- pushEOL(eol) {
334
- const editStackElement = this._getOrCreateEditStackElement(null, undefined);
335
- this._model.setEOL(eol);
336
- editStackElement.append(this._model, [], getModelEOL(this._model), this._model.getAlternativeVersionId(), null);
337
- }
338
- pushEditOperation(beforeCursorState, editOperations, cursorStateComputer, group, reason = EditSources.unknown({ name: 'pushEditOperation' })) {
339
- const editStackElement = this._getOrCreateEditStackElement(beforeCursorState, group);
340
- const inverseEditOperations = this._model.applyEdits(editOperations, true, reason);
341
- const afterCursorState = EditStack._computeCursorState(cursorStateComputer, inverseEditOperations);
342
- const textChanges = inverseEditOperations.map((op, index) => ({ index: index, textChange: op.textChange }));
343
- textChanges.sort((a, b) => {
344
- if (a.textChange.oldPosition === b.textChange.oldPosition) {
345
- return a.index - b.index;
346
- }
347
- return a.textChange.oldPosition - b.textChange.oldPosition;
348
- });
349
- editStackElement.append(this._model, textChanges.map(op => op.textChange), getModelEOL(this._model), this._model.getAlternativeVersionId(), afterCursorState);
350
- return afterCursorState;
351
- }
352
- static _computeCursorState(cursorStateComputer, inverseEditOperations) {
353
- try {
354
- return cursorStateComputer ? cursorStateComputer(inverseEditOperations) : null;
355
- }
356
- catch (e) {
357
- onUnexpectedError(e);
358
- return null;
359
- }
360
- }
361
- }
362
-
363
- export { EditStack, MultiModelEditStackElement, SingleModelEditStackData, SingleModelEditStackElement, isEditStackElement };
@@ -1,26 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- class InternalEditorAction {
6
- constructor(id, label, alias, metadata, _precondition, _run, _contextKeyService) {
7
- this.id = id;
8
- this.label = label;
9
- this.alias = alias;
10
- this.metadata = metadata;
11
- this._precondition = _precondition;
12
- this._run = _run;
13
- this._contextKeyService = _contextKeyService;
14
- }
15
- isSupported() {
16
- return this._contextKeyService.contextMatchesRules(this._precondition);
17
- }
18
- run(args) {
19
- if (!this.isSupported()) {
20
- return Promise.resolve(undefined);
21
- }
22
- return this._run(args);
23
- }
24
- }
25
-
26
- export { InternalEditorAction };
@@ -1,43 +0,0 @@
1
- import { CancellationTokenSource } from '../../../base/common/cancellation.js';
2
- import { Emitter } from '../../../base/common/event.js';
3
- import { KeyChord } from '../../../base/common/keyCodes.js';
4
- import { URI } from '../../../base/common/uri.js';
5
- import { Position } from '../core/position.js';
6
- import { Range } from '../core/range.js';
7
- import { Selection } from '../core/selection.js';
8
- import { Token } from '../languages.js';
9
- import { MarkerTag, MarkerSeverity, SelectionDirection, KeyCode } from '../standalone/standaloneEnums.js';
10
-
11
- /*---------------------------------------------------------------------------------------------
12
- * Copyright (c) Microsoft Corporation. All rights reserved.
13
- * Licensed under the MIT License. See License.txt in the project root for license information.
14
- *--------------------------------------------------------------------------------------------*/
15
- class KeyMod {
16
- static { this.CtrlCmd = 2048 /* ConstKeyMod.CtrlCmd */; }
17
- static { this.Shift = 1024 /* ConstKeyMod.Shift */; }
18
- static { this.Alt = 512 /* ConstKeyMod.Alt */; }
19
- static { this.WinCtrl = 256 /* ConstKeyMod.WinCtrl */; }
20
- static chord(firstPart, secondPart) {
21
- return KeyChord(firstPart, secondPart);
22
- }
23
- }
24
- function createMonacoBaseAPI() {
25
- return {
26
- editor: undefined, // undefined override expected here
27
- languages: undefined, // undefined override expected here
28
- CancellationTokenSource: CancellationTokenSource,
29
- Emitter: Emitter,
30
- KeyCode: KeyCode,
31
- KeyMod: KeyMod,
32
- Position: Position,
33
- Range: Range,
34
- Selection: Selection,
35
- SelectionDirection: SelectionDirection,
36
- MarkerSeverity: MarkerSeverity,
37
- MarkerTag: MarkerTag,
38
- Uri: URI,
39
- Token: Token
40
- };
41
- }
42
-
43
- export { KeyMod, createMonacoBaseAPI };