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.
- package/dist/index.d.ts +1 -1
- package/dist/monaco-editor11.es.js +11 -16
- package/dist/monaco-editor11.umd.js +1 -1
- package/package.json +2 -2
- package/dist/monaco.d.ts +0 -8
- package/dist/workers/common/initialize.js +0 -16
- package/dist/workers/common/workers.js +0 -141
- package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +0 -128
- package/dist/workers/editor/common/abstractText.js +0 -89
- package/dist/workers/editor/common/ast.js +0 -485
- package/dist/workers/editor/common/autoIndent.js +0 -390
- package/dist/workers/editor/common/beforeEditPositionMapper.js +0 -110
- package/dist/workers/editor/common/bracketPairsImpl.js +0 -717
- package/dist/workers/editor/common/bracketPairsTree.js +0 -343
- package/dist/workers/editor/common/brackets.js +0 -108
- package/dist/workers/editor/common/characterClassifier.js +0 -59
- package/dist/workers/editor/common/characterPair.js +0 -40
- package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +0 -97
- package/dist/workers/editor/common/columnRange.js +0 -35
- package/dist/workers/editor/common/combineTextEditInfos.js +0 -124
- package/dist/workers/editor/common/common.js +0 -20
- package/dist/workers/editor/common/computeMovedLines.js +0 -249
- package/dist/workers/editor/common/concat23Trees.js +0 -192
- package/dist/workers/editor/common/contiguousMultilineTokens.js +0 -32
- package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +0 -23
- package/dist/workers/editor/common/contiguousTokensEditing.js +0 -128
- package/dist/workers/editor/common/contiguousTokensStore.js +0 -207
- package/dist/workers/editor/common/coordinatesConverter.js +0 -51
- package/dist/workers/editor/common/cursor.js +0 -899
- package/dist/workers/editor/common/cursorAtomicMoveOperations.js +0 -145
- package/dist/workers/editor/common/cursorCollection.js +0 -194
- package/dist/workers/editor/common/cursorColumnSelection.js +0 -93
- package/dist/workers/editor/common/cursorColumns.js +0 -112
- package/dist/workers/editor/common/cursorCommon.js +0 -250
- package/dist/workers/editor/common/cursorContext.js +0 -15
- package/dist/workers/editor/common/cursorDeleteOperations.js +0 -231
- package/dist/workers/editor/common/cursorMoveCommands.js +0 -676
- package/dist/workers/editor/common/cursorMoveOperations.js +0 -290
- package/dist/workers/editor/common/cursorTypeEditOperations.js +0 -968
- package/dist/workers/editor/common/cursorTypeOperations.js +0 -173
- package/dist/workers/editor/common/cursorUtils.js +0 -75
- package/dist/workers/editor/common/cursorWordOperations.js +0 -720
- package/dist/workers/editor/common/defaultDocumentColorsComputer.js +0 -138
- package/dist/workers/editor/common/defaultLinesDiffComputer.js +0 -188
- package/dist/workers/editor/common/diffAlgorithm.js +0 -139
- package/dist/workers/editor/common/diffEditor.js +0 -38
- package/dist/workers/editor/common/dynamicProgrammingDiffing.js +0 -101
- package/dist/workers/editor/common/edit.js +0 -183
- package/dist/workers/editor/common/editOperation.js +0 -36
- package/dist/workers/editor/common/editStack.js +0 -363
- package/dist/workers/editor/common/editorAction.js +0 -26
- package/dist/workers/editor/common/editorBaseApi.js +0 -43
- package/dist/workers/editor/common/editorColorRegistry.js +0 -102
- package/dist/workers/editor/common/editorCommon.js +0 -13
- package/dist/workers/editor/common/editorConfigurationSchema.js +0 -338
- package/dist/workers/editor/common/editorContextKeys.js +0 -84
- package/dist/workers/editor/common/editorFeatures.js +0 -17
- package/dist/workers/editor/common/editorOptions.js +0 -3440
- package/dist/workers/editor/common/editorTheme.js +0 -23
- package/dist/workers/editor/common/editorWebWorker.js +0 -299
- package/dist/workers/editor/common/editorWorker.js +0 -9
- package/dist/workers/editor/common/editorWorkerHost.js +0 -15
- package/dist/workers/editor/common/editorZoom.js +0 -26
- package/dist/workers/editor/common/electricCharacter.js +0 -55
- package/dist/workers/editor/common/encodedTokenAttributes.js +0 -79
- package/dist/workers/editor/common/enterAction.js +0 -53
- package/dist/workers/editor/common/eolCounter.js +0 -44
- package/dist/workers/editor/common/findSectionHeaders.js +0 -128
- package/dist/workers/editor/common/fixBrackets.js +0 -67
- package/dist/workers/editor/common/fixedArray.js +0 -70
- package/dist/workers/editor/common/fontInfo.js +0 -172
- package/dist/workers/editor/common/fontInfoFromSettings.js +0 -29
- package/dist/workers/editor/common/getIconClasses.js +0 -106
- package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +0 -24
- package/dist/workers/editor/common/glyphLanesModel.js +0 -61
- package/dist/workers/editor/common/guidesTextModelPart.js +0 -405
- package/dist/workers/editor/common/heuristicSequenceOptimizations.js +0 -374
- package/dist/workers/editor/common/indentRules.js +0 -63
- package/dist/workers/editor/common/indentation.js +0 -39
- package/dist/workers/editor/common/indentationGuesser.js +0 -178
- package/dist/workers/editor/common/indentationLineProcessor.js +0 -193
- package/dist/workers/editor/common/inlineDecorations.js +0 -26
- package/dist/workers/editor/common/inplaceReplaceSupport.js +0 -87
- package/dist/workers/editor/common/inputMode.js +0 -22
- package/dist/workers/editor/common/intervalTree.js +0 -1002
- package/dist/workers/editor/common/language.js +0 -9
- package/dist/workers/editor/common/languageBracketsConfiguration.js +0 -133
- package/dist/workers/editor/common/languageConfiguration.js +0 -138
- package/dist/workers/editor/common/languageConfigurationRegistry.js +0 -361
- package/dist/workers/editor/common/languageFeatureDebounce.js +0 -137
- package/dist/workers/editor/common/languageFeatureRegistry.js +0 -180
- package/dist/workers/editor/common/languageFeatures.js +0 -9
- package/dist/workers/editor/common/languageFeaturesService.js +0 -47
- package/dist/workers/editor/common/languageSelector.js +0 -112
- package/dist/workers/editor/common/languageService.js +0 -92
- package/dist/workers/editor/common/languages.js +0 -522
- package/dist/workers/editor/common/languagesAssociations.js +0 -193
- package/dist/workers/editor/common/languagesRegistry.js +0 -237
- package/dist/workers/editor/common/legacyLinesDiffComputer.js +0 -468
- package/dist/workers/editor/common/length.js +0 -129
- package/dist/workers/editor/common/lineDecorations.js +0 -208
- package/dist/workers/editor/common/lineEdit.js +0 -75
- package/dist/workers/editor/common/lineHeights.js +0 -370
- package/dist/workers/editor/common/linePart.js +0 -25
- package/dist/workers/editor/common/lineRange.js +0 -312
- package/dist/workers/editor/common/lineSequence.js +0 -36
- package/dist/workers/editor/common/lineTokens.js +0 -405
- package/dist/workers/editor/common/linesDiffComputer.js +0 -29
- package/dist/workers/editor/common/linesDiffComputers.js +0 -13
- package/dist/workers/editor/common/linesLayout.js +0 -765
- package/dist/workers/editor/common/linesSliceCharSequence.js +0 -205
- package/dist/workers/editor/common/linkComputer.js +0 -269
- package/dist/workers/editor/common/markerDecorations.js +0 -9
- package/dist/workers/editor/common/markerDecorationsService.js +0 -248
- package/dist/workers/editor/common/minimapTokensColorTracker.js +0 -58
- package/dist/workers/editor/common/mirrorTextModel.js +0 -117
- package/dist/workers/editor/common/model.js +0 -9
- package/dist/workers/editor/common/modelLineProjection.js +0 -350
- package/dist/workers/editor/common/modelLineProjectionData.js +0 -297
- package/dist/workers/editor/common/modelService.js +0 -413
- package/dist/workers/editor/common/modesRegistry.js +0 -75
- package/dist/workers/editor/common/monospaceLineBreaksComputer.js +0 -473
- package/dist/workers/editor/common/myersDiffAlgorithm.js +0 -159
- package/dist/workers/editor/common/nodeReader.js +0 -127
- package/dist/workers/editor/common/nullTokenize.js +0 -29
- package/dist/workers/editor/common/offsetRange.js +0 -225
- package/dist/workers/editor/common/onEnter.js +0 -109
- package/dist/workers/editor/common/oneCursor.js +0 -117
- package/dist/workers/editor/common/overviewZoneManager.js +0 -176
- package/dist/workers/editor/common/parser.js +0 -121
- package/dist/workers/editor/common/pieceTreeBase.js +0 -1473
- package/dist/workers/editor/common/pieceTreeTextBuffer.js +0 -461
- package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +0 -140
- package/dist/workers/editor/common/point.js +0 -50
- package/dist/workers/editor/common/position.js +0 -142
- package/dist/workers/editor/common/positionToOffset.js +0 -17
- package/dist/workers/editor/common/positionToOffsetImpl.js +0 -98
- package/dist/workers/editor/common/prefixSumComputer.js +0 -226
- package/dist/workers/editor/common/range.js +0 -421
- package/dist/workers/editor/common/rangeMapping.js +0 -229
- package/dist/workers/editor/common/rangeSingleLine.js +0 -17
- package/dist/workers/editor/common/rbTreeBase.js +0 -362
- package/dist/workers/editor/common/rect.js +0 -163
- package/dist/workers/editor/common/replaceCommand.js +0 -158
- package/dist/workers/editor/common/resolverService.js +0 -5
- package/dist/workers/editor/common/rgba.js +0 -35
- package/dist/workers/editor/common/richEditBrackets.js +0 -356
- package/dist/workers/editor/common/selection.js +0 -145
- package/dist/workers/editor/common/semanticTokensDto.js +0 -82
- package/dist/workers/editor/common/semanticTokensProviderStyling.js +0 -263
- package/dist/workers/editor/common/semanticTokensStyling.js +0 -9
- package/dist/workers/editor/common/semanticTokensStylingService.js +0 -47
- package/dist/workers/editor/common/shiftCommand.js +0 -241
- package/dist/workers/editor/common/smallImmutableSet.js +0 -108
- package/dist/workers/editor/common/sparseMultilineTokens.js +0 -548
- package/dist/workers/editor/common/sparseTokensStore.js +0 -210
- package/dist/workers/editor/common/standaloneEnums.js +0 -1017
- package/dist/workers/editor/common/standaloneStrings.js +0 -42
- package/dist/workers/editor/common/stringBuilder.js +0 -122
- package/dist/workers/editor/common/stringEdit.js +0 -165
- package/dist/workers/editor/common/supports.js +0 -58
- package/dist/workers/editor/common/surroundSelectionCommand.js +0 -44
- package/dist/workers/editor/common/textChange.js +0 -248
- package/dist/workers/editor/common/textEdit.js +0 -269
- package/dist/workers/editor/common/textLength.js +0 -87
- package/dist/workers/editor/common/textModel.js +0 -2031
- package/dist/workers/editor/common/textModelBracketPairs.js +0 -45
- package/dist/workers/editor/common/textModelDefaults.js +0 -18
- package/dist/workers/editor/common/textModelEditSource.js +0 -166
- package/dist/workers/editor/common/textModelEvents.js +0 -216
- package/dist/workers/editor/common/textModelGuides.js +0 -40
- package/dist/workers/editor/common/textModelPart.js +0 -23
- package/dist/workers/editor/common/textModelSearch.js +0 -455
- package/dist/workers/editor/common/textModelStringEdit.js +0 -11
- package/dist/workers/editor/common/textModelSync.impl.js +0 -307
- package/dist/workers/editor/common/textModelText.js +0 -26
- package/dist/workers/editor/common/textModelTokens.js +0 -436
- package/dist/workers/editor/common/textResourceConfiguration.js +0 -6
- package/dist/workers/editor/common/textToHtmlTokenizer.js +0 -139
- package/dist/workers/editor/common/tokenStore.js +0 -407
- package/dist/workers/editor/common/tokenWithTextArray.js +0 -73
- package/dist/workers/editor/common/tokenization.js +0 -287
- package/dist/workers/editor/common/tokenizationRegistry.js +0 -123
- package/dist/workers/editor/common/tokenizationTextModelPart.js +0 -275
- package/dist/workers/editor/common/tokenizer.js +0 -301
- package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +0 -261
- package/dist/workers/editor/common/treeSitterLibraryService.js +0 -9
- package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +0 -167
- package/dist/workers/editor/common/treeSitterThemeService.js +0 -9
- package/dist/workers/editor/common/treeSitterTokenizationImpl.js +0 -713
- package/dist/workers/editor/common/treeSitterTree.js +0 -395
- package/dist/workers/editor/common/treeViewsDnd.js +0 -24
- package/dist/workers/editor/common/treeViewsDndService.js +0 -12
- package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +0 -98
- package/dist/workers/editor/common/unicodeTextModelHighlighter.js +0 -188
- package/dist/workers/editor/common/utils.js +0 -62
- package/dist/workers/editor/common/viewContext.js +0 -22
- package/dist/workers/editor/common/viewEventHandler.js +0 -186
- package/dist/workers/editor/common/viewEvents.js +0 -180
- package/dist/workers/editor/common/viewLayout.js +0 -368
- package/dist/workers/editor/common/viewLineRenderer.js +0 -948
- package/dist/workers/editor/common/viewLinesViewportData.js +0 -30
- package/dist/workers/editor/common/viewModel.js +0 -98
- package/dist/workers/editor/common/viewModelDecoration.js +0 -55
- package/dist/workers/editor/common/viewModelDecorations.js +0 -132
- package/dist/workers/editor/common/viewModelEventDispatcher.js +0 -398
- package/dist/workers/editor/common/viewModelImpl.js +0 -1163
- package/dist/workers/editor/common/viewModelLines.js +0 -938
- package/dist/workers/editor/common/wordCharacterClassifier.js +0 -87
- package/dist/workers/editor/common/wordHelper.js +0 -127
- package/dist/workers/language/cssMode.js +0 -198
- package/dist/workers/language/cssWorker.js +0 -183
- package/dist/workers/language/htmlMode.js +0 -213
- package/dist/workers/language/htmlWorker.js +0 -126
- package/dist/workers/language/jsonMode.js +0 -224
- package/dist/workers/language/jsonWorker.js +0 -187
- package/dist/workers/language/languageFeatures.js +0 -1009
- package/dist/workers/language/lib.index.js +0 -103
- package/dist/workers/language/lib.js +0 -1107
- package/dist/workers/language/lspLanguageFeatures.js +0 -716
- package/dist/workers/language/monaco.contribution.js +0 -144
- package/dist/workers/language/tokenization.js +0 -189
- package/dist/workers/language/tsMode.js +0 -212
- package/dist/workers/language/tsWorker.js +0 -352
- package/dist/workers/language/typescriptServices.js +0 -210154
- package/dist/workers/language/typescriptServicesMetadata.js +0 -3
- package/dist/workers/language/workerManager.js +0 -65
- /package/dist/workers/{language/css.worker.js → css.worker.js} +0 -0
- /package/dist/workers/{editor/editor.worker.js → editor.worker.js} +0 -0
- /package/dist/workers/{language/html.worker.js → html.worker.js} +0 -0
- /package/dist/workers/{language/json.worker.js → json.worker.js} +0 -0
- /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 };
|