monaco-editor11 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/assets/css.worker-C7FogG4G.js +93 -0
  2. package/dist/assets/editor.worker-iXcRX1Tq.js +26 -0
  3. package/dist/assets/html.worker-C8VxctEJ.js +470 -0
  4. package/dist/assets/json.worker-CMC9kgPL.js +58 -0
  5. package/dist/assets/ts.worker-CtTJ3hNN.js +67731 -0
  6. package/dist/index.d.ts +0 -6
  7. package/dist/monaco-editor11.es.js +49 -78
  8. package/dist/monaco-editor11.umd.js +1 -50
  9. package/dist/monaco.d.ts +8 -0
  10. package/dist/workers/common/initialize.js +16 -0
  11. package/dist/workers/common/workers.js +141 -0
  12. package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +128 -0
  13. package/dist/workers/editor/common/abstractText.js +89 -0
  14. package/dist/workers/editor/common/ast.js +485 -0
  15. package/dist/workers/editor/common/autoIndent.js +390 -0
  16. package/dist/workers/editor/common/beforeEditPositionMapper.js +110 -0
  17. package/dist/workers/editor/common/bracketPairsImpl.js +717 -0
  18. package/dist/workers/editor/common/bracketPairsTree.js +343 -0
  19. package/dist/workers/editor/common/brackets.js +108 -0
  20. package/dist/workers/editor/common/characterClassifier.js +59 -0
  21. package/dist/workers/editor/common/characterPair.js +40 -0
  22. package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +97 -0
  23. package/dist/workers/editor/common/columnRange.js +35 -0
  24. package/dist/workers/editor/common/combineTextEditInfos.js +124 -0
  25. package/dist/workers/editor/common/common.js +20 -0
  26. package/dist/workers/editor/common/computeMovedLines.js +249 -0
  27. package/dist/workers/editor/common/concat23Trees.js +192 -0
  28. package/dist/workers/editor/common/contiguousMultilineTokens.js +32 -0
  29. package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +23 -0
  30. package/dist/workers/editor/common/contiguousTokensEditing.js +128 -0
  31. package/dist/workers/editor/common/contiguousTokensStore.js +207 -0
  32. package/dist/workers/editor/common/coordinatesConverter.js +51 -0
  33. package/dist/workers/editor/common/cursor.js +899 -0
  34. package/dist/workers/editor/common/cursorAtomicMoveOperations.js +145 -0
  35. package/dist/workers/editor/common/cursorCollection.js +194 -0
  36. package/dist/workers/editor/common/cursorColumnSelection.js +93 -0
  37. package/dist/workers/editor/common/cursorColumns.js +112 -0
  38. package/dist/workers/editor/common/cursorCommon.js +250 -0
  39. package/dist/workers/editor/common/cursorContext.js +15 -0
  40. package/dist/workers/editor/common/cursorDeleteOperations.js +231 -0
  41. package/dist/workers/editor/common/cursorMoveCommands.js +676 -0
  42. package/dist/workers/editor/common/cursorMoveOperations.js +290 -0
  43. package/dist/workers/editor/common/cursorTypeEditOperations.js +968 -0
  44. package/dist/workers/editor/common/cursorTypeOperations.js +173 -0
  45. package/dist/workers/editor/common/cursorUtils.js +75 -0
  46. package/dist/workers/editor/common/cursorWordOperations.js +720 -0
  47. package/dist/workers/editor/common/defaultDocumentColorsComputer.js +138 -0
  48. package/dist/workers/editor/common/defaultLinesDiffComputer.js +188 -0
  49. package/dist/workers/editor/common/diffAlgorithm.js +139 -0
  50. package/dist/workers/editor/common/diffEditor.js +38 -0
  51. package/dist/workers/editor/common/dynamicProgrammingDiffing.js +101 -0
  52. package/dist/workers/editor/common/edit.js +183 -0
  53. package/dist/workers/editor/common/editOperation.js +36 -0
  54. package/dist/workers/editor/common/editStack.js +363 -0
  55. package/dist/workers/editor/common/editorAction.js +26 -0
  56. package/dist/workers/editor/common/editorBaseApi.js +43 -0
  57. package/dist/workers/editor/common/editorColorRegistry.js +102 -0
  58. package/dist/workers/editor/common/editorCommon.js +13 -0
  59. package/dist/workers/editor/common/editorConfigurationSchema.js +338 -0
  60. package/dist/workers/editor/common/editorContextKeys.js +84 -0
  61. package/dist/workers/editor/common/editorFeatures.js +17 -0
  62. package/dist/workers/editor/common/editorOptions.js +3440 -0
  63. package/dist/workers/editor/common/editorTheme.js +23 -0
  64. package/dist/workers/editor/common/editorWebWorker.js +299 -0
  65. package/dist/workers/editor/common/editorWorker.js +9 -0
  66. package/dist/workers/editor/common/editorWorkerHost.js +15 -0
  67. package/dist/workers/editor/common/editorZoom.js +26 -0
  68. package/dist/workers/editor/common/electricCharacter.js +55 -0
  69. package/dist/workers/editor/common/encodedTokenAttributes.js +79 -0
  70. package/dist/workers/editor/common/enterAction.js +53 -0
  71. package/dist/workers/editor/common/eolCounter.js +44 -0
  72. package/dist/workers/editor/common/findSectionHeaders.js +128 -0
  73. package/dist/workers/editor/common/fixBrackets.js +67 -0
  74. package/dist/workers/editor/common/fixedArray.js +70 -0
  75. package/dist/workers/editor/common/fontInfo.js +172 -0
  76. package/dist/workers/editor/common/fontInfoFromSettings.js +29 -0
  77. package/dist/workers/editor/common/getIconClasses.js +106 -0
  78. package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +24 -0
  79. package/dist/workers/editor/common/glyphLanesModel.js +61 -0
  80. package/dist/workers/editor/common/guidesTextModelPart.js +405 -0
  81. package/dist/workers/editor/common/heuristicSequenceOptimizations.js +374 -0
  82. package/dist/workers/editor/common/indentRules.js +63 -0
  83. package/dist/workers/editor/common/indentation.js +39 -0
  84. package/dist/workers/editor/common/indentationGuesser.js +178 -0
  85. package/dist/workers/editor/common/indentationLineProcessor.js +193 -0
  86. package/dist/workers/editor/common/inlineDecorations.js +26 -0
  87. package/dist/workers/editor/common/inplaceReplaceSupport.js +87 -0
  88. package/dist/workers/editor/common/inputMode.js +22 -0
  89. package/dist/workers/editor/common/intervalTree.js +1002 -0
  90. package/dist/workers/editor/common/language.js +9 -0
  91. package/dist/workers/editor/common/languageBracketsConfiguration.js +133 -0
  92. package/dist/workers/editor/common/languageConfiguration.js +138 -0
  93. package/dist/workers/editor/common/languageConfigurationRegistry.js +361 -0
  94. package/dist/workers/editor/common/languageFeatureDebounce.js +137 -0
  95. package/dist/workers/editor/common/languageFeatureRegistry.js +180 -0
  96. package/dist/workers/editor/common/languageFeatures.js +9 -0
  97. package/dist/workers/editor/common/languageFeaturesService.js +47 -0
  98. package/dist/workers/editor/common/languageSelector.js +112 -0
  99. package/dist/workers/editor/common/languageService.js +92 -0
  100. package/dist/workers/editor/common/languages.js +522 -0
  101. package/dist/workers/editor/common/languagesAssociations.js +193 -0
  102. package/dist/workers/editor/common/languagesRegistry.js +237 -0
  103. package/dist/workers/editor/common/legacyLinesDiffComputer.js +468 -0
  104. package/dist/workers/editor/common/length.js +129 -0
  105. package/dist/workers/editor/common/lineDecorations.js +208 -0
  106. package/dist/workers/editor/common/lineEdit.js +75 -0
  107. package/dist/workers/editor/common/lineHeights.js +370 -0
  108. package/dist/workers/editor/common/linePart.js +25 -0
  109. package/dist/workers/editor/common/lineRange.js +312 -0
  110. package/dist/workers/editor/common/lineSequence.js +36 -0
  111. package/dist/workers/editor/common/lineTokens.js +405 -0
  112. package/dist/workers/editor/common/linesDiffComputer.js +29 -0
  113. package/dist/workers/editor/common/linesDiffComputers.js +13 -0
  114. package/dist/workers/editor/common/linesLayout.js +765 -0
  115. package/dist/workers/editor/common/linesSliceCharSequence.js +205 -0
  116. package/dist/workers/editor/common/linkComputer.js +269 -0
  117. package/dist/workers/editor/common/markerDecorations.js +9 -0
  118. package/dist/workers/editor/common/markerDecorationsService.js +248 -0
  119. package/dist/workers/editor/common/minimapTokensColorTracker.js +58 -0
  120. package/dist/workers/editor/common/mirrorTextModel.js +117 -0
  121. package/dist/workers/editor/common/model.js +9 -0
  122. package/dist/workers/editor/common/modelLineProjection.js +350 -0
  123. package/dist/workers/editor/common/modelLineProjectionData.js +297 -0
  124. package/dist/workers/editor/common/modelService.js +413 -0
  125. package/dist/workers/editor/common/modesRegistry.js +75 -0
  126. package/dist/workers/editor/common/monospaceLineBreaksComputer.js +473 -0
  127. package/dist/workers/editor/common/myersDiffAlgorithm.js +159 -0
  128. package/dist/workers/editor/common/nodeReader.js +127 -0
  129. package/dist/workers/editor/common/nullTokenize.js +29 -0
  130. package/dist/workers/editor/common/offsetRange.js +225 -0
  131. package/dist/workers/editor/common/onEnter.js +109 -0
  132. package/dist/workers/editor/common/oneCursor.js +117 -0
  133. package/dist/workers/editor/common/overviewZoneManager.js +176 -0
  134. package/dist/workers/editor/common/parser.js +121 -0
  135. package/dist/workers/editor/common/pieceTreeBase.js +1473 -0
  136. package/dist/workers/editor/common/pieceTreeTextBuffer.js +461 -0
  137. package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +140 -0
  138. package/dist/workers/editor/common/point.js +50 -0
  139. package/dist/workers/editor/common/position.js +142 -0
  140. package/dist/workers/editor/common/positionToOffset.js +17 -0
  141. package/dist/workers/editor/common/positionToOffsetImpl.js +98 -0
  142. package/dist/workers/editor/common/prefixSumComputer.js +226 -0
  143. package/dist/workers/editor/common/range.js +421 -0
  144. package/dist/workers/editor/common/rangeMapping.js +229 -0
  145. package/dist/workers/editor/common/rangeSingleLine.js +17 -0
  146. package/dist/workers/editor/common/rbTreeBase.js +362 -0
  147. package/dist/workers/editor/common/rect.js +163 -0
  148. package/dist/workers/editor/common/replaceCommand.js +158 -0
  149. package/dist/workers/editor/common/resolverService.js +5 -0
  150. package/dist/workers/editor/common/rgba.js +35 -0
  151. package/dist/workers/editor/common/richEditBrackets.js +356 -0
  152. package/dist/workers/editor/common/selection.js +145 -0
  153. package/dist/workers/editor/common/semanticTokensDto.js +82 -0
  154. package/dist/workers/editor/common/semanticTokensProviderStyling.js +263 -0
  155. package/dist/workers/editor/common/semanticTokensStyling.js +9 -0
  156. package/dist/workers/editor/common/semanticTokensStylingService.js +47 -0
  157. package/dist/workers/editor/common/shiftCommand.js +241 -0
  158. package/dist/workers/editor/common/smallImmutableSet.js +108 -0
  159. package/dist/workers/editor/common/sparseMultilineTokens.js +548 -0
  160. package/dist/workers/editor/common/sparseTokensStore.js +210 -0
  161. package/dist/workers/editor/common/standaloneEnums.js +1017 -0
  162. package/dist/workers/editor/common/standaloneStrings.js +42 -0
  163. package/dist/workers/editor/common/stringBuilder.js +122 -0
  164. package/dist/workers/editor/common/stringEdit.js +165 -0
  165. package/dist/workers/editor/common/supports.js +58 -0
  166. package/dist/workers/editor/common/surroundSelectionCommand.js +44 -0
  167. package/dist/workers/editor/common/textChange.js +248 -0
  168. package/dist/workers/editor/common/textEdit.js +269 -0
  169. package/dist/workers/editor/common/textLength.js +87 -0
  170. package/dist/workers/editor/common/textModel.js +2031 -0
  171. package/dist/workers/editor/common/textModelBracketPairs.js +45 -0
  172. package/dist/workers/editor/common/textModelDefaults.js +18 -0
  173. package/dist/workers/editor/common/textModelEditSource.js +166 -0
  174. package/dist/workers/editor/common/textModelEvents.js +216 -0
  175. package/dist/workers/editor/common/textModelGuides.js +40 -0
  176. package/dist/workers/editor/common/textModelPart.js +23 -0
  177. package/dist/workers/editor/common/textModelSearch.js +455 -0
  178. package/dist/workers/editor/common/textModelStringEdit.js +11 -0
  179. package/dist/workers/editor/common/textModelSync.impl.js +307 -0
  180. package/dist/workers/editor/common/textModelText.js +26 -0
  181. package/dist/workers/editor/common/textModelTokens.js +436 -0
  182. package/dist/workers/editor/common/textResourceConfiguration.js +6 -0
  183. package/dist/workers/editor/common/textToHtmlTokenizer.js +139 -0
  184. package/dist/workers/editor/common/tokenStore.js +407 -0
  185. package/dist/workers/editor/common/tokenWithTextArray.js +73 -0
  186. package/dist/workers/editor/common/tokenization.js +287 -0
  187. package/dist/workers/editor/common/tokenizationRegistry.js +123 -0
  188. package/dist/workers/editor/common/tokenizationTextModelPart.js +275 -0
  189. package/dist/workers/editor/common/tokenizer.js +301 -0
  190. package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +261 -0
  191. package/dist/workers/editor/common/treeSitterLibraryService.js +9 -0
  192. package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +167 -0
  193. package/dist/workers/editor/common/treeSitterThemeService.js +9 -0
  194. package/dist/workers/editor/common/treeSitterTokenizationImpl.js +713 -0
  195. package/dist/workers/editor/common/treeSitterTree.js +395 -0
  196. package/dist/workers/editor/common/treeViewsDnd.js +24 -0
  197. package/dist/workers/editor/common/treeViewsDndService.js +12 -0
  198. package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +98 -0
  199. package/dist/workers/editor/common/unicodeTextModelHighlighter.js +188 -0
  200. package/dist/workers/editor/common/utils.js +62 -0
  201. package/dist/workers/editor/common/viewContext.js +22 -0
  202. package/dist/workers/editor/common/viewEventHandler.js +186 -0
  203. package/dist/workers/editor/common/viewEvents.js +180 -0
  204. package/dist/workers/editor/common/viewLayout.js +368 -0
  205. package/dist/workers/editor/common/viewLineRenderer.js +948 -0
  206. package/dist/workers/editor/common/viewLinesViewportData.js +30 -0
  207. package/dist/workers/editor/common/viewModel.js +98 -0
  208. package/dist/workers/editor/common/viewModelDecoration.js +55 -0
  209. package/dist/workers/editor/common/viewModelDecorations.js +132 -0
  210. package/dist/workers/editor/common/viewModelEventDispatcher.js +398 -0
  211. package/dist/workers/editor/common/viewModelImpl.js +1163 -0
  212. package/dist/workers/editor/common/viewModelLines.js +938 -0
  213. package/dist/workers/editor/common/wordCharacterClassifier.js +87 -0
  214. package/dist/workers/editor/common/wordHelper.js +127 -0
  215. package/dist/workers/editor/editor.worker.js +11 -0
  216. package/dist/workers/language/css.worker.js +8 -0
  217. package/dist/workers/language/cssMode.js +198 -0
  218. package/dist/workers/language/cssWorker.js +183 -0
  219. package/dist/workers/language/html.worker.js +8 -0
  220. package/dist/workers/language/htmlMode.js +213 -0
  221. package/dist/workers/language/htmlWorker.js +126 -0
  222. package/dist/workers/language/json.worker.js +8 -0
  223. package/dist/workers/language/jsonMode.js +224 -0
  224. package/dist/workers/language/jsonWorker.js +187 -0
  225. package/dist/workers/language/languageFeatures.js +1009 -0
  226. package/dist/workers/language/lib.index.js +103 -0
  227. package/dist/workers/language/lib.js +1107 -0
  228. package/dist/workers/language/lspLanguageFeatures.js +716 -0
  229. package/dist/workers/language/monaco.contribution.js +144 -0
  230. package/dist/workers/language/tokenization.js +189 -0
  231. package/dist/workers/language/ts.worker.js +14 -0
  232. package/dist/workers/language/tsMode.js +212 -0
  233. package/dist/workers/language/tsWorker.js +352 -0
  234. package/dist/workers/language/typescriptServices.js +210154 -0
  235. package/dist/workers/language/typescriptServicesMetadata.js +3 -0
  236. package/dist/workers/language/workerManager.js +65 -0
  237. package/package.json +3 -2
@@ -0,0 +1,473 @@
1
+ import { isHighSurrogate, isLowSurrogate, firstNonWhitespaceIndex, isFullWidthCharacter } from '../../../base/common/strings.js';
2
+ import { CharacterClassifier } from '../core/characterClassifier.js';
3
+ import { LineInjectedText } from '../textModelEvents.js';
4
+ import { ModelLineProjectionData } from '../modelLineProjectionData.js';
5
+
6
+ /*---------------------------------------------------------------------------------------------
7
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8
+ * Licensed under the MIT License. See License.txt in the project root for license information.
9
+ *--------------------------------------------------------------------------------------------*/
10
+ class MonospaceLineBreaksComputerFactory {
11
+ static create(options) {
12
+ return new MonospaceLineBreaksComputerFactory(options.get(151 /* EditorOption.wordWrapBreakBeforeCharacters */), options.get(150 /* EditorOption.wordWrapBreakAfterCharacters */));
13
+ }
14
+ constructor(breakBeforeChars, breakAfterChars) {
15
+ this.classifier = new WrappingCharacterClassifier(breakBeforeChars, breakAfterChars);
16
+ }
17
+ createLineBreaksComputer(fontInfo, tabSize, wrappingColumn, wrappingIndent, wordBreak, wrapOnEscapedLineFeeds) {
18
+ const requests = [];
19
+ const injectedTexts = [];
20
+ const previousBreakingData = [];
21
+ return {
22
+ addRequest: (lineText, injectedText, previousLineBreakData) => {
23
+ requests.push(lineText);
24
+ injectedTexts.push(injectedText);
25
+ previousBreakingData.push(previousLineBreakData);
26
+ },
27
+ finalize: () => {
28
+ const columnsForFullWidthChar = fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth;
29
+ const result = [];
30
+ for (let i = 0, len = requests.length; i < len; i++) {
31
+ const injectedText = injectedTexts[i];
32
+ const previousLineBreakData = previousBreakingData[i];
33
+ const lineText = requests[i];
34
+ const isLineFeedWrappingEnabled = wrapOnEscapedLineFeeds && lineText.includes('"') && lineText.includes('\\n');
35
+ if (previousLineBreakData && !previousLineBreakData.injectionOptions && !injectedText && !isLineFeedWrappingEnabled) {
36
+ result[i] = createLineBreaksFromPreviousLineBreaks(this.classifier, previousLineBreakData, lineText, tabSize, wrappingColumn, columnsForFullWidthChar, wrappingIndent, wordBreak);
37
+ }
38
+ else {
39
+ result[i] = createLineBreaks(this.classifier, lineText, injectedText, tabSize, wrappingColumn, columnsForFullWidthChar, wrappingIndent, wordBreak, isLineFeedWrappingEnabled);
40
+ }
41
+ }
42
+ arrPool1.length = 0;
43
+ arrPool2.length = 0;
44
+ return result;
45
+ }
46
+ };
47
+ }
48
+ }
49
+ class WrappingCharacterClassifier extends CharacterClassifier {
50
+ constructor(BREAK_BEFORE, BREAK_AFTER) {
51
+ super(0 /* CharacterClass.NONE */);
52
+ for (let i = 0; i < BREAK_BEFORE.length; i++) {
53
+ this.set(BREAK_BEFORE.charCodeAt(i), 1 /* CharacterClass.BREAK_BEFORE */);
54
+ }
55
+ for (let i = 0; i < BREAK_AFTER.length; i++) {
56
+ this.set(BREAK_AFTER.charCodeAt(i), 2 /* CharacterClass.BREAK_AFTER */);
57
+ }
58
+ }
59
+ get(charCode) {
60
+ if (charCode >= 0 && charCode < 256) {
61
+ return this._asciiMap[charCode];
62
+ }
63
+ else {
64
+ // Initialize CharacterClass.BREAK_IDEOGRAPHIC for these Unicode ranges:
65
+ // 1. CJK Unified Ideographs (0x4E00 -- 0x9FFF)
66
+ // 2. CJK Unified Ideographs Extension A (0x3400 -- 0x4DBF)
67
+ // 3. Hiragana and Katakana (0x3040 -- 0x30FF)
68
+ if ((charCode >= 0x3040 && charCode <= 0x30FF)
69
+ || (charCode >= 0x3400 && charCode <= 0x4DBF)
70
+ || (charCode >= 0x4E00 && charCode <= 0x9FFF)) {
71
+ return 3 /* CharacterClass.BREAK_IDEOGRAPHIC */;
72
+ }
73
+ return (this._map.get(charCode) || this._defaultValue);
74
+ }
75
+ }
76
+ }
77
+ let arrPool1 = [];
78
+ let arrPool2 = [];
79
+ function createLineBreaksFromPreviousLineBreaks(classifier, previousBreakingData, lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent, wordBreak) {
80
+ if (firstLineBreakColumn === -1) {
81
+ return null;
82
+ }
83
+ const len = lineText.length;
84
+ if (len <= 1) {
85
+ return null;
86
+ }
87
+ const isKeepAll = (wordBreak === 'keepAll');
88
+ const prevBreakingOffsets = previousBreakingData.breakOffsets;
89
+ const prevBreakingOffsetsVisibleColumn = previousBreakingData.breakOffsetsVisibleColumn;
90
+ const wrappedTextIndentLength = computeWrappedTextIndentLength(lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent);
91
+ const wrappedLineBreakColumn = firstLineBreakColumn - wrappedTextIndentLength;
92
+ const breakingOffsets = arrPool1;
93
+ const breakingOffsetsVisibleColumn = arrPool2;
94
+ let breakingOffsetsCount = 0;
95
+ let lastBreakingOffset = 0;
96
+ let lastBreakingOffsetVisibleColumn = 0;
97
+ let breakingColumn = firstLineBreakColumn;
98
+ const prevLen = prevBreakingOffsets.length;
99
+ let prevIndex = 0;
100
+ if (prevIndex >= 0) {
101
+ let bestDistance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex] - breakingColumn);
102
+ while (prevIndex + 1 < prevLen) {
103
+ const distance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex + 1] - breakingColumn);
104
+ if (distance >= bestDistance) {
105
+ break;
106
+ }
107
+ bestDistance = distance;
108
+ prevIndex++;
109
+ }
110
+ }
111
+ while (prevIndex < prevLen) {
112
+ // Allow for prevIndex to be -1 (for the case where we hit a tab when walking backwards from the first break)
113
+ let prevBreakOffset = prevIndex < 0 ? 0 : prevBreakingOffsets[prevIndex];
114
+ let prevBreakOffsetVisibleColumn = prevIndex < 0 ? 0 : prevBreakingOffsetsVisibleColumn[prevIndex];
115
+ if (lastBreakingOffset > prevBreakOffset) {
116
+ prevBreakOffset = lastBreakingOffset;
117
+ prevBreakOffsetVisibleColumn = lastBreakingOffsetVisibleColumn;
118
+ }
119
+ let breakOffset = 0;
120
+ let breakOffsetVisibleColumn = 0;
121
+ let forcedBreakOffset = 0;
122
+ let forcedBreakOffsetVisibleColumn = 0;
123
+ // initially, we search as much as possible to the right (if it fits)
124
+ if (prevBreakOffsetVisibleColumn <= breakingColumn) {
125
+ let visibleColumn = prevBreakOffsetVisibleColumn;
126
+ let prevCharCode = prevBreakOffset === 0 ? 0 /* CharCode.Null */ : lineText.charCodeAt(prevBreakOffset - 1);
127
+ let prevCharCodeClass = prevBreakOffset === 0 ? 0 /* CharacterClass.NONE */ : classifier.get(prevCharCode);
128
+ let entireLineFits = true;
129
+ for (let i = prevBreakOffset; i < len; i++) {
130
+ const charStartOffset = i;
131
+ const charCode = lineText.charCodeAt(i);
132
+ let charCodeClass;
133
+ let charWidth;
134
+ if (isHighSurrogate(charCode)) {
135
+ // A surrogate pair must always be considered as a single unit, so it is never to be broken
136
+ i++;
137
+ charCodeClass = 0 /* CharacterClass.NONE */;
138
+ charWidth = 2;
139
+ }
140
+ else {
141
+ charCodeClass = classifier.get(charCode);
142
+ charWidth = computeCharWidth(charCode, visibleColumn, tabSize, columnsForFullWidthChar);
143
+ }
144
+ if (charStartOffset > lastBreakingOffset && canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass, isKeepAll)) {
145
+ breakOffset = charStartOffset;
146
+ breakOffsetVisibleColumn = visibleColumn;
147
+ }
148
+ visibleColumn += charWidth;
149
+ // check if adding character at `i` will go over the breaking column
150
+ if (visibleColumn > breakingColumn) {
151
+ // We need to break at least before character at `i`:
152
+ if (charStartOffset > lastBreakingOffset) {
153
+ forcedBreakOffset = charStartOffset;
154
+ forcedBreakOffsetVisibleColumn = visibleColumn - charWidth;
155
+ }
156
+ else {
157
+ // we need to advance at least by one character
158
+ forcedBreakOffset = i + 1;
159
+ forcedBreakOffsetVisibleColumn = visibleColumn;
160
+ }
161
+ if (visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakColumn) {
162
+ // Cannot break at `breakOffset` => reset it if it was set
163
+ breakOffset = 0;
164
+ }
165
+ entireLineFits = false;
166
+ break;
167
+ }
168
+ prevCharCode = charCode;
169
+ prevCharCodeClass = charCodeClass;
170
+ }
171
+ if (entireLineFits) {
172
+ // there is no more need to break => stop the outer loop!
173
+ if (breakingOffsetsCount > 0) {
174
+ // Add last segment, no need to assign to `lastBreakingOffset` and `lastBreakingOffsetVisibleColumn`
175
+ breakingOffsets[breakingOffsetsCount] = prevBreakingOffsets[prevBreakingOffsets.length - 1];
176
+ breakingOffsetsVisibleColumn[breakingOffsetsCount] = prevBreakingOffsetsVisibleColumn[prevBreakingOffsets.length - 1];
177
+ breakingOffsetsCount++;
178
+ }
179
+ break;
180
+ }
181
+ }
182
+ if (breakOffset === 0) {
183
+ // must search left
184
+ let visibleColumn = prevBreakOffsetVisibleColumn;
185
+ let charCode = lineText.charCodeAt(prevBreakOffset);
186
+ let charCodeClass = classifier.get(charCode);
187
+ let hitATabCharacter = false;
188
+ for (let i = prevBreakOffset - 1; i >= lastBreakingOffset; i--) {
189
+ const charStartOffset = i + 1;
190
+ const prevCharCode = lineText.charCodeAt(i);
191
+ if (prevCharCode === 9 /* CharCode.Tab */) {
192
+ // cannot determine the width of a tab when going backwards, so we must go forwards
193
+ hitATabCharacter = true;
194
+ break;
195
+ }
196
+ let prevCharCodeClass;
197
+ let prevCharWidth;
198
+ if (isLowSurrogate(prevCharCode)) {
199
+ // A surrogate pair must always be considered as a single unit, so it is never to be broken
200
+ i--;
201
+ prevCharCodeClass = 0 /* CharacterClass.NONE */;
202
+ prevCharWidth = 2;
203
+ }
204
+ else {
205
+ prevCharCodeClass = classifier.get(prevCharCode);
206
+ prevCharWidth = (isFullWidthCharacter(prevCharCode) ? columnsForFullWidthChar : 1);
207
+ }
208
+ if (visibleColumn <= breakingColumn) {
209
+ if (forcedBreakOffset === 0) {
210
+ forcedBreakOffset = charStartOffset;
211
+ forcedBreakOffsetVisibleColumn = visibleColumn;
212
+ }
213
+ if (visibleColumn <= breakingColumn - wrappedLineBreakColumn) {
214
+ // went too far!
215
+ break;
216
+ }
217
+ if (canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass, isKeepAll)) {
218
+ breakOffset = charStartOffset;
219
+ breakOffsetVisibleColumn = visibleColumn;
220
+ break;
221
+ }
222
+ }
223
+ visibleColumn -= prevCharWidth;
224
+ charCode = prevCharCode;
225
+ charCodeClass = prevCharCodeClass;
226
+ }
227
+ if (breakOffset !== 0) {
228
+ const remainingWidthOfNextLine = wrappedLineBreakColumn - (forcedBreakOffsetVisibleColumn - breakOffsetVisibleColumn);
229
+ if (remainingWidthOfNextLine <= tabSize) {
230
+ const charCodeAtForcedBreakOffset = lineText.charCodeAt(forcedBreakOffset);
231
+ let charWidth;
232
+ if (isHighSurrogate(charCodeAtForcedBreakOffset)) {
233
+ // A surrogate pair must always be considered as a single unit, so it is never to be broken
234
+ charWidth = 2;
235
+ }
236
+ else {
237
+ charWidth = computeCharWidth(charCodeAtForcedBreakOffset, forcedBreakOffsetVisibleColumn, tabSize, columnsForFullWidthChar);
238
+ }
239
+ if (remainingWidthOfNextLine - charWidth < 0) {
240
+ // it is not worth it to break at breakOffset, it just introduces an extra needless line!
241
+ breakOffset = 0;
242
+ }
243
+ }
244
+ }
245
+ if (hitATabCharacter) {
246
+ // cannot determine the width of a tab when going backwards, so we must go forwards from the previous break
247
+ prevIndex--;
248
+ continue;
249
+ }
250
+ }
251
+ if (breakOffset === 0) {
252
+ // Could not find a good breaking point
253
+ breakOffset = forcedBreakOffset;
254
+ breakOffsetVisibleColumn = forcedBreakOffsetVisibleColumn;
255
+ }
256
+ if (breakOffset <= lastBreakingOffset) {
257
+ // Make sure that we are advancing (at least one character)
258
+ const charCode = lineText.charCodeAt(lastBreakingOffset);
259
+ if (isHighSurrogate(charCode)) {
260
+ // A surrogate pair must always be considered as a single unit, so it is never to be broken
261
+ breakOffset = lastBreakingOffset + 2;
262
+ breakOffsetVisibleColumn = lastBreakingOffsetVisibleColumn + 2;
263
+ }
264
+ else {
265
+ breakOffset = lastBreakingOffset + 1;
266
+ breakOffsetVisibleColumn = lastBreakingOffsetVisibleColumn + computeCharWidth(charCode, lastBreakingOffsetVisibleColumn, tabSize, columnsForFullWidthChar);
267
+ }
268
+ }
269
+ lastBreakingOffset = breakOffset;
270
+ breakingOffsets[breakingOffsetsCount] = breakOffset;
271
+ lastBreakingOffsetVisibleColumn = breakOffsetVisibleColumn;
272
+ breakingOffsetsVisibleColumn[breakingOffsetsCount] = breakOffsetVisibleColumn;
273
+ breakingOffsetsCount++;
274
+ breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakColumn;
275
+ while (prevIndex < 0 || (prevIndex < prevLen && prevBreakingOffsetsVisibleColumn[prevIndex] < breakOffsetVisibleColumn)) {
276
+ prevIndex++;
277
+ }
278
+ let bestDistance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex] - breakingColumn);
279
+ while (prevIndex + 1 < prevLen) {
280
+ const distance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex + 1] - breakingColumn);
281
+ if (distance >= bestDistance) {
282
+ break;
283
+ }
284
+ bestDistance = distance;
285
+ prevIndex++;
286
+ }
287
+ }
288
+ if (breakingOffsetsCount === 0) {
289
+ return null;
290
+ }
291
+ // Doing here some object reuse which ends up helping a huge deal with GC pauses!
292
+ breakingOffsets.length = breakingOffsetsCount;
293
+ breakingOffsetsVisibleColumn.length = breakingOffsetsCount;
294
+ arrPool1 = previousBreakingData.breakOffsets;
295
+ arrPool2 = previousBreakingData.breakOffsetsVisibleColumn;
296
+ previousBreakingData.breakOffsets = breakingOffsets;
297
+ previousBreakingData.breakOffsetsVisibleColumn = breakingOffsetsVisibleColumn;
298
+ previousBreakingData.wrappedTextIndentLength = wrappedTextIndentLength;
299
+ return previousBreakingData;
300
+ }
301
+ function createLineBreaks(classifier, _lineText, injectedTexts, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent, wordBreak, wrapOnEscapedLineFeeds) {
302
+ const lineText = LineInjectedText.applyInjectedText(_lineText, injectedTexts);
303
+ let injectionOptions;
304
+ let injectionOffsets;
305
+ if (injectedTexts && injectedTexts.length > 0) {
306
+ injectionOptions = injectedTexts.map(t => t.options);
307
+ injectionOffsets = injectedTexts.map(text => text.column - 1);
308
+ }
309
+ else {
310
+ injectionOptions = null;
311
+ injectionOffsets = null;
312
+ }
313
+ if (firstLineBreakColumn === -1) {
314
+ if (!injectionOptions) {
315
+ return null;
316
+ }
317
+ // creating a `LineBreakData` with an invalid `breakOffsetsVisibleColumn` is OK
318
+ // because `breakOffsetsVisibleColumn` will never be used because it contains injected text
319
+ return new ModelLineProjectionData(injectionOffsets, injectionOptions, [lineText.length], [], 0);
320
+ }
321
+ const len = lineText.length;
322
+ if (len <= 1) {
323
+ if (!injectionOptions) {
324
+ return null;
325
+ }
326
+ // creating a `LineBreakData` with an invalid `breakOffsetsVisibleColumn` is OK
327
+ // because `breakOffsetsVisibleColumn` will never be used because it contains injected text
328
+ return new ModelLineProjectionData(injectionOffsets, injectionOptions, [lineText.length], [], 0);
329
+ }
330
+ const isKeepAll = (wordBreak === 'keepAll');
331
+ const wrappedTextIndentLength = computeWrappedTextIndentLength(lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent);
332
+ const wrappedLineBreakColumn = firstLineBreakColumn - wrappedTextIndentLength;
333
+ const breakingOffsets = [];
334
+ const breakingOffsetsVisibleColumn = [];
335
+ let breakingOffsetsCount = 0;
336
+ let breakOffset = 0;
337
+ let breakOffsetVisibleColumn = 0;
338
+ let breakingColumn = firstLineBreakColumn;
339
+ let prevCharCode = lineText.charCodeAt(0);
340
+ let prevCharCodeClass = classifier.get(prevCharCode);
341
+ let visibleColumn = computeCharWidth(prevCharCode, 0, tabSize, columnsForFullWidthChar);
342
+ let startOffset = 1;
343
+ if (isHighSurrogate(prevCharCode)) {
344
+ // A surrogate pair must always be considered as a single unit, so it is never to be broken
345
+ visibleColumn += 1;
346
+ prevCharCode = lineText.charCodeAt(1);
347
+ prevCharCodeClass = classifier.get(prevCharCode);
348
+ startOffset++;
349
+ }
350
+ for (let i = startOffset; i < len; i++) {
351
+ const charStartOffset = i;
352
+ const charCode = lineText.charCodeAt(i);
353
+ let charCodeClass;
354
+ let charWidth;
355
+ let wrapEscapedLineFeed = false;
356
+ if (isHighSurrogate(charCode)) {
357
+ // A surrogate pair must always be considered as a single unit, so it is never to be broken
358
+ i++;
359
+ charCodeClass = 0 /* CharacterClass.NONE */;
360
+ charWidth = 2;
361
+ }
362
+ else {
363
+ charCodeClass = classifier.get(charCode);
364
+ charWidth = computeCharWidth(charCode, visibleColumn, tabSize, columnsForFullWidthChar);
365
+ }
366
+ // literal \n shall trigger a softwrap
367
+ if (wrapOnEscapedLineFeeds && isEscapedLineBreakAtPosition(lineText, i)) {
368
+ breakOffset = charStartOffset;
369
+ breakOffsetVisibleColumn = visibleColumn;
370
+ wrapEscapedLineFeed = true;
371
+ }
372
+ else if (canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass, isKeepAll)) {
373
+ breakOffset = charStartOffset;
374
+ breakOffsetVisibleColumn = visibleColumn;
375
+ }
376
+ visibleColumn += charWidth;
377
+ // check if adding character at `i` will go over the breaking column
378
+ if (visibleColumn > breakingColumn || wrapEscapedLineFeed) {
379
+ // We need to break at least before character at `i`:
380
+ if (breakOffset === 0 || visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakColumn) {
381
+ // Cannot break at `breakOffset`, must break at `i`
382
+ breakOffset = charStartOffset;
383
+ breakOffsetVisibleColumn = visibleColumn - charWidth;
384
+ }
385
+ breakingOffsets[breakingOffsetsCount] = breakOffset;
386
+ breakingOffsetsVisibleColumn[breakingOffsetsCount] = breakOffsetVisibleColumn;
387
+ breakingOffsetsCount++;
388
+ breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakColumn;
389
+ breakOffset = 0;
390
+ }
391
+ prevCharCode = charCode;
392
+ prevCharCodeClass = charCodeClass;
393
+ }
394
+ if (breakingOffsetsCount === 0 && (!injectedTexts || injectedTexts.length === 0)) {
395
+ return null;
396
+ }
397
+ // Add last segment
398
+ breakingOffsets[breakingOffsetsCount] = len;
399
+ breakingOffsetsVisibleColumn[breakingOffsetsCount] = visibleColumn;
400
+ return new ModelLineProjectionData(injectionOffsets, injectionOptions, breakingOffsets, breakingOffsetsVisibleColumn, wrappedTextIndentLength);
401
+ }
402
+ function computeCharWidth(charCode, visibleColumn, tabSize, columnsForFullWidthChar) {
403
+ if (charCode === 9 /* CharCode.Tab */) {
404
+ return (tabSize - (visibleColumn % tabSize));
405
+ }
406
+ if (isFullWidthCharacter(charCode)) {
407
+ return columnsForFullWidthChar;
408
+ }
409
+ if (charCode < 32) {
410
+ // when using `editor.renderControlCharacters`, the substitutions are often wide
411
+ return columnsForFullWidthChar;
412
+ }
413
+ return 1;
414
+ }
415
+ function tabCharacterWidth(visibleColumn, tabSize) {
416
+ return (tabSize - (visibleColumn % tabSize));
417
+ }
418
+ /**
419
+ * Checks if the current position in the text should trigger a soft wrap due to escaped line feeds.
420
+ * This handles the wrapOnEscapedLineFeeds feature which allows \n sequences in strings to trigger wrapping.
421
+ */
422
+ function isEscapedLineBreakAtPosition(lineText, i) {
423
+ if (i >= 2 && lineText.charAt(i - 1) === 'n') {
424
+ // Check if there's an odd number of backslashes
425
+ let escapeCount = 0;
426
+ for (let j = i - 2; j >= 0; j--) {
427
+ if (lineText.charAt(j) === '\\') {
428
+ escapeCount++;
429
+ }
430
+ else {
431
+ return escapeCount % 2 === 1;
432
+ }
433
+ }
434
+ }
435
+ return false;
436
+ }
437
+ /**
438
+ * Kinsoku Shori : Don't break after a leading character, like an open bracket
439
+ * Kinsoku Shori : Don't break before a trailing character, like a period
440
+ */
441
+ function canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass, isKeepAll) {
442
+ return (charCode !== 32 /* CharCode.Space */
443
+ && ((prevCharCodeClass === 2 /* CharacterClass.BREAK_AFTER */ && charCodeClass !== 2 /* CharacterClass.BREAK_AFTER */) // break at the end of multiple BREAK_AFTER
444
+ || (prevCharCodeClass !== 1 /* CharacterClass.BREAK_BEFORE */ && charCodeClass === 1 /* CharacterClass.BREAK_BEFORE */) // break at the start of multiple BREAK_BEFORE
445
+ || (!isKeepAll && prevCharCodeClass === 3 /* CharacterClass.BREAK_IDEOGRAPHIC */ && charCodeClass !== 2 /* CharacterClass.BREAK_AFTER */)
446
+ || (!isKeepAll && charCodeClass === 3 /* CharacterClass.BREAK_IDEOGRAPHIC */ && prevCharCodeClass !== 1 /* CharacterClass.BREAK_BEFORE */)));
447
+ }
448
+ function computeWrappedTextIndentLength(lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent) {
449
+ let wrappedTextIndentLength = 0;
450
+ if (wrappingIndent !== 0 /* WrappingIndent.None */) {
451
+ const firstNonWhitespaceIndex$1 = firstNonWhitespaceIndex(lineText);
452
+ if (firstNonWhitespaceIndex$1 !== -1) {
453
+ // Track existing indent
454
+ for (let i = 0; i < firstNonWhitespaceIndex$1; i++) {
455
+ const charWidth = (lineText.charCodeAt(i) === 9 /* CharCode.Tab */ ? tabCharacterWidth(wrappedTextIndentLength, tabSize) : 1);
456
+ wrappedTextIndentLength += charWidth;
457
+ }
458
+ // Increase indent of continuation lines, if desired
459
+ const numberOfAdditionalTabs = (wrappingIndent === 3 /* WrappingIndent.DeepIndent */ ? 2 : wrappingIndent === 2 /* WrappingIndent.Indent */ ? 1 : 0);
460
+ for (let i = 0; i < numberOfAdditionalTabs; i++) {
461
+ const charWidth = tabCharacterWidth(wrappedTextIndentLength, tabSize);
462
+ wrappedTextIndentLength += charWidth;
463
+ }
464
+ // Force sticking to beginning of line if no character would fit except for the indentation
465
+ if (wrappedTextIndentLength + columnsForFullWidthChar > firstLineBreakColumn) {
466
+ wrappedTextIndentLength = 0;
467
+ }
468
+ }
469
+ }
470
+ return wrappedTextIndentLength;
471
+ }
472
+
473
+ export { MonospaceLineBreaksComputerFactory };
@@ -0,0 +1,159 @@
1
+ import { OffsetRange } from '../../../core/ranges/offsetRange.js';
2
+ import { InfiniteTimeout, DiffAlgorithmResult, SequenceDiff } from './diffAlgorithm.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
+ /**
9
+ * An O(ND) diff algorithm that has a quadratic space worst-case complexity.
10
+ */
11
+ class MyersDiffAlgorithm {
12
+ compute(seq1, seq2, timeout = InfiniteTimeout.instance) {
13
+ // These are common special cases.
14
+ // The early return improves performance dramatically.
15
+ if (seq1.length === 0 || seq2.length === 0) {
16
+ return DiffAlgorithmResult.trivial(seq1, seq2);
17
+ }
18
+ const seqX = seq1; // Text on the x axis
19
+ const seqY = seq2; // Text on the y axis
20
+ function getXAfterSnake(x, y) {
21
+ while (x < seqX.length && y < seqY.length && seqX.getElement(x) === seqY.getElement(y)) {
22
+ x++;
23
+ y++;
24
+ }
25
+ return x;
26
+ }
27
+ let d = 0;
28
+ // V[k]: X value of longest d-line that ends in diagonal k.
29
+ // d-line: path from (0,0) to (x,y) that uses exactly d non-diagonals.
30
+ // diagonal k: Set of points (x,y) with x-y = k.
31
+ // k=1 -> (1,0),(2,1)
32
+ const V = new FastInt32Array();
33
+ V.set(0, getXAfterSnake(0, 0));
34
+ const paths = new FastArrayNegativeIndices();
35
+ paths.set(0, V.get(0) === 0 ? null : new SnakePath(null, 0, 0, V.get(0)));
36
+ let k = 0;
37
+ loop: while (true) {
38
+ d++;
39
+ if (!timeout.isValid()) {
40
+ return DiffAlgorithmResult.trivialTimedOut(seqX, seqY);
41
+ }
42
+ // The paper has `for (k = -d; k <= d; k += 2)`, but we can ignore diagonals that cannot influence the result.
43
+ const lowerBound = -Math.min(d, seqY.length + (d % 2));
44
+ const upperBound = Math.min(d, seqX.length + (d % 2));
45
+ for (k = lowerBound; k <= upperBound; k += 2) {
46
+ // We can use the X values of (d-1)-lines to compute X value of the longest d-lines.
47
+ const maxXofDLineTop = k === upperBound ? -1 : V.get(k + 1); // We take a vertical non-diagonal (add a symbol in seqX)
48
+ const maxXofDLineLeft = k === lowerBound ? -1 : V.get(k - 1) + 1; // We take a horizontal non-diagonal (+1 x) (delete a symbol in seqX)
49
+ const x = Math.min(Math.max(maxXofDLineTop, maxXofDLineLeft), seqX.length);
50
+ const y = x - k;
51
+ if (x > seqX.length || y > seqY.length) {
52
+ // This diagonal is irrelevant for the result.
53
+ // TODO: Don't pay the cost for this in the next iteration.
54
+ continue;
55
+ }
56
+ const newMaxX = getXAfterSnake(x, y);
57
+ V.set(k, newMaxX);
58
+ const lastPath = x === maxXofDLineTop ? paths.get(k + 1) : paths.get(k - 1);
59
+ paths.set(k, newMaxX !== x ? new SnakePath(lastPath, x, y, newMaxX - x) : lastPath);
60
+ if (V.get(k) === seqX.length && V.get(k) - k === seqY.length) {
61
+ break loop;
62
+ }
63
+ }
64
+ }
65
+ let path = paths.get(k);
66
+ const result = [];
67
+ let lastAligningPosS1 = seqX.length;
68
+ let lastAligningPosS2 = seqY.length;
69
+ while (true) {
70
+ const endX = path ? path.x + path.length : 0;
71
+ const endY = path ? path.y + path.length : 0;
72
+ if (endX !== lastAligningPosS1 || endY !== lastAligningPosS2) {
73
+ result.push(new SequenceDiff(new OffsetRange(endX, lastAligningPosS1), new OffsetRange(endY, lastAligningPosS2)));
74
+ }
75
+ if (!path) {
76
+ break;
77
+ }
78
+ lastAligningPosS1 = path.x;
79
+ lastAligningPosS2 = path.y;
80
+ path = path.prev;
81
+ }
82
+ result.reverse();
83
+ return new DiffAlgorithmResult(result, false);
84
+ }
85
+ }
86
+ class SnakePath {
87
+ constructor(prev, x, y, length) {
88
+ this.prev = prev;
89
+ this.x = x;
90
+ this.y = y;
91
+ this.length = length;
92
+ }
93
+ }
94
+ /**
95
+ * An array that supports fast negative indices.
96
+ */
97
+ class FastInt32Array {
98
+ constructor() {
99
+ this.positiveArr = new Int32Array(10);
100
+ this.negativeArr = new Int32Array(10);
101
+ }
102
+ get(idx) {
103
+ if (idx < 0) {
104
+ idx = -idx - 1;
105
+ return this.negativeArr[idx];
106
+ }
107
+ else {
108
+ return this.positiveArr[idx];
109
+ }
110
+ }
111
+ set(idx, value) {
112
+ if (idx < 0) {
113
+ idx = -idx - 1;
114
+ if (idx >= this.negativeArr.length) {
115
+ const arr = this.negativeArr;
116
+ this.negativeArr = new Int32Array(arr.length * 2);
117
+ this.negativeArr.set(arr);
118
+ }
119
+ this.negativeArr[idx] = value;
120
+ }
121
+ else {
122
+ if (idx >= this.positiveArr.length) {
123
+ const arr = this.positiveArr;
124
+ this.positiveArr = new Int32Array(arr.length * 2);
125
+ this.positiveArr.set(arr);
126
+ }
127
+ this.positiveArr[idx] = value;
128
+ }
129
+ }
130
+ }
131
+ /**
132
+ * An array that supports fast negative indices.
133
+ */
134
+ class FastArrayNegativeIndices {
135
+ constructor() {
136
+ this.positiveArr = [];
137
+ this.negativeArr = [];
138
+ }
139
+ get(idx) {
140
+ if (idx < 0) {
141
+ idx = -idx - 1;
142
+ return this.negativeArr[idx];
143
+ }
144
+ else {
145
+ return this.positiveArr[idx];
146
+ }
147
+ }
148
+ set(idx, value) {
149
+ if (idx < 0) {
150
+ idx = -idx - 1;
151
+ this.negativeArr[idx] = value;
152
+ }
153
+ else {
154
+ this.positiveArr[idx] = value;
155
+ }
156
+ }
157
+ }
158
+
159
+ export { MyersDiffAlgorithm };