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,205 +0,0 @@
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 };
@@ -1,269 +0,0 @@
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 };
@@ -1,9 +0,0 @@
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 };