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,205 @@
1
+ import { findLastIdxMonotonous, findLastMonotonous, findFirstMonotonous } from '../../../../base/common/arraysFind.js';
2
+ import { OffsetRange } from '../../core/ranges/offsetRange.js';
3
+ import { Position } from '../../core/position.js';
4
+ import { Range } from '../../core/range.js';
5
+ import { isSpace } from './utils.js';
6
+
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9
+ * Licensed under the MIT License. See License.txt in the project root for license information.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ class LinesSliceCharSequence {
12
+ constructor(lines, range, considerWhitespaceChanges) {
13
+ this.lines = lines;
14
+ this.range = range;
15
+ this.considerWhitespaceChanges = considerWhitespaceChanges;
16
+ this.elements = [];
17
+ this.firstElementOffsetByLineIdx = [];
18
+ this.lineStartOffsets = [];
19
+ this.trimmedWsLengthsByLineIdx = [];
20
+ this.firstElementOffsetByLineIdx.push(0);
21
+ for (let lineNumber = this.range.startLineNumber; lineNumber <= this.range.endLineNumber; lineNumber++) {
22
+ let line = lines[lineNumber - 1];
23
+ let lineStartOffset = 0;
24
+ if (lineNumber === this.range.startLineNumber && this.range.startColumn > 1) {
25
+ lineStartOffset = this.range.startColumn - 1;
26
+ line = line.substring(lineStartOffset);
27
+ }
28
+ this.lineStartOffsets.push(lineStartOffset);
29
+ let trimmedWsLength = 0;
30
+ if (!considerWhitespaceChanges) {
31
+ const trimmedStartLine = line.trimStart();
32
+ trimmedWsLength = line.length - trimmedStartLine.length;
33
+ line = trimmedStartLine.trimEnd();
34
+ }
35
+ this.trimmedWsLengthsByLineIdx.push(trimmedWsLength);
36
+ const lineLength = lineNumber === this.range.endLineNumber ? Math.min(this.range.endColumn - 1 - lineStartOffset - trimmedWsLength, line.length) : line.length;
37
+ for (let i = 0; i < lineLength; i++) {
38
+ this.elements.push(line.charCodeAt(i));
39
+ }
40
+ if (lineNumber < this.range.endLineNumber) {
41
+ this.elements.push('\n'.charCodeAt(0));
42
+ this.firstElementOffsetByLineIdx.push(this.elements.length);
43
+ }
44
+ }
45
+ }
46
+ toString() {
47
+ return `Slice: "${this.text}"`;
48
+ }
49
+ get text() {
50
+ return this.getText(new OffsetRange(0, this.length));
51
+ }
52
+ getText(range) {
53
+ return this.elements.slice(range.start, range.endExclusive).map(e => String.fromCharCode(e)).join('');
54
+ }
55
+ getElement(offset) {
56
+ return this.elements[offset];
57
+ }
58
+ get length() {
59
+ return this.elements.length;
60
+ }
61
+ getBoundaryScore(length) {
62
+ // a b c , d e f
63
+ // 11 0 0 12 15 6 13 0 0 11
64
+ const prevCategory = getCategory(length > 0 ? this.elements[length - 1] : -1);
65
+ const nextCategory = getCategory(length < this.elements.length ? this.elements[length] : -1);
66
+ if (prevCategory === 7 /* CharBoundaryCategory.LineBreakCR */ && nextCategory === 8 /* CharBoundaryCategory.LineBreakLF */) {
67
+ // don't break between \r and \n
68
+ return 0;
69
+ }
70
+ if (prevCategory === 8 /* CharBoundaryCategory.LineBreakLF */) {
71
+ // prefer the linebreak before the change
72
+ return 150;
73
+ }
74
+ let score = 0;
75
+ if (prevCategory !== nextCategory) {
76
+ score += 10;
77
+ if (prevCategory === 0 /* CharBoundaryCategory.WordLower */ && nextCategory === 1 /* CharBoundaryCategory.WordUpper */) {
78
+ score += 1;
79
+ }
80
+ }
81
+ score += getCategoryBoundaryScore(prevCategory);
82
+ score += getCategoryBoundaryScore(nextCategory);
83
+ return score;
84
+ }
85
+ translateOffset(offset, preference = 'right') {
86
+ // find smallest i, so that lineBreakOffsets[i] <= offset using binary search
87
+ const i = findLastIdxMonotonous(this.firstElementOffsetByLineIdx, (value) => value <= offset);
88
+ const lineOffset = offset - this.firstElementOffsetByLineIdx[i];
89
+ return new Position(this.range.startLineNumber + i, 1 + this.lineStartOffsets[i] + lineOffset + ((lineOffset === 0 && preference === 'left') ? 0 : this.trimmedWsLengthsByLineIdx[i]));
90
+ }
91
+ translateRange(range) {
92
+ const pos1 = this.translateOffset(range.start, 'right');
93
+ const pos2 = this.translateOffset(range.endExclusive, 'left');
94
+ if (pos2.isBefore(pos1)) {
95
+ return Range.fromPositions(pos2, pos2);
96
+ }
97
+ return Range.fromPositions(pos1, pos2);
98
+ }
99
+ /**
100
+ * Finds the word that contains the character at the given offset
101
+ */
102
+ findWordContaining(offset) {
103
+ if (offset < 0 || offset >= this.elements.length) {
104
+ return undefined;
105
+ }
106
+ if (!isWordChar(this.elements[offset])) {
107
+ return undefined;
108
+ }
109
+ // find start
110
+ let start = offset;
111
+ while (start > 0 && isWordChar(this.elements[start - 1])) {
112
+ start--;
113
+ }
114
+ // find end
115
+ let end = offset;
116
+ while (end < this.elements.length && isWordChar(this.elements[end])) {
117
+ end++;
118
+ }
119
+ return new OffsetRange(start, end);
120
+ }
121
+ /** fooBar has the two sub-words foo and bar */
122
+ findSubWordContaining(offset) {
123
+ if (offset < 0 || offset >= this.elements.length) {
124
+ return undefined;
125
+ }
126
+ if (!isWordChar(this.elements[offset])) {
127
+ return undefined;
128
+ }
129
+ // find start
130
+ let start = offset;
131
+ while (start > 0 && isWordChar(this.elements[start - 1]) && !isUpperCase(this.elements[start])) {
132
+ start--;
133
+ }
134
+ // find end
135
+ let end = offset;
136
+ while (end < this.elements.length && isWordChar(this.elements[end]) && !isUpperCase(this.elements[end])) {
137
+ end++;
138
+ }
139
+ return new OffsetRange(start, end);
140
+ }
141
+ countLinesIn(range) {
142
+ return this.translateOffset(range.endExclusive).lineNumber - this.translateOffset(range.start).lineNumber;
143
+ }
144
+ isStronglyEqual(offset1, offset2) {
145
+ return this.elements[offset1] === this.elements[offset2];
146
+ }
147
+ extendToFullLines(range) {
148
+ const start = findLastMonotonous(this.firstElementOffsetByLineIdx, x => x <= range.start) ?? 0;
149
+ const end = findFirstMonotonous(this.firstElementOffsetByLineIdx, x => range.endExclusive <= x) ?? this.elements.length;
150
+ return new OffsetRange(start, end);
151
+ }
152
+ }
153
+ function isWordChar(charCode) {
154
+ return charCode >= 97 /* CharCode.a */ && charCode <= 122 /* CharCode.z */
155
+ || charCode >= 65 /* CharCode.A */ && charCode <= 90 /* CharCode.Z */
156
+ || charCode >= 48 /* CharCode.Digit0 */ && charCode <= 57 /* CharCode.Digit9 */;
157
+ }
158
+ function isUpperCase(charCode) {
159
+ return charCode >= 65 /* CharCode.A */ && charCode <= 90 /* CharCode.Z */;
160
+ }
161
+ const score = {
162
+ [0 /* CharBoundaryCategory.WordLower */]: 0,
163
+ [1 /* CharBoundaryCategory.WordUpper */]: 0,
164
+ [2 /* CharBoundaryCategory.WordNumber */]: 0,
165
+ [3 /* CharBoundaryCategory.End */]: 10,
166
+ [4 /* CharBoundaryCategory.Other */]: 2,
167
+ [5 /* CharBoundaryCategory.Separator */]: 30,
168
+ [6 /* CharBoundaryCategory.Space */]: 3,
169
+ [7 /* CharBoundaryCategory.LineBreakCR */]: 10,
170
+ [8 /* CharBoundaryCategory.LineBreakLF */]: 10,
171
+ };
172
+ function getCategoryBoundaryScore(category) {
173
+ return score[category];
174
+ }
175
+ function getCategory(charCode) {
176
+ if (charCode === 10 /* CharCode.LineFeed */) {
177
+ return 8 /* CharBoundaryCategory.LineBreakLF */;
178
+ }
179
+ else if (charCode === 13 /* CharCode.CarriageReturn */) {
180
+ return 7 /* CharBoundaryCategory.LineBreakCR */;
181
+ }
182
+ else if (isSpace(charCode)) {
183
+ return 6 /* CharBoundaryCategory.Space */;
184
+ }
185
+ else if (charCode >= 97 /* CharCode.a */ && charCode <= 122 /* CharCode.z */) {
186
+ return 0 /* CharBoundaryCategory.WordLower */;
187
+ }
188
+ else if (charCode >= 65 /* CharCode.A */ && charCode <= 90 /* CharCode.Z */) {
189
+ return 1 /* CharBoundaryCategory.WordUpper */;
190
+ }
191
+ else if (charCode >= 48 /* CharCode.Digit0 */ && charCode <= 57 /* CharCode.Digit9 */) {
192
+ return 2 /* CharBoundaryCategory.WordNumber */;
193
+ }
194
+ else if (charCode === -1) {
195
+ return 3 /* CharBoundaryCategory.End */;
196
+ }
197
+ else if (charCode === 44 /* CharCode.Comma */ || charCode === 59 /* CharCode.Semicolon */) {
198
+ return 5 /* CharBoundaryCategory.Separator */;
199
+ }
200
+ else {
201
+ return 4 /* CharBoundaryCategory.Other */;
202
+ }
203
+ }
204
+
205
+ export { LinesSliceCharSequence };
@@ -0,0 +1,269 @@
1
+ import { CharacterClassifier } from '../core/characterClassifier.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 Uint8Matrix {
8
+ constructor(rows, cols, defaultValue) {
9
+ const data = new Uint8Array(rows * cols);
10
+ for (let i = 0, len = rows * cols; i < len; i++) {
11
+ data[i] = defaultValue;
12
+ }
13
+ this._data = data;
14
+ this.rows = rows;
15
+ this.cols = cols;
16
+ }
17
+ get(row, col) {
18
+ return this._data[row * this.cols + col];
19
+ }
20
+ set(row, col, value) {
21
+ this._data[row * this.cols + col] = value;
22
+ }
23
+ }
24
+ class StateMachine {
25
+ constructor(edges) {
26
+ let maxCharCode = 0;
27
+ let maxState = 0 /* State.Invalid */;
28
+ for (let i = 0, len = edges.length; i < len; i++) {
29
+ const [from, chCode, to] = edges[i];
30
+ if (chCode > maxCharCode) {
31
+ maxCharCode = chCode;
32
+ }
33
+ if (from > maxState) {
34
+ maxState = from;
35
+ }
36
+ if (to > maxState) {
37
+ maxState = to;
38
+ }
39
+ }
40
+ maxCharCode++;
41
+ maxState++;
42
+ const states = new Uint8Matrix(maxState, maxCharCode, 0 /* State.Invalid */);
43
+ for (let i = 0, len = edges.length; i < len; i++) {
44
+ const [from, chCode, to] = edges[i];
45
+ states.set(from, chCode, to);
46
+ }
47
+ this._states = states;
48
+ this._maxCharCode = maxCharCode;
49
+ }
50
+ nextState(currentState, chCode) {
51
+ if (chCode < 0 || chCode >= this._maxCharCode) {
52
+ return 0 /* State.Invalid */;
53
+ }
54
+ return this._states.get(currentState, chCode);
55
+ }
56
+ }
57
+ // State machine for http:// or https:// or file://
58
+ let _stateMachine = null;
59
+ function getStateMachine() {
60
+ if (_stateMachine === null) {
61
+ _stateMachine = new StateMachine([
62
+ [1 /* State.Start */, 104 /* CharCode.h */, 2 /* State.H */],
63
+ [1 /* State.Start */, 72 /* CharCode.H */, 2 /* State.H */],
64
+ [1 /* State.Start */, 102 /* CharCode.f */, 6 /* State.F */],
65
+ [1 /* State.Start */, 70 /* CharCode.F */, 6 /* State.F */],
66
+ [2 /* State.H */, 116 /* CharCode.t */, 3 /* State.HT */],
67
+ [2 /* State.H */, 84 /* CharCode.T */, 3 /* State.HT */],
68
+ [3 /* State.HT */, 116 /* CharCode.t */, 4 /* State.HTT */],
69
+ [3 /* State.HT */, 84 /* CharCode.T */, 4 /* State.HTT */],
70
+ [4 /* State.HTT */, 112 /* CharCode.p */, 5 /* State.HTTP */],
71
+ [4 /* State.HTT */, 80 /* CharCode.P */, 5 /* State.HTTP */],
72
+ [5 /* State.HTTP */, 115 /* CharCode.s */, 9 /* State.BeforeColon */],
73
+ [5 /* State.HTTP */, 83 /* CharCode.S */, 9 /* State.BeforeColon */],
74
+ [5 /* State.HTTP */, 58 /* CharCode.Colon */, 10 /* State.AfterColon */],
75
+ [6 /* State.F */, 105 /* CharCode.i */, 7 /* State.FI */],
76
+ [6 /* State.F */, 73 /* CharCode.I */, 7 /* State.FI */],
77
+ [7 /* State.FI */, 108 /* CharCode.l */, 8 /* State.FIL */],
78
+ [7 /* State.FI */, 76 /* CharCode.L */, 8 /* State.FIL */],
79
+ [8 /* State.FIL */, 101 /* CharCode.e */, 9 /* State.BeforeColon */],
80
+ [8 /* State.FIL */, 69 /* CharCode.E */, 9 /* State.BeforeColon */],
81
+ [9 /* State.BeforeColon */, 58 /* CharCode.Colon */, 10 /* State.AfterColon */],
82
+ [10 /* State.AfterColon */, 47 /* CharCode.Slash */, 11 /* State.AlmostThere */],
83
+ [11 /* State.AlmostThere */, 47 /* CharCode.Slash */, 12 /* State.End */],
84
+ ]);
85
+ }
86
+ return _stateMachine;
87
+ }
88
+ let _classifier = null;
89
+ function getClassifier() {
90
+ if (_classifier === null) {
91
+ _classifier = new CharacterClassifier(0 /* CharacterClass.None */);
92
+ // allow-any-unicode-next-line
93
+ const FORCE_TERMINATION_CHARACTERS = ' \t<>\'\"、。。、,.:;‘〈「『〔([{「」}])〕』」〉’`~…|';
94
+ for (let i = 0; i < FORCE_TERMINATION_CHARACTERS.length; i++) {
95
+ _classifier.set(FORCE_TERMINATION_CHARACTERS.charCodeAt(i), 1 /* CharacterClass.ForceTermination */);
96
+ }
97
+ const CANNOT_END_WITH_CHARACTERS = '.,;:';
98
+ for (let i = 0; i < CANNOT_END_WITH_CHARACTERS.length; i++) {
99
+ _classifier.set(CANNOT_END_WITH_CHARACTERS.charCodeAt(i), 2 /* CharacterClass.CannotEndIn */);
100
+ }
101
+ }
102
+ return _classifier;
103
+ }
104
+ class LinkComputer {
105
+ static _createLink(classifier, line, lineNumber, linkBeginIndex, linkEndIndex) {
106
+ // Do not allow to end link in certain characters...
107
+ let lastIncludedCharIndex = linkEndIndex - 1;
108
+ do {
109
+ const chCode = line.charCodeAt(lastIncludedCharIndex);
110
+ const chClass = classifier.get(chCode);
111
+ if (chClass !== 2 /* CharacterClass.CannotEndIn */) {
112
+ break;
113
+ }
114
+ lastIncludedCharIndex--;
115
+ } while (lastIncludedCharIndex > linkBeginIndex);
116
+ // Handle links enclosed in parens, square brackets and curlys.
117
+ if (linkBeginIndex > 0) {
118
+ const charCodeBeforeLink = line.charCodeAt(linkBeginIndex - 1);
119
+ const lastCharCodeInLink = line.charCodeAt(lastIncludedCharIndex);
120
+ if ((charCodeBeforeLink === 40 /* CharCode.OpenParen */ && lastCharCodeInLink === 41 /* CharCode.CloseParen */)
121
+ || (charCodeBeforeLink === 91 /* CharCode.OpenSquareBracket */ && lastCharCodeInLink === 93 /* CharCode.CloseSquareBracket */)
122
+ || (charCodeBeforeLink === 123 /* CharCode.OpenCurlyBrace */ && lastCharCodeInLink === 125 /* CharCode.CloseCurlyBrace */)) {
123
+ // Do not end in ) if ( is before the link start
124
+ // Do not end in ] if [ is before the link start
125
+ // Do not end in } if { is before the link start
126
+ lastIncludedCharIndex--;
127
+ }
128
+ }
129
+ return {
130
+ range: {
131
+ startLineNumber: lineNumber,
132
+ startColumn: linkBeginIndex + 1,
133
+ endLineNumber: lineNumber,
134
+ endColumn: lastIncludedCharIndex + 2
135
+ },
136
+ url: line.substring(linkBeginIndex, lastIncludedCharIndex + 1)
137
+ };
138
+ }
139
+ static computeLinks(model, stateMachine = getStateMachine()) {
140
+ const classifier = getClassifier();
141
+ const result = [];
142
+ for (let i = 1, lineCount = model.getLineCount(); i <= lineCount; i++) {
143
+ const line = model.getLineContent(i);
144
+ const len = line.length;
145
+ let j = 0;
146
+ let linkBeginIndex = 0;
147
+ let linkBeginChCode = 0;
148
+ let state = 1 /* State.Start */;
149
+ let hasOpenParens = false;
150
+ let hasOpenSquareBracket = false;
151
+ let inSquareBrackets = false;
152
+ let hasOpenCurlyBracket = false;
153
+ while (j < len) {
154
+ let resetStateMachine = false;
155
+ const chCode = line.charCodeAt(j);
156
+ if (state === 13 /* State.Accept */) {
157
+ let chClass;
158
+ switch (chCode) {
159
+ case 40 /* CharCode.OpenParen */:
160
+ hasOpenParens = true;
161
+ chClass = 0 /* CharacterClass.None */;
162
+ break;
163
+ case 41 /* CharCode.CloseParen */:
164
+ chClass = (hasOpenParens ? 0 /* CharacterClass.None */ : 1 /* CharacterClass.ForceTermination */);
165
+ break;
166
+ case 91 /* CharCode.OpenSquareBracket */:
167
+ inSquareBrackets = true;
168
+ hasOpenSquareBracket = true;
169
+ chClass = 0 /* CharacterClass.None */;
170
+ break;
171
+ case 93 /* CharCode.CloseSquareBracket */:
172
+ inSquareBrackets = false;
173
+ chClass = (hasOpenSquareBracket ? 0 /* CharacterClass.None */ : 1 /* CharacterClass.ForceTermination */);
174
+ break;
175
+ case 123 /* CharCode.OpenCurlyBrace */:
176
+ hasOpenCurlyBracket = true;
177
+ chClass = 0 /* CharacterClass.None */;
178
+ break;
179
+ case 125 /* CharCode.CloseCurlyBrace */:
180
+ chClass = (hasOpenCurlyBracket ? 0 /* CharacterClass.None */ : 1 /* CharacterClass.ForceTermination */);
181
+ break;
182
+ // The following three rules make it that ' or " or ` are allowed inside links
183
+ // only if the link is wrapped by some other quote character
184
+ case 39 /* CharCode.SingleQuote */:
185
+ case 34 /* CharCode.DoubleQuote */:
186
+ case 96 /* CharCode.BackTick */:
187
+ if (linkBeginChCode === chCode) {
188
+ chClass = 1 /* CharacterClass.ForceTermination */;
189
+ }
190
+ else if (linkBeginChCode === 39 /* CharCode.SingleQuote */ || linkBeginChCode === 34 /* CharCode.DoubleQuote */ || linkBeginChCode === 96 /* CharCode.BackTick */) {
191
+ chClass = 0 /* CharacterClass.None */;
192
+ }
193
+ else {
194
+ chClass = 1 /* CharacterClass.ForceTermination */;
195
+ }
196
+ break;
197
+ case 42 /* CharCode.Asterisk */:
198
+ // `*` terminates a link if the link began with `*`
199
+ chClass = (linkBeginChCode === 42 /* CharCode.Asterisk */) ? 1 /* CharacterClass.ForceTermination */ : 0 /* CharacterClass.None */;
200
+ break;
201
+ case 32 /* CharCode.Space */:
202
+ // ` ` allow space in between [ and ]
203
+ chClass = (inSquareBrackets ? 0 /* CharacterClass.None */ : 1 /* CharacterClass.ForceTermination */);
204
+ break;
205
+ default:
206
+ chClass = classifier.get(chCode);
207
+ }
208
+ // Check if character terminates link
209
+ if (chClass === 1 /* CharacterClass.ForceTermination */) {
210
+ result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, j));
211
+ resetStateMachine = true;
212
+ }
213
+ }
214
+ else if (state === 12 /* State.End */) {
215
+ let chClass;
216
+ if (chCode === 91 /* CharCode.OpenSquareBracket */) {
217
+ // Allow for the authority part to contain ipv6 addresses which contain [ and ]
218
+ hasOpenSquareBracket = true;
219
+ chClass = 0 /* CharacterClass.None */;
220
+ }
221
+ else {
222
+ chClass = classifier.get(chCode);
223
+ }
224
+ // Check if character terminates link
225
+ if (chClass === 1 /* CharacterClass.ForceTermination */) {
226
+ resetStateMachine = true;
227
+ }
228
+ else {
229
+ state = 13 /* State.Accept */;
230
+ }
231
+ }
232
+ else {
233
+ state = stateMachine.nextState(state, chCode);
234
+ if (state === 0 /* State.Invalid */) {
235
+ resetStateMachine = true;
236
+ }
237
+ }
238
+ if (resetStateMachine) {
239
+ state = 1 /* State.Start */;
240
+ hasOpenParens = false;
241
+ hasOpenSquareBracket = false;
242
+ hasOpenCurlyBracket = false;
243
+ // Record where the link started
244
+ linkBeginIndex = j + 1;
245
+ linkBeginChCode = chCode;
246
+ }
247
+ j++;
248
+ }
249
+ if (state === 13 /* State.Accept */) {
250
+ result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, len));
251
+ }
252
+ }
253
+ return result;
254
+ }
255
+ }
256
+ /**
257
+ * Returns an array of all links contains in the provided
258
+ * document. *Note* that this operation is computational
259
+ * expensive and should not run in the UI thread.
260
+ */
261
+ function computeLinks(model) {
262
+ if (!model || typeof model.getLineCount !== 'function' || typeof model.getLineContent !== 'function') {
263
+ // Unknown caller!
264
+ return [];
265
+ }
266
+ return LinkComputer.computeLinks(model);
267
+ }
268
+
269
+ export { LinkComputer, StateMachine, computeLinks };
@@ -0,0 +1,9 @@
1
+ import { createDecorator } from '../../../platform/instantiation/common/instantiation.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
+ const IMarkerDecorationsService = createDecorator('markerDecorationsService');
8
+
9
+ export { IMarkerDecorationsService };