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,390 +0,0 @@
1
- import { getLeadingWhitespace } from '../../../base/common/strings.js';
2
- import { IndentAction } from './languageConfiguration.js';
3
- import { IndentationContextProcessor, isLanguageDifferentFromLineStart, ProcessedIndentRulesSupport } from './supports/indentationLineProcessor.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
- * Get nearest preceding line which doesn't match unIndentPattern or contains all whitespace.
11
- * Result:
12
- * -1: run into the boundary of embedded languages
13
- * 0: every line above are invalid
14
- * else: nearest preceding line of the same language
15
- */
16
- function getPrecedingValidLine(model, lineNumber, processedIndentRulesSupport) {
17
- const languageId = model.tokenization.getLanguageIdAtPosition(lineNumber, 0);
18
- if (lineNumber > 1) {
19
- let lastLineNumber;
20
- let resultLineNumber = -1;
21
- for (lastLineNumber = lineNumber - 1; lastLineNumber >= 1; lastLineNumber--) {
22
- if (model.tokenization.getLanguageIdAtPosition(lastLineNumber, 0) !== languageId) {
23
- return resultLineNumber;
24
- }
25
- const text = model.getLineContent(lastLineNumber);
26
- if (processedIndentRulesSupport.shouldIgnore(lastLineNumber) || /^\s+$/.test(text) || text === '') {
27
- resultLineNumber = lastLineNumber;
28
- continue;
29
- }
30
- return lastLineNumber;
31
- }
32
- }
33
- return -1;
34
- }
35
- /**
36
- * Get inherited indentation from above lines.
37
- * 1. Find the nearest preceding line which doesn't match unIndentedLinePattern.
38
- * 2. If this line matches indentNextLinePattern or increaseIndentPattern, it means that the indent level of `lineNumber` should be 1 greater than this line.
39
- * 3. If this line doesn't match any indent rules
40
- * a. check whether the line above it matches indentNextLinePattern
41
- * b. If not, the indent level of this line is the result
42
- * c. If so, it means the indent of this line is *temporary*, go upward utill we find a line whose indent is not temporary (the same workflow a -> b -> c).
43
- * 4. Otherwise, we fail to get an inherited indent from aboves. Return null and we should not touch the indent of `lineNumber`
44
- *
45
- * This function only return the inherited indent based on above lines, it doesn't check whether current line should decrease or not.
46
- */
47
- function getInheritIndentForLine(autoIndent, model, lineNumber, honorIntentialIndent = true, languageConfigurationService) {
48
- if (autoIndent < 4 /* EditorAutoIndentStrategy.Full */) {
49
- return null;
50
- }
51
- const indentRulesSupport = languageConfigurationService.getLanguageConfiguration(model.tokenization.getLanguageId()).indentRulesSupport;
52
- if (!indentRulesSupport) {
53
- return null;
54
- }
55
- const processedIndentRulesSupport = new ProcessedIndentRulesSupport(model, indentRulesSupport, languageConfigurationService);
56
- if (lineNumber <= 1) {
57
- return {
58
- indentation: '',
59
- action: null
60
- };
61
- }
62
- // Use no indent if this is the first non-blank line
63
- for (let priorLineNumber = lineNumber - 1; priorLineNumber > 0; priorLineNumber--) {
64
- if (model.getLineContent(priorLineNumber) !== '') {
65
- break;
66
- }
67
- if (priorLineNumber === 1) {
68
- return {
69
- indentation: '',
70
- action: null
71
- };
72
- }
73
- }
74
- const precedingUnIgnoredLine = getPrecedingValidLine(model, lineNumber, processedIndentRulesSupport);
75
- if (precedingUnIgnoredLine < 0) {
76
- return null;
77
- }
78
- else if (precedingUnIgnoredLine < 1) {
79
- return {
80
- indentation: '',
81
- action: null
82
- };
83
- }
84
- if (processedIndentRulesSupport.shouldIncrease(precedingUnIgnoredLine) || processedIndentRulesSupport.shouldIndentNextLine(precedingUnIgnoredLine)) {
85
- const precedingUnIgnoredLineContent = model.getLineContent(precedingUnIgnoredLine);
86
- return {
87
- indentation: getLeadingWhitespace(precedingUnIgnoredLineContent),
88
- action: IndentAction.Indent,
89
- line: precedingUnIgnoredLine
90
- };
91
- }
92
- else if (processedIndentRulesSupport.shouldDecrease(precedingUnIgnoredLine)) {
93
- const precedingUnIgnoredLineContent = model.getLineContent(precedingUnIgnoredLine);
94
- return {
95
- indentation: getLeadingWhitespace(precedingUnIgnoredLineContent),
96
- action: null,
97
- line: precedingUnIgnoredLine
98
- };
99
- }
100
- else {
101
- // precedingUnIgnoredLine can not be ignored.
102
- // it doesn't increase indent of following lines
103
- // it doesn't increase just next line
104
- // so current line is not affect by precedingUnIgnoredLine
105
- // and then we should get a correct inheritted indentation from above lines
106
- if (precedingUnIgnoredLine === 1) {
107
- return {
108
- indentation: getLeadingWhitespace(model.getLineContent(precedingUnIgnoredLine)),
109
- action: null,
110
- line: precedingUnIgnoredLine
111
- };
112
- }
113
- const previousLine = precedingUnIgnoredLine - 1;
114
- const previousLineIndentMetadata = indentRulesSupport.getIndentMetadata(model.getLineContent(previousLine));
115
- if (!(previousLineIndentMetadata & (1 /* IndentConsts.INCREASE_MASK */ | 2 /* IndentConsts.DECREASE_MASK */)) &&
116
- (previousLineIndentMetadata & 4 /* IndentConsts.INDENT_NEXTLINE_MASK */)) {
117
- let stopLine = 0;
118
- for (let i = previousLine - 1; i > 0; i--) {
119
- if (processedIndentRulesSupport.shouldIndentNextLine(i)) {
120
- continue;
121
- }
122
- stopLine = i;
123
- break;
124
- }
125
- return {
126
- indentation: getLeadingWhitespace(model.getLineContent(stopLine + 1)),
127
- action: null,
128
- line: stopLine + 1
129
- };
130
- }
131
- if (honorIntentialIndent) {
132
- return {
133
- indentation: getLeadingWhitespace(model.getLineContent(precedingUnIgnoredLine)),
134
- action: null,
135
- line: precedingUnIgnoredLine
136
- };
137
- }
138
- else {
139
- // search from precedingUnIgnoredLine until we find one whose indent is not temporary
140
- for (let i = precedingUnIgnoredLine; i > 0; i--) {
141
- if (processedIndentRulesSupport.shouldIncrease(i)) {
142
- return {
143
- indentation: getLeadingWhitespace(model.getLineContent(i)),
144
- action: IndentAction.Indent,
145
- line: i
146
- };
147
- }
148
- else if (processedIndentRulesSupport.shouldIndentNextLine(i)) {
149
- let stopLine = 0;
150
- for (let j = i - 1; j > 0; j--) {
151
- if (processedIndentRulesSupport.shouldIndentNextLine(i)) {
152
- continue;
153
- }
154
- stopLine = j;
155
- break;
156
- }
157
- return {
158
- indentation: getLeadingWhitespace(model.getLineContent(stopLine + 1)),
159
- action: null,
160
- line: stopLine + 1
161
- };
162
- }
163
- else if (processedIndentRulesSupport.shouldDecrease(i)) {
164
- return {
165
- indentation: getLeadingWhitespace(model.getLineContent(i)),
166
- action: null,
167
- line: i
168
- };
169
- }
170
- }
171
- return {
172
- indentation: getLeadingWhitespace(model.getLineContent(1)),
173
- action: null,
174
- line: 1
175
- };
176
- }
177
- }
178
- }
179
- function getGoodIndentForLine(autoIndent, virtualModel, languageId, lineNumber, indentConverter, languageConfigurationService) {
180
- if (autoIndent < 4 /* EditorAutoIndentStrategy.Full */) {
181
- return null;
182
- }
183
- const richEditSupport = languageConfigurationService.getLanguageConfiguration(languageId);
184
- if (!richEditSupport) {
185
- return null;
186
- }
187
- const indentRulesSupport = languageConfigurationService.getLanguageConfiguration(languageId).indentRulesSupport;
188
- if (!indentRulesSupport) {
189
- return null;
190
- }
191
- const processedIndentRulesSupport = new ProcessedIndentRulesSupport(virtualModel, indentRulesSupport, languageConfigurationService);
192
- const indent = getInheritIndentForLine(autoIndent, virtualModel, lineNumber, undefined, languageConfigurationService);
193
- if (indent) {
194
- const inheritLine = indent.line;
195
- if (inheritLine !== undefined) {
196
- // Apply enter action as long as there are only whitespace lines between inherited line and this line.
197
- let shouldApplyEnterRules = true;
198
- for (let inBetweenLine = inheritLine; inBetweenLine < lineNumber - 1; inBetweenLine++) {
199
- if (!/^\s*$/.test(virtualModel.getLineContent(inBetweenLine))) {
200
- shouldApplyEnterRules = false;
201
- break;
202
- }
203
- }
204
- if (shouldApplyEnterRules) {
205
- const enterResult = richEditSupport.onEnter(autoIndent, '', virtualModel.getLineContent(inheritLine), '');
206
- if (enterResult) {
207
- let indentation = getLeadingWhitespace(virtualModel.getLineContent(inheritLine));
208
- if (enterResult.removeText) {
209
- indentation = indentation.substring(0, indentation.length - enterResult.removeText);
210
- }
211
- if ((enterResult.indentAction === IndentAction.Indent) ||
212
- (enterResult.indentAction === IndentAction.IndentOutdent)) {
213
- indentation = indentConverter.shiftIndent(indentation);
214
- }
215
- else if (enterResult.indentAction === IndentAction.Outdent) {
216
- indentation = indentConverter.unshiftIndent(indentation);
217
- }
218
- if (processedIndentRulesSupport.shouldDecrease(lineNumber)) {
219
- indentation = indentConverter.unshiftIndent(indentation);
220
- }
221
- if (enterResult.appendText) {
222
- indentation += enterResult.appendText;
223
- }
224
- return getLeadingWhitespace(indentation);
225
- }
226
- }
227
- }
228
- if (processedIndentRulesSupport.shouldDecrease(lineNumber)) {
229
- if (indent.action === IndentAction.Indent) {
230
- return indent.indentation;
231
- }
232
- else {
233
- return indentConverter.unshiftIndent(indent.indentation);
234
- }
235
- }
236
- else {
237
- if (indent.action === IndentAction.Indent) {
238
- return indentConverter.shiftIndent(indent.indentation);
239
- }
240
- else {
241
- return indent.indentation;
242
- }
243
- }
244
- }
245
- return null;
246
- }
247
- function getIndentForEnter(autoIndent, model, range, indentConverter, languageConfigurationService) {
248
- if (autoIndent < 4 /* EditorAutoIndentStrategy.Full */) {
249
- return null;
250
- }
251
- const languageId = model.getLanguageIdAtPosition(range.startLineNumber, range.startColumn);
252
- const indentRulesSupport = languageConfigurationService.getLanguageConfiguration(languageId).indentRulesSupport;
253
- if (!indentRulesSupport) {
254
- return null;
255
- }
256
- model.tokenization.forceTokenization(range.startLineNumber);
257
- const indentationContextProcessor = new IndentationContextProcessor(model, languageConfigurationService);
258
- const processedContextTokens = indentationContextProcessor.getProcessedTokenContextAroundRange(range);
259
- const afterEnterProcessedTokens = processedContextTokens.afterRangeProcessedTokens;
260
- const beforeEnterProcessedTokens = processedContextTokens.beforeRangeProcessedTokens;
261
- const beforeEnterIndent = getLeadingWhitespace(beforeEnterProcessedTokens.getLineContent());
262
- const virtualModel = createVirtualModelWithModifiedTokensAtLine(model, range.startLineNumber, beforeEnterProcessedTokens);
263
- const languageIsDifferentFromLineStart = isLanguageDifferentFromLineStart(model, range.getStartPosition());
264
- const currentLine = model.getLineContent(range.startLineNumber);
265
- const currentLineIndent = getLeadingWhitespace(currentLine);
266
- const afterEnterAction = getInheritIndentForLine(autoIndent, virtualModel, range.startLineNumber + 1, undefined, languageConfigurationService);
267
- if (!afterEnterAction) {
268
- const beforeEnter = languageIsDifferentFromLineStart ? currentLineIndent : beforeEnterIndent;
269
- return {
270
- beforeEnter: beforeEnter,
271
- afterEnter: beforeEnter
272
- };
273
- }
274
- let afterEnterIndent = languageIsDifferentFromLineStart ? currentLineIndent : afterEnterAction.indentation;
275
- if (afterEnterAction.action === IndentAction.Indent) {
276
- afterEnterIndent = indentConverter.shiftIndent(afterEnterIndent);
277
- }
278
- if (indentRulesSupport.shouldDecrease(afterEnterProcessedTokens.getLineContent())) {
279
- afterEnterIndent = indentConverter.unshiftIndent(afterEnterIndent);
280
- }
281
- return {
282
- beforeEnter: languageIsDifferentFromLineStart ? currentLineIndent : beforeEnterIndent,
283
- afterEnter: afterEnterIndent
284
- };
285
- }
286
- /**
287
- * We should always allow intentional indentation. It means, if users change the indentation of `lineNumber` and the content of
288
- * this line doesn't match decreaseIndentPattern, we should not adjust the indentation.
289
- */
290
- function getIndentActionForType(cursorConfig, model, range, ch, indentConverter, languageConfigurationService) {
291
- const autoIndent = cursorConfig.autoIndent;
292
- if (autoIndent < 4 /* EditorAutoIndentStrategy.Full */) {
293
- return null;
294
- }
295
- const languageIsDifferentFromLineStart = isLanguageDifferentFromLineStart(model, range.getStartPosition());
296
- if (languageIsDifferentFromLineStart) {
297
- // this line has mixed languages and indentation rules will not work
298
- return null;
299
- }
300
- const languageId = model.getLanguageIdAtPosition(range.startLineNumber, range.startColumn);
301
- const indentRulesSupport = languageConfigurationService.getLanguageConfiguration(languageId).indentRulesSupport;
302
- if (!indentRulesSupport) {
303
- return null;
304
- }
305
- const indentationContextProcessor = new IndentationContextProcessor(model, languageConfigurationService);
306
- const processedContextTokens = indentationContextProcessor.getProcessedTokenContextAroundRange(range);
307
- const beforeRangeText = processedContextTokens.beforeRangeProcessedTokens.getLineContent();
308
- const afterRangeText = processedContextTokens.afterRangeProcessedTokens.getLineContent();
309
- const textAroundRange = beforeRangeText + afterRangeText;
310
- const textAroundRangeWithCharacter = beforeRangeText + ch + afterRangeText;
311
- // If previous content already matches decreaseIndentPattern, it means indentation of this line should already be adjusted
312
- // Users might change the indentation by purpose and we should honor that instead of readjusting.
313
- if (!indentRulesSupport.shouldDecrease(textAroundRange) && indentRulesSupport.shouldDecrease(textAroundRangeWithCharacter)) {
314
- // after typing `ch`, the content matches decreaseIndentPattern, we should adjust the indent to a good manner.
315
- // 1. Get inherited indent action
316
- const r = getInheritIndentForLine(autoIndent, model, range.startLineNumber, false, languageConfigurationService);
317
- if (!r) {
318
- return null;
319
- }
320
- let indentation = r.indentation;
321
- if (r.action !== IndentAction.Indent) {
322
- indentation = indentConverter.unshiftIndent(indentation);
323
- }
324
- return indentation;
325
- }
326
- const previousLineNumber = range.startLineNumber - 1;
327
- if (previousLineNumber > 0) {
328
- const previousLine = model.getLineContent(previousLineNumber);
329
- if (indentRulesSupport.shouldIndentNextLine(previousLine) && indentRulesSupport.shouldIncrease(textAroundRangeWithCharacter)) {
330
- const inheritedIndentationData = getInheritIndentForLine(autoIndent, model, range.startLineNumber, false, languageConfigurationService);
331
- const inheritedIndentation = inheritedIndentationData?.indentation;
332
- if (inheritedIndentation !== undefined) {
333
- const currentLine = model.getLineContent(range.startLineNumber);
334
- const actualCurrentIndentation = getLeadingWhitespace(currentLine);
335
- const inferredCurrentIndentation = indentConverter.shiftIndent(inheritedIndentation);
336
- // If the inferred current indentation is not equal to the actual current indentation, then the indentation has been intentionally changed, in that case keep it
337
- const inferredIndentationEqualsActual = inferredCurrentIndentation === actualCurrentIndentation;
338
- const textAroundRangeContainsOnlyWhitespace = /^\s*$/.test(textAroundRange);
339
- const autoClosingPairs = cursorConfig.autoClosingPairs.autoClosingPairsOpenByEnd.get(ch);
340
- const autoClosingPairExists = autoClosingPairs && autoClosingPairs.length > 0;
341
- const isChFirstNonWhitespaceCharacterAndInAutoClosingPair = autoClosingPairExists && textAroundRangeContainsOnlyWhitespace;
342
- if (inferredIndentationEqualsActual && isChFirstNonWhitespaceCharacterAndInAutoClosingPair) {
343
- return inheritedIndentation;
344
- }
345
- }
346
- }
347
- }
348
- return null;
349
- }
350
- function getIndentMetadata(model, lineNumber, languageConfigurationService) {
351
- const indentRulesSupport = languageConfigurationService.getLanguageConfiguration(model.getLanguageId()).indentRulesSupport;
352
- if (!indentRulesSupport) {
353
- return null;
354
- }
355
- if (lineNumber < 1 || lineNumber > model.getLineCount()) {
356
- return null;
357
- }
358
- return indentRulesSupport.getIndentMetadata(model.getLineContent(lineNumber));
359
- }
360
- function createVirtualModelWithModifiedTokensAtLine(model, modifiedLineNumber, modifiedTokens) {
361
- const virtualModel = {
362
- tokenization: {
363
- getLineTokens: (lineNumber) => {
364
- if (lineNumber === modifiedLineNumber) {
365
- return modifiedTokens;
366
- }
367
- else {
368
- return model.tokenization.getLineTokens(lineNumber);
369
- }
370
- },
371
- getLanguageId: () => {
372
- return model.getLanguageId();
373
- },
374
- getLanguageIdAtPosition: (lineNumber, column) => {
375
- return model.getLanguageIdAtPosition(lineNumber, column);
376
- },
377
- },
378
- getLineContent: (lineNumber) => {
379
- if (lineNumber === modifiedLineNumber) {
380
- return modifiedTokens.getLineContent();
381
- }
382
- else {
383
- return model.getLineContent(lineNumber);
384
- }
385
- }
386
- };
387
- return virtualModel;
388
- }
389
-
390
- export { getGoodIndentForLine, getIndentActionForType, getIndentForEnter, getIndentMetadata, getInheritIndentForLine };
@@ -1,110 +0,0 @@
1
- import { Range } from '../../../core/range.js';
2
- import { positionToLength, lengthOfString, lengthToObj, lengthDiffNonNegative, toLength, lengthLessThanEqual, lengthAdd } from './length.js';
3
-
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Microsoft Corporation. All rights reserved.
6
- * Licensed under the MIT License. See License.txt in the project root for license information.
7
- *--------------------------------------------------------------------------------------------*/
8
- class TextEditInfo {
9
- static fromModelContentChanges(changes) {
10
- // Must be sorted in ascending order
11
- const edits = changes.map(c => {
12
- const range = Range.lift(c.range);
13
- return new TextEditInfo(positionToLength(range.getStartPosition()), positionToLength(range.getEndPosition()), lengthOfString(c.text));
14
- }).reverse();
15
- return edits;
16
- }
17
- constructor(startOffset, endOffset, newLength) {
18
- this.startOffset = startOffset;
19
- this.endOffset = endOffset;
20
- this.newLength = newLength;
21
- }
22
- toString() {
23
- return `[${lengthToObj(this.startOffset)}...${lengthToObj(this.endOffset)}) -> ${lengthToObj(this.newLength)}`;
24
- }
25
- }
26
- class BeforeEditPositionMapper {
27
- /**
28
- * @param edits Must be sorted by offset in ascending order.
29
- */
30
- constructor(edits) {
31
- this.nextEditIdx = 0;
32
- this.deltaOldToNewLineCount = 0;
33
- this.deltaOldToNewColumnCount = 0;
34
- this.deltaLineIdxInOld = -1;
35
- this.edits = edits.map(edit => TextEditInfoCache.from(edit));
36
- }
37
- /**
38
- * @param offset Must be equal to or greater than the last offset this method has been called with.
39
- */
40
- getOffsetBeforeChange(offset) {
41
- this.adjustNextEdit(offset);
42
- return this.translateCurToOld(offset);
43
- }
44
- /**
45
- * @param offset Must be equal to or greater than the last offset this method has been called with.
46
- * Returns null if there is no edit anymore.
47
- */
48
- getDistanceToNextChange(offset) {
49
- this.adjustNextEdit(offset);
50
- const nextEdit = this.edits[this.nextEditIdx];
51
- const nextChangeOffset = nextEdit ? this.translateOldToCur(nextEdit.offsetObj) : null;
52
- if (nextChangeOffset === null) {
53
- return null;
54
- }
55
- return lengthDiffNonNegative(offset, nextChangeOffset);
56
- }
57
- translateOldToCur(oldOffsetObj) {
58
- if (oldOffsetObj.lineCount === this.deltaLineIdxInOld) {
59
- return toLength(oldOffsetObj.lineCount + this.deltaOldToNewLineCount, oldOffsetObj.columnCount + this.deltaOldToNewColumnCount);
60
- }
61
- else {
62
- return toLength(oldOffsetObj.lineCount + this.deltaOldToNewLineCount, oldOffsetObj.columnCount);
63
- }
64
- }
65
- translateCurToOld(newOffset) {
66
- const offsetObj = lengthToObj(newOffset);
67
- if (offsetObj.lineCount - this.deltaOldToNewLineCount === this.deltaLineIdxInOld) {
68
- return toLength(offsetObj.lineCount - this.deltaOldToNewLineCount, offsetObj.columnCount - this.deltaOldToNewColumnCount);
69
- }
70
- else {
71
- return toLength(offsetObj.lineCount - this.deltaOldToNewLineCount, offsetObj.columnCount);
72
- }
73
- }
74
- adjustNextEdit(offset) {
75
- while (this.nextEditIdx < this.edits.length) {
76
- const nextEdit = this.edits[this.nextEditIdx];
77
- // After applying the edit, what is its end offset (considering all previous edits)?
78
- const nextEditEndOffsetInCur = this.translateOldToCur(nextEdit.endOffsetAfterObj);
79
- if (lengthLessThanEqual(nextEditEndOffsetInCur, offset)) {
80
- // We are after the edit, skip it
81
- this.nextEditIdx++;
82
- const nextEditEndOffsetInCurObj = lengthToObj(nextEditEndOffsetInCur);
83
- // Before applying the edit, what is its end offset (considering all previous edits)?
84
- const nextEditEndOffsetBeforeInCurObj = lengthToObj(this.translateOldToCur(nextEdit.endOffsetBeforeObj));
85
- const lineDelta = nextEditEndOffsetInCurObj.lineCount - nextEditEndOffsetBeforeInCurObj.lineCount;
86
- this.deltaOldToNewLineCount += lineDelta;
87
- const previousColumnDelta = this.deltaLineIdxInOld === nextEdit.endOffsetBeforeObj.lineCount ? this.deltaOldToNewColumnCount : 0;
88
- const columnDelta = nextEditEndOffsetInCurObj.columnCount - nextEditEndOffsetBeforeInCurObj.columnCount;
89
- this.deltaOldToNewColumnCount = previousColumnDelta + columnDelta;
90
- this.deltaLineIdxInOld = nextEdit.endOffsetBeforeObj.lineCount;
91
- }
92
- else {
93
- // We are in or before the edit.
94
- break;
95
- }
96
- }
97
- }
98
- }
99
- class TextEditInfoCache {
100
- static from(edit) {
101
- return new TextEditInfoCache(edit.startOffset, edit.endOffset, edit.newLength);
102
- }
103
- constructor(startOffset, endOffset, textLength) {
104
- this.endOffsetBeforeObj = lengthToObj(endOffset);
105
- this.endOffsetAfterObj = lengthToObj(lengthAdd(startOffset, textLength));
106
- this.offsetObj = lengthToObj(startOffset);
107
- }
108
- }
109
-
110
- export { BeforeEditPositionMapper, TextEditInfo };