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.
- package/dist/assets/css.worker-C7FogG4G.js +93 -0
- package/dist/assets/editor.worker-iXcRX1Tq.js +26 -0
- package/dist/assets/html.worker-C8VxctEJ.js +470 -0
- package/dist/assets/json.worker-CMC9kgPL.js +58 -0
- package/dist/assets/ts.worker-CtTJ3hNN.js +67731 -0
- package/dist/index.d.ts +0 -6
- package/dist/monaco-editor11.es.js +49 -78
- package/dist/monaco-editor11.umd.js +1 -50
- package/dist/monaco.d.ts +8 -0
- package/dist/workers/common/initialize.js +16 -0
- package/dist/workers/common/workers.js +141 -0
- package/dist/workers/editor/common/abstractSyntaxTokenBackend.js +128 -0
- package/dist/workers/editor/common/abstractText.js +89 -0
- package/dist/workers/editor/common/ast.js +485 -0
- package/dist/workers/editor/common/autoIndent.js +390 -0
- package/dist/workers/editor/common/beforeEditPositionMapper.js +110 -0
- package/dist/workers/editor/common/bracketPairsImpl.js +717 -0
- package/dist/workers/editor/common/bracketPairsTree.js +343 -0
- package/dist/workers/editor/common/brackets.js +108 -0
- package/dist/workers/editor/common/characterClassifier.js +59 -0
- package/dist/workers/editor/common/characterPair.js +40 -0
- package/dist/workers/editor/common/colorizedBracketPairsDecorationProvider.js +97 -0
- package/dist/workers/editor/common/columnRange.js +35 -0
- package/dist/workers/editor/common/combineTextEditInfos.js +124 -0
- package/dist/workers/editor/common/common.js +20 -0
- package/dist/workers/editor/common/computeMovedLines.js +249 -0
- package/dist/workers/editor/common/concat23Trees.js +192 -0
- package/dist/workers/editor/common/contiguousMultilineTokens.js +32 -0
- package/dist/workers/editor/common/contiguousMultilineTokensBuilder.js +23 -0
- package/dist/workers/editor/common/contiguousTokensEditing.js +128 -0
- package/dist/workers/editor/common/contiguousTokensStore.js +207 -0
- package/dist/workers/editor/common/coordinatesConverter.js +51 -0
- package/dist/workers/editor/common/cursor.js +899 -0
- package/dist/workers/editor/common/cursorAtomicMoveOperations.js +145 -0
- package/dist/workers/editor/common/cursorCollection.js +194 -0
- package/dist/workers/editor/common/cursorColumnSelection.js +93 -0
- package/dist/workers/editor/common/cursorColumns.js +112 -0
- package/dist/workers/editor/common/cursorCommon.js +250 -0
- package/dist/workers/editor/common/cursorContext.js +15 -0
- package/dist/workers/editor/common/cursorDeleteOperations.js +231 -0
- package/dist/workers/editor/common/cursorMoveCommands.js +676 -0
- package/dist/workers/editor/common/cursorMoveOperations.js +290 -0
- package/dist/workers/editor/common/cursorTypeEditOperations.js +968 -0
- package/dist/workers/editor/common/cursorTypeOperations.js +173 -0
- package/dist/workers/editor/common/cursorUtils.js +75 -0
- package/dist/workers/editor/common/cursorWordOperations.js +720 -0
- package/dist/workers/editor/common/defaultDocumentColorsComputer.js +138 -0
- package/dist/workers/editor/common/defaultLinesDiffComputer.js +188 -0
- package/dist/workers/editor/common/diffAlgorithm.js +139 -0
- package/dist/workers/editor/common/diffEditor.js +38 -0
- package/dist/workers/editor/common/dynamicProgrammingDiffing.js +101 -0
- package/dist/workers/editor/common/edit.js +183 -0
- package/dist/workers/editor/common/editOperation.js +36 -0
- package/dist/workers/editor/common/editStack.js +363 -0
- package/dist/workers/editor/common/editorAction.js +26 -0
- package/dist/workers/editor/common/editorBaseApi.js +43 -0
- package/dist/workers/editor/common/editorColorRegistry.js +102 -0
- package/dist/workers/editor/common/editorCommon.js +13 -0
- package/dist/workers/editor/common/editorConfigurationSchema.js +338 -0
- package/dist/workers/editor/common/editorContextKeys.js +84 -0
- package/dist/workers/editor/common/editorFeatures.js +17 -0
- package/dist/workers/editor/common/editorOptions.js +3440 -0
- package/dist/workers/editor/common/editorTheme.js +23 -0
- package/dist/workers/editor/common/editorWebWorker.js +299 -0
- package/dist/workers/editor/common/editorWorker.js +9 -0
- package/dist/workers/editor/common/editorWorkerHost.js +15 -0
- package/dist/workers/editor/common/editorZoom.js +26 -0
- package/dist/workers/editor/common/electricCharacter.js +55 -0
- package/dist/workers/editor/common/encodedTokenAttributes.js +79 -0
- package/dist/workers/editor/common/enterAction.js +53 -0
- package/dist/workers/editor/common/eolCounter.js +44 -0
- package/dist/workers/editor/common/findSectionHeaders.js +128 -0
- package/dist/workers/editor/common/fixBrackets.js +67 -0
- package/dist/workers/editor/common/fixedArray.js +70 -0
- package/dist/workers/editor/common/fontInfo.js +172 -0
- package/dist/workers/editor/common/fontInfoFromSettings.js +29 -0
- package/dist/workers/editor/common/getIconClasses.js +106 -0
- package/dist/workers/editor/common/getPositionOffsetTransformerFromTextModel.js +24 -0
- package/dist/workers/editor/common/glyphLanesModel.js +61 -0
- package/dist/workers/editor/common/guidesTextModelPart.js +405 -0
- package/dist/workers/editor/common/heuristicSequenceOptimizations.js +374 -0
- package/dist/workers/editor/common/indentRules.js +63 -0
- package/dist/workers/editor/common/indentation.js +39 -0
- package/dist/workers/editor/common/indentationGuesser.js +178 -0
- package/dist/workers/editor/common/indentationLineProcessor.js +193 -0
- package/dist/workers/editor/common/inlineDecorations.js +26 -0
- package/dist/workers/editor/common/inplaceReplaceSupport.js +87 -0
- package/dist/workers/editor/common/inputMode.js +22 -0
- package/dist/workers/editor/common/intervalTree.js +1002 -0
- package/dist/workers/editor/common/language.js +9 -0
- package/dist/workers/editor/common/languageBracketsConfiguration.js +133 -0
- package/dist/workers/editor/common/languageConfiguration.js +138 -0
- package/dist/workers/editor/common/languageConfigurationRegistry.js +361 -0
- package/dist/workers/editor/common/languageFeatureDebounce.js +137 -0
- package/dist/workers/editor/common/languageFeatureRegistry.js +180 -0
- package/dist/workers/editor/common/languageFeatures.js +9 -0
- package/dist/workers/editor/common/languageFeaturesService.js +47 -0
- package/dist/workers/editor/common/languageSelector.js +112 -0
- package/dist/workers/editor/common/languageService.js +92 -0
- package/dist/workers/editor/common/languages.js +522 -0
- package/dist/workers/editor/common/languagesAssociations.js +193 -0
- package/dist/workers/editor/common/languagesRegistry.js +237 -0
- package/dist/workers/editor/common/legacyLinesDiffComputer.js +468 -0
- package/dist/workers/editor/common/length.js +129 -0
- package/dist/workers/editor/common/lineDecorations.js +208 -0
- package/dist/workers/editor/common/lineEdit.js +75 -0
- package/dist/workers/editor/common/lineHeights.js +370 -0
- package/dist/workers/editor/common/linePart.js +25 -0
- package/dist/workers/editor/common/lineRange.js +312 -0
- package/dist/workers/editor/common/lineSequence.js +36 -0
- package/dist/workers/editor/common/lineTokens.js +405 -0
- package/dist/workers/editor/common/linesDiffComputer.js +29 -0
- package/dist/workers/editor/common/linesDiffComputers.js +13 -0
- package/dist/workers/editor/common/linesLayout.js +765 -0
- package/dist/workers/editor/common/linesSliceCharSequence.js +205 -0
- package/dist/workers/editor/common/linkComputer.js +269 -0
- package/dist/workers/editor/common/markerDecorations.js +9 -0
- package/dist/workers/editor/common/markerDecorationsService.js +248 -0
- package/dist/workers/editor/common/minimapTokensColorTracker.js +58 -0
- package/dist/workers/editor/common/mirrorTextModel.js +117 -0
- package/dist/workers/editor/common/model.js +9 -0
- package/dist/workers/editor/common/modelLineProjection.js +350 -0
- package/dist/workers/editor/common/modelLineProjectionData.js +297 -0
- package/dist/workers/editor/common/modelService.js +413 -0
- package/dist/workers/editor/common/modesRegistry.js +75 -0
- package/dist/workers/editor/common/monospaceLineBreaksComputer.js +473 -0
- package/dist/workers/editor/common/myersDiffAlgorithm.js +159 -0
- package/dist/workers/editor/common/nodeReader.js +127 -0
- package/dist/workers/editor/common/nullTokenize.js +29 -0
- package/dist/workers/editor/common/offsetRange.js +225 -0
- package/dist/workers/editor/common/onEnter.js +109 -0
- package/dist/workers/editor/common/oneCursor.js +117 -0
- package/dist/workers/editor/common/overviewZoneManager.js +176 -0
- package/dist/workers/editor/common/parser.js +121 -0
- package/dist/workers/editor/common/pieceTreeBase.js +1473 -0
- package/dist/workers/editor/common/pieceTreeTextBuffer.js +461 -0
- package/dist/workers/editor/common/pieceTreeTextBufferBuilder.js +140 -0
- package/dist/workers/editor/common/point.js +50 -0
- package/dist/workers/editor/common/position.js +142 -0
- package/dist/workers/editor/common/positionToOffset.js +17 -0
- package/dist/workers/editor/common/positionToOffsetImpl.js +98 -0
- package/dist/workers/editor/common/prefixSumComputer.js +226 -0
- package/dist/workers/editor/common/range.js +421 -0
- package/dist/workers/editor/common/rangeMapping.js +229 -0
- package/dist/workers/editor/common/rangeSingleLine.js +17 -0
- package/dist/workers/editor/common/rbTreeBase.js +362 -0
- package/dist/workers/editor/common/rect.js +163 -0
- package/dist/workers/editor/common/replaceCommand.js +158 -0
- package/dist/workers/editor/common/resolverService.js +5 -0
- package/dist/workers/editor/common/rgba.js +35 -0
- package/dist/workers/editor/common/richEditBrackets.js +356 -0
- package/dist/workers/editor/common/selection.js +145 -0
- package/dist/workers/editor/common/semanticTokensDto.js +82 -0
- package/dist/workers/editor/common/semanticTokensProviderStyling.js +263 -0
- package/dist/workers/editor/common/semanticTokensStyling.js +9 -0
- package/dist/workers/editor/common/semanticTokensStylingService.js +47 -0
- package/dist/workers/editor/common/shiftCommand.js +241 -0
- package/dist/workers/editor/common/smallImmutableSet.js +108 -0
- package/dist/workers/editor/common/sparseMultilineTokens.js +548 -0
- package/dist/workers/editor/common/sparseTokensStore.js +210 -0
- package/dist/workers/editor/common/standaloneEnums.js +1017 -0
- package/dist/workers/editor/common/standaloneStrings.js +42 -0
- package/dist/workers/editor/common/stringBuilder.js +122 -0
- package/dist/workers/editor/common/stringEdit.js +165 -0
- package/dist/workers/editor/common/supports.js +58 -0
- package/dist/workers/editor/common/surroundSelectionCommand.js +44 -0
- package/dist/workers/editor/common/textChange.js +248 -0
- package/dist/workers/editor/common/textEdit.js +269 -0
- package/dist/workers/editor/common/textLength.js +87 -0
- package/dist/workers/editor/common/textModel.js +2031 -0
- package/dist/workers/editor/common/textModelBracketPairs.js +45 -0
- package/dist/workers/editor/common/textModelDefaults.js +18 -0
- package/dist/workers/editor/common/textModelEditSource.js +166 -0
- package/dist/workers/editor/common/textModelEvents.js +216 -0
- package/dist/workers/editor/common/textModelGuides.js +40 -0
- package/dist/workers/editor/common/textModelPart.js +23 -0
- package/dist/workers/editor/common/textModelSearch.js +455 -0
- package/dist/workers/editor/common/textModelStringEdit.js +11 -0
- package/dist/workers/editor/common/textModelSync.impl.js +307 -0
- package/dist/workers/editor/common/textModelText.js +26 -0
- package/dist/workers/editor/common/textModelTokens.js +436 -0
- package/dist/workers/editor/common/textResourceConfiguration.js +6 -0
- package/dist/workers/editor/common/textToHtmlTokenizer.js +139 -0
- package/dist/workers/editor/common/tokenStore.js +407 -0
- package/dist/workers/editor/common/tokenWithTextArray.js +73 -0
- package/dist/workers/editor/common/tokenization.js +287 -0
- package/dist/workers/editor/common/tokenizationRegistry.js +123 -0
- package/dist/workers/editor/common/tokenizationTextModelPart.js +275 -0
- package/dist/workers/editor/common/tokenizer.js +301 -0
- package/dist/workers/editor/common/tokenizerSyntaxTokenBackend.js +261 -0
- package/dist/workers/editor/common/treeSitterLibraryService.js +9 -0
- package/dist/workers/editor/common/treeSitterSyntaxTokenBackend.js +167 -0
- package/dist/workers/editor/common/treeSitterThemeService.js +9 -0
- package/dist/workers/editor/common/treeSitterTokenizationImpl.js +713 -0
- package/dist/workers/editor/common/treeSitterTree.js +395 -0
- package/dist/workers/editor/common/treeViewsDnd.js +24 -0
- package/dist/workers/editor/common/treeViewsDndService.js +12 -0
- package/dist/workers/editor/common/trimTrailingWhitespaceCommand.js +98 -0
- package/dist/workers/editor/common/unicodeTextModelHighlighter.js +188 -0
- package/dist/workers/editor/common/utils.js +62 -0
- package/dist/workers/editor/common/viewContext.js +22 -0
- package/dist/workers/editor/common/viewEventHandler.js +186 -0
- package/dist/workers/editor/common/viewEvents.js +180 -0
- package/dist/workers/editor/common/viewLayout.js +368 -0
- package/dist/workers/editor/common/viewLineRenderer.js +948 -0
- package/dist/workers/editor/common/viewLinesViewportData.js +30 -0
- package/dist/workers/editor/common/viewModel.js +98 -0
- package/dist/workers/editor/common/viewModelDecoration.js +55 -0
- package/dist/workers/editor/common/viewModelDecorations.js +132 -0
- package/dist/workers/editor/common/viewModelEventDispatcher.js +398 -0
- package/dist/workers/editor/common/viewModelImpl.js +1163 -0
- package/dist/workers/editor/common/viewModelLines.js +938 -0
- package/dist/workers/editor/common/wordCharacterClassifier.js +87 -0
- package/dist/workers/editor/common/wordHelper.js +127 -0
- package/dist/workers/editor/editor.worker.js +11 -0
- package/dist/workers/language/css.worker.js +8 -0
- package/dist/workers/language/cssMode.js +198 -0
- package/dist/workers/language/cssWorker.js +183 -0
- package/dist/workers/language/html.worker.js +8 -0
- package/dist/workers/language/htmlMode.js +213 -0
- package/dist/workers/language/htmlWorker.js +126 -0
- package/dist/workers/language/json.worker.js +8 -0
- package/dist/workers/language/jsonMode.js +224 -0
- package/dist/workers/language/jsonWorker.js +187 -0
- package/dist/workers/language/languageFeatures.js +1009 -0
- package/dist/workers/language/lib.index.js +103 -0
- package/dist/workers/language/lib.js +1107 -0
- package/dist/workers/language/lspLanguageFeatures.js +716 -0
- package/dist/workers/language/monaco.contribution.js +144 -0
- package/dist/workers/language/tokenization.js +189 -0
- package/dist/workers/language/ts.worker.js +14 -0
- package/dist/workers/language/tsMode.js +212 -0
- package/dist/workers/language/tsWorker.js +352 -0
- package/dist/workers/language/typescriptServices.js +210154 -0
- package/dist/workers/language/typescriptServicesMetadata.js +3 -0
- package/dist/workers/language/workerManager.js +65 -0
- package/package.json +3 -2
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { CursorColumns } from '../core/cursorColumns.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 AtomicTabMoveOperations {
|
|
8
|
+
/**
|
|
9
|
+
* Get the visible column at the position. If we get to a non-whitespace character first
|
|
10
|
+
* or past the end of string then return -1.
|
|
11
|
+
*
|
|
12
|
+
* **Note** `position` and the return value are 0-based.
|
|
13
|
+
*/
|
|
14
|
+
static whitespaceVisibleColumn(lineContent, position, tabSize) {
|
|
15
|
+
const lineLength = lineContent.length;
|
|
16
|
+
let visibleColumn = 0;
|
|
17
|
+
let prevTabStopPosition = -1;
|
|
18
|
+
let prevTabStopVisibleColumn = -1;
|
|
19
|
+
for (let i = 0; i < lineLength; i++) {
|
|
20
|
+
if (i === position) {
|
|
21
|
+
return [prevTabStopPosition, prevTabStopVisibleColumn, visibleColumn];
|
|
22
|
+
}
|
|
23
|
+
if (visibleColumn % tabSize === 0) {
|
|
24
|
+
prevTabStopPosition = i;
|
|
25
|
+
prevTabStopVisibleColumn = visibleColumn;
|
|
26
|
+
}
|
|
27
|
+
const chCode = lineContent.charCodeAt(i);
|
|
28
|
+
switch (chCode) {
|
|
29
|
+
case 32 /* CharCode.Space */:
|
|
30
|
+
visibleColumn += 1;
|
|
31
|
+
break;
|
|
32
|
+
case 9 /* CharCode.Tab */:
|
|
33
|
+
// Skip to the next multiple of tabSize.
|
|
34
|
+
visibleColumn = CursorColumns.nextRenderTabStop(visibleColumn, tabSize);
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
return [-1, -1, -1];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (position === lineLength) {
|
|
41
|
+
return [prevTabStopPosition, prevTabStopVisibleColumn, visibleColumn];
|
|
42
|
+
}
|
|
43
|
+
return [-1, -1, -1];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Return the position that should result from a move left, right or to the
|
|
47
|
+
* nearest tab, if atomic tabs are enabled. Left and right are used for the
|
|
48
|
+
* arrow key movements, nearest is used for mouse selection. It returns
|
|
49
|
+
* -1 if atomic tabs are not relevant and you should fall back to normal
|
|
50
|
+
* behaviour.
|
|
51
|
+
*
|
|
52
|
+
* **Note**: `position` and the return value are 0-based.
|
|
53
|
+
*/
|
|
54
|
+
static atomicPosition(lineContent, position, tabSize, direction) {
|
|
55
|
+
const lineLength = lineContent.length;
|
|
56
|
+
// Get the 0-based visible column corresponding to the position, or return
|
|
57
|
+
// -1 if it is not in the initial whitespace.
|
|
58
|
+
const [prevTabStopPosition, prevTabStopVisibleColumn, visibleColumn] = AtomicTabMoveOperations.whitespaceVisibleColumn(lineContent, position, tabSize);
|
|
59
|
+
if (visibleColumn === -1) {
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
// Is the output left or right of the current position. The case for nearest
|
|
63
|
+
// where it is the same as the current position is handled in the switch.
|
|
64
|
+
let left;
|
|
65
|
+
switch (direction) {
|
|
66
|
+
case 0 /* Direction.Left */:
|
|
67
|
+
left = true;
|
|
68
|
+
break;
|
|
69
|
+
case 1 /* Direction.Right */:
|
|
70
|
+
left = false;
|
|
71
|
+
break;
|
|
72
|
+
case 2 /* Direction.Nearest */:
|
|
73
|
+
// The code below assumes the output position is either left or right
|
|
74
|
+
// of the input position. If it is the same, return immediately.
|
|
75
|
+
if (visibleColumn % tabSize === 0) {
|
|
76
|
+
return position;
|
|
77
|
+
}
|
|
78
|
+
// Go to the nearest indentation.
|
|
79
|
+
left = visibleColumn % tabSize <= (tabSize / 2);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
// If going left, we can just use the info about the last tab stop position and
|
|
83
|
+
// last tab stop visible column that we computed in the first walk over the whitespace.
|
|
84
|
+
if (left) {
|
|
85
|
+
if (prevTabStopPosition === -1) {
|
|
86
|
+
return -1;
|
|
87
|
+
}
|
|
88
|
+
// If the direction is left, we need to keep scanning right to ensure
|
|
89
|
+
// that targetVisibleColumn + tabSize is before non-whitespace.
|
|
90
|
+
// This is so that when we press left at the end of a partial
|
|
91
|
+
// indentation it only goes one character. For example ' foo' with
|
|
92
|
+
// tabSize 4, should jump from position 6 to position 5, not 4.
|
|
93
|
+
let currentVisibleColumn = prevTabStopVisibleColumn;
|
|
94
|
+
for (let i = prevTabStopPosition; i < lineLength; ++i) {
|
|
95
|
+
if (currentVisibleColumn === prevTabStopVisibleColumn + tabSize) {
|
|
96
|
+
// It is a full indentation.
|
|
97
|
+
return prevTabStopPosition;
|
|
98
|
+
}
|
|
99
|
+
const chCode = lineContent.charCodeAt(i);
|
|
100
|
+
switch (chCode) {
|
|
101
|
+
case 32 /* CharCode.Space */:
|
|
102
|
+
currentVisibleColumn += 1;
|
|
103
|
+
break;
|
|
104
|
+
case 9 /* CharCode.Tab */:
|
|
105
|
+
currentVisibleColumn = CursorColumns.nextRenderTabStop(currentVisibleColumn, tabSize);
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
return -1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (currentVisibleColumn === prevTabStopVisibleColumn + tabSize) {
|
|
112
|
+
return prevTabStopPosition;
|
|
113
|
+
}
|
|
114
|
+
// It must have been a partial indentation.
|
|
115
|
+
return -1;
|
|
116
|
+
}
|
|
117
|
+
// We are going right.
|
|
118
|
+
const targetVisibleColumn = CursorColumns.nextRenderTabStop(visibleColumn, tabSize);
|
|
119
|
+
// We can just continue from where whitespaceVisibleColumn got to.
|
|
120
|
+
let currentVisibleColumn = visibleColumn;
|
|
121
|
+
for (let i = position; i < lineLength; i++) {
|
|
122
|
+
if (currentVisibleColumn === targetVisibleColumn) {
|
|
123
|
+
return i;
|
|
124
|
+
}
|
|
125
|
+
const chCode = lineContent.charCodeAt(i);
|
|
126
|
+
switch (chCode) {
|
|
127
|
+
case 32 /* CharCode.Space */:
|
|
128
|
+
currentVisibleColumn += 1;
|
|
129
|
+
break;
|
|
130
|
+
case 9 /* CharCode.Tab */:
|
|
131
|
+
currentVisibleColumn = CursorColumns.nextRenderTabStop(currentVisibleColumn, tabSize);
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
return -1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// This condition handles when the target column is at the end of the line.
|
|
138
|
+
if (currentVisibleColumn === targetVisibleColumn) {
|
|
139
|
+
return lineLength;
|
|
140
|
+
}
|
|
141
|
+
return -1;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export { AtomicTabMoveOperations };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { compareBy } from '../../../base/common/arrays.js';
|
|
2
|
+
import { findFirstMin, findLastMax } from '../../../base/common/arraysFind.js';
|
|
3
|
+
import { CursorState } from '../cursorCommon.js';
|
|
4
|
+
import { Cursor } from './oneCursor.js';
|
|
5
|
+
import { Position } from '../core/position.js';
|
|
6
|
+
import { Range } from '../core/range.js';
|
|
7
|
+
import { Selection } from '../core/selection.js';
|
|
8
|
+
|
|
9
|
+
/*---------------------------------------------------------------------------------------------
|
|
10
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
12
|
+
*--------------------------------------------------------------------------------------------*/
|
|
13
|
+
class CursorCollection {
|
|
14
|
+
constructor(context) {
|
|
15
|
+
this.context = context;
|
|
16
|
+
this.cursors = [new Cursor(context)];
|
|
17
|
+
this.lastAddedCursorIndex = 0;
|
|
18
|
+
}
|
|
19
|
+
dispose() {
|
|
20
|
+
for (const cursor of this.cursors) {
|
|
21
|
+
cursor.dispose(this.context);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
startTrackingSelections() {
|
|
25
|
+
for (const cursor of this.cursors) {
|
|
26
|
+
cursor.startTrackingSelection(this.context);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
stopTrackingSelections() {
|
|
30
|
+
for (const cursor of this.cursors) {
|
|
31
|
+
cursor.stopTrackingSelection(this.context);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
updateContext(context) {
|
|
35
|
+
this.context = context;
|
|
36
|
+
}
|
|
37
|
+
ensureValidState() {
|
|
38
|
+
for (const cursor of this.cursors) {
|
|
39
|
+
cursor.ensureValidState(this.context);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
readSelectionFromMarkers() {
|
|
43
|
+
return this.cursors.map(c => c.readSelectionFromMarkers(this.context));
|
|
44
|
+
}
|
|
45
|
+
getAll() {
|
|
46
|
+
return this.cursors.map(c => c.asCursorState());
|
|
47
|
+
}
|
|
48
|
+
getViewPositions() {
|
|
49
|
+
return this.cursors.map(c => c.viewState.position);
|
|
50
|
+
}
|
|
51
|
+
getTopMostViewPosition() {
|
|
52
|
+
return findFirstMin(this.cursors, compareBy(c => c.viewState.position, Position.compare)).viewState.position;
|
|
53
|
+
}
|
|
54
|
+
getBottomMostViewPosition() {
|
|
55
|
+
return findLastMax(this.cursors, compareBy(c => c.viewState.position, Position.compare)).viewState.position;
|
|
56
|
+
}
|
|
57
|
+
getSelections() {
|
|
58
|
+
return this.cursors.map(c => c.modelState.selection);
|
|
59
|
+
}
|
|
60
|
+
getViewSelections() {
|
|
61
|
+
return this.cursors.map(c => c.viewState.selection);
|
|
62
|
+
}
|
|
63
|
+
setSelections(selections) {
|
|
64
|
+
this.setStates(CursorState.fromModelSelections(selections));
|
|
65
|
+
}
|
|
66
|
+
getPrimaryCursor() {
|
|
67
|
+
return this.cursors[0].asCursorState();
|
|
68
|
+
}
|
|
69
|
+
setStates(states) {
|
|
70
|
+
if (states === null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.cursors[0].setState(this.context, states[0].modelState, states[0].viewState);
|
|
74
|
+
this._setSecondaryStates(states.slice(1));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates or disposes secondary cursors as necessary to match the number of `secondarySelections`.
|
|
78
|
+
*/
|
|
79
|
+
_setSecondaryStates(secondaryStates) {
|
|
80
|
+
const secondaryCursorsLength = this.cursors.length - 1;
|
|
81
|
+
const secondaryStatesLength = secondaryStates.length;
|
|
82
|
+
if (secondaryCursorsLength < secondaryStatesLength) {
|
|
83
|
+
const createCnt = secondaryStatesLength - secondaryCursorsLength;
|
|
84
|
+
for (let i = 0; i < createCnt; i++) {
|
|
85
|
+
this._addSecondaryCursor();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (secondaryCursorsLength > secondaryStatesLength) {
|
|
89
|
+
const removeCnt = secondaryCursorsLength - secondaryStatesLength;
|
|
90
|
+
for (let i = 0; i < removeCnt; i++) {
|
|
91
|
+
this._removeSecondaryCursor(this.cursors.length - 2);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (let i = 0; i < secondaryStatesLength; i++) {
|
|
95
|
+
this.cursors[i + 1].setState(this.context, secondaryStates[i].modelState, secondaryStates[i].viewState);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
killSecondaryCursors() {
|
|
99
|
+
this._setSecondaryStates([]);
|
|
100
|
+
}
|
|
101
|
+
_addSecondaryCursor() {
|
|
102
|
+
this.cursors.push(new Cursor(this.context));
|
|
103
|
+
this.lastAddedCursorIndex = this.cursors.length - 1;
|
|
104
|
+
}
|
|
105
|
+
getLastAddedCursorIndex() {
|
|
106
|
+
if (this.cursors.length === 1 || this.lastAddedCursorIndex === 0) {
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
return this.lastAddedCursorIndex;
|
|
110
|
+
}
|
|
111
|
+
_removeSecondaryCursor(removeIndex) {
|
|
112
|
+
if (this.lastAddedCursorIndex >= removeIndex + 1) {
|
|
113
|
+
this.lastAddedCursorIndex--;
|
|
114
|
+
}
|
|
115
|
+
this.cursors[removeIndex + 1].dispose(this.context);
|
|
116
|
+
this.cursors.splice(removeIndex + 1, 1);
|
|
117
|
+
}
|
|
118
|
+
normalize() {
|
|
119
|
+
if (this.cursors.length === 1) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const cursors = this.cursors.slice(0);
|
|
123
|
+
const sortedCursors = [];
|
|
124
|
+
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
125
|
+
sortedCursors.push({
|
|
126
|
+
index: i,
|
|
127
|
+
selection: cursors[i].modelState.selection,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
sortedCursors.sort(compareBy(s => s.selection, Range.compareRangesUsingStarts));
|
|
131
|
+
for (let sortedCursorIndex = 0; sortedCursorIndex < sortedCursors.length - 1; sortedCursorIndex++) {
|
|
132
|
+
const current = sortedCursors[sortedCursorIndex];
|
|
133
|
+
const next = sortedCursors[sortedCursorIndex + 1];
|
|
134
|
+
const currentSelection = current.selection;
|
|
135
|
+
const nextSelection = next.selection;
|
|
136
|
+
if (!this.context.cursorConfig.multiCursorMergeOverlapping) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
let shouldMergeCursors;
|
|
140
|
+
if (nextSelection.isEmpty() || currentSelection.isEmpty()) {
|
|
141
|
+
// Merge touching cursors if one of them is collapsed
|
|
142
|
+
shouldMergeCursors = nextSelection.getStartPosition().isBeforeOrEqual(currentSelection.getEndPosition());
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// Merge only overlapping cursors (i.e. allow touching ranges)
|
|
146
|
+
shouldMergeCursors = nextSelection.getStartPosition().isBefore(currentSelection.getEndPosition());
|
|
147
|
+
}
|
|
148
|
+
if (shouldMergeCursors) {
|
|
149
|
+
const winnerSortedCursorIndex = current.index < next.index ? sortedCursorIndex : sortedCursorIndex + 1;
|
|
150
|
+
const looserSortedCursorIndex = current.index < next.index ? sortedCursorIndex + 1 : sortedCursorIndex;
|
|
151
|
+
const looserIndex = sortedCursors[looserSortedCursorIndex].index;
|
|
152
|
+
const winnerIndex = sortedCursors[winnerSortedCursorIndex].index;
|
|
153
|
+
const looserSelection = sortedCursors[looserSortedCursorIndex].selection;
|
|
154
|
+
const winnerSelection = sortedCursors[winnerSortedCursorIndex].selection;
|
|
155
|
+
if (!looserSelection.equalsSelection(winnerSelection)) {
|
|
156
|
+
const resultingRange = looserSelection.plusRange(winnerSelection);
|
|
157
|
+
const looserSelectionIsLTR = (looserSelection.selectionStartLineNumber === looserSelection.startLineNumber && looserSelection.selectionStartColumn === looserSelection.startColumn);
|
|
158
|
+
const winnerSelectionIsLTR = (winnerSelection.selectionStartLineNumber === winnerSelection.startLineNumber && winnerSelection.selectionStartColumn === winnerSelection.startColumn);
|
|
159
|
+
// Give more importance to the last added cursor (think Ctrl-dragging + hitting another cursor)
|
|
160
|
+
let resultingSelectionIsLTR;
|
|
161
|
+
if (looserIndex === this.lastAddedCursorIndex) {
|
|
162
|
+
resultingSelectionIsLTR = looserSelectionIsLTR;
|
|
163
|
+
this.lastAddedCursorIndex = winnerIndex;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Winner takes it all
|
|
167
|
+
resultingSelectionIsLTR = winnerSelectionIsLTR;
|
|
168
|
+
}
|
|
169
|
+
let resultingSelection;
|
|
170
|
+
if (resultingSelectionIsLTR) {
|
|
171
|
+
resultingSelection = new Selection(resultingRange.startLineNumber, resultingRange.startColumn, resultingRange.endLineNumber, resultingRange.endColumn);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
resultingSelection = new Selection(resultingRange.endLineNumber, resultingRange.endColumn, resultingRange.startLineNumber, resultingRange.startColumn);
|
|
175
|
+
}
|
|
176
|
+
sortedCursors[winnerSortedCursorIndex].selection = resultingSelection;
|
|
177
|
+
const resultingState = CursorState.fromModelSelection(resultingSelection);
|
|
178
|
+
cursors[winnerIndex].setState(this.context, resultingState.modelState, resultingState.viewState);
|
|
179
|
+
}
|
|
180
|
+
for (const sortedCursor of sortedCursors) {
|
|
181
|
+
if (sortedCursor.index > looserIndex) {
|
|
182
|
+
sortedCursor.index--;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
cursors.splice(looserIndex, 1);
|
|
186
|
+
sortedCursors.splice(looserSortedCursorIndex, 1);
|
|
187
|
+
this._removeSecondaryCursor(looserIndex - 1);
|
|
188
|
+
sortedCursorIndex--;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { CursorCollection };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { SingleCursorState } from '../cursorCommon.js';
|
|
2
|
+
import { Position } from '../core/position.js';
|
|
3
|
+
import { Range } from '../core/range.js';
|
|
4
|
+
|
|
5
|
+
/*---------------------------------------------------------------------------------------------
|
|
6
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
8
|
+
*--------------------------------------------------------------------------------------------*/
|
|
9
|
+
class ColumnSelection {
|
|
10
|
+
static columnSelect(config, model, fromLineNumber, fromVisibleColumn, toLineNumber, toVisibleColumn) {
|
|
11
|
+
const lineCount = Math.abs(toLineNumber - fromLineNumber) + 1;
|
|
12
|
+
const reversed = (fromLineNumber > toLineNumber);
|
|
13
|
+
const isRTL = (fromVisibleColumn > toVisibleColumn);
|
|
14
|
+
const isLTR = (fromVisibleColumn < toVisibleColumn);
|
|
15
|
+
const result = [];
|
|
16
|
+
// console.log(`fromVisibleColumn: ${fromVisibleColumn}, toVisibleColumn: ${toVisibleColumn}`);
|
|
17
|
+
for (let i = 0; i < lineCount; i++) {
|
|
18
|
+
const lineNumber = fromLineNumber + (reversed ? -i : i);
|
|
19
|
+
const startColumn = config.columnFromVisibleColumn(model, lineNumber, fromVisibleColumn);
|
|
20
|
+
const endColumn = config.columnFromVisibleColumn(model, lineNumber, toVisibleColumn);
|
|
21
|
+
const visibleStartColumn = config.visibleColumnFromColumn(model, new Position(lineNumber, startColumn));
|
|
22
|
+
const visibleEndColumn = config.visibleColumnFromColumn(model, new Position(lineNumber, endColumn));
|
|
23
|
+
// console.log(`lineNumber: ${lineNumber}: visibleStartColumn: ${visibleStartColumn}, visibleEndColumn: ${visibleEndColumn}`);
|
|
24
|
+
if (isLTR) {
|
|
25
|
+
if (visibleStartColumn > toVisibleColumn) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (visibleEndColumn < fromVisibleColumn) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (isRTL) {
|
|
33
|
+
if (visibleEndColumn > fromVisibleColumn) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (visibleStartColumn < toVisibleColumn) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
result.push(new SingleCursorState(new Range(lineNumber, startColumn, lineNumber, startColumn), 0 /* SelectionStartKind.Simple */, 0, new Position(lineNumber, endColumn), 0));
|
|
41
|
+
}
|
|
42
|
+
if (result.length === 0) {
|
|
43
|
+
// We are after all the lines, so add cursor at the end of each line
|
|
44
|
+
for (let i = 0; i < lineCount; i++) {
|
|
45
|
+
const lineNumber = fromLineNumber + (reversed ? -i : i);
|
|
46
|
+
const maxColumn = model.getLineMaxColumn(lineNumber);
|
|
47
|
+
result.push(new SingleCursorState(new Range(lineNumber, maxColumn, lineNumber, maxColumn), 0 /* SelectionStartKind.Simple */, 0, new Position(lineNumber, maxColumn), 0));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
viewStates: result,
|
|
52
|
+
reversed: reversed,
|
|
53
|
+
fromLineNumber: fromLineNumber,
|
|
54
|
+
fromVisualColumn: fromVisibleColumn,
|
|
55
|
+
toLineNumber: toLineNumber,
|
|
56
|
+
toVisualColumn: toVisibleColumn
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
static columnSelectLeft(config, model, prevColumnSelectData) {
|
|
60
|
+
let toViewVisualColumn = prevColumnSelectData.toViewVisualColumn;
|
|
61
|
+
if (toViewVisualColumn > 0) {
|
|
62
|
+
toViewVisualColumn--;
|
|
63
|
+
}
|
|
64
|
+
return ColumnSelection.columnSelect(config, model, prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.fromViewVisualColumn, prevColumnSelectData.toViewLineNumber, toViewVisualColumn);
|
|
65
|
+
}
|
|
66
|
+
static columnSelectRight(config, model, prevColumnSelectData) {
|
|
67
|
+
let maxVisualViewColumn = 0;
|
|
68
|
+
const minViewLineNumber = Math.min(prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.toViewLineNumber);
|
|
69
|
+
const maxViewLineNumber = Math.max(prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.toViewLineNumber);
|
|
70
|
+
for (let lineNumber = minViewLineNumber; lineNumber <= maxViewLineNumber; lineNumber++) {
|
|
71
|
+
const lineMaxViewColumn = model.getLineMaxColumn(lineNumber);
|
|
72
|
+
const lineMaxVisualViewColumn = config.visibleColumnFromColumn(model, new Position(lineNumber, lineMaxViewColumn));
|
|
73
|
+
maxVisualViewColumn = Math.max(maxVisualViewColumn, lineMaxVisualViewColumn);
|
|
74
|
+
}
|
|
75
|
+
let toViewVisualColumn = prevColumnSelectData.toViewVisualColumn;
|
|
76
|
+
if (toViewVisualColumn < maxVisualViewColumn) {
|
|
77
|
+
toViewVisualColumn++;
|
|
78
|
+
}
|
|
79
|
+
return this.columnSelect(config, model, prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.fromViewVisualColumn, prevColumnSelectData.toViewLineNumber, toViewVisualColumn);
|
|
80
|
+
}
|
|
81
|
+
static columnSelectUp(config, model, prevColumnSelectData, isPaged) {
|
|
82
|
+
const linesCount = isPaged ? config.pageSize : 1;
|
|
83
|
+
const toViewLineNumber = Math.max(1, prevColumnSelectData.toViewLineNumber - linesCount);
|
|
84
|
+
return this.columnSelect(config, model, prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.fromViewVisualColumn, toViewLineNumber, prevColumnSelectData.toViewVisualColumn);
|
|
85
|
+
}
|
|
86
|
+
static columnSelectDown(config, model, prevColumnSelectData, isPaged) {
|
|
87
|
+
const linesCount = isPaged ? config.pageSize : 1;
|
|
88
|
+
const toViewLineNumber = Math.min(model.getLineCount(), prevColumnSelectData.toViewLineNumber + linesCount);
|
|
89
|
+
return this.columnSelect(config, model, prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.fromViewVisualColumn, toViewLineNumber, prevColumnSelectData.toViewVisualColumn);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { ColumnSelection };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { isFullWidthCharacter, isEmojiImprecise, GraphemeIterator, getNextCodePoint } from '../../../base/common/strings.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
|
+
/**
|
|
8
|
+
* A column in a position is the gap between two adjacent characters. The methods here
|
|
9
|
+
* work with a concept called "visible column". A visible column is a very rough approximation
|
|
10
|
+
* of the horizontal screen position of a column. For example, using a tab size of 4:
|
|
11
|
+
* ```txt
|
|
12
|
+
* |<TAB>|<TAB>|T|ext
|
|
13
|
+
* | | | \---- column = 4, visible column = 9
|
|
14
|
+
* | | \------ column = 3, visible column = 8
|
|
15
|
+
* | \------------ column = 2, visible column = 4
|
|
16
|
+
* \------------------ column = 1, visible column = 0
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* **NOTE**: Visual columns do not work well for RTL text or variable-width fonts or characters.
|
|
20
|
+
*
|
|
21
|
+
* **NOTE**: These methods work and make sense both on the model and on the view model.
|
|
22
|
+
*/
|
|
23
|
+
class CursorColumns {
|
|
24
|
+
static _nextVisibleColumn(codePoint, visibleColumn, tabSize) {
|
|
25
|
+
if (codePoint === 9 /* CharCode.Tab */) {
|
|
26
|
+
return CursorColumns.nextRenderTabStop(visibleColumn, tabSize);
|
|
27
|
+
}
|
|
28
|
+
if (isFullWidthCharacter(codePoint) || isEmojiImprecise(codePoint)) {
|
|
29
|
+
return visibleColumn + 2;
|
|
30
|
+
}
|
|
31
|
+
return visibleColumn + 1;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns a visible column from a column.
|
|
35
|
+
* @see {@link CursorColumns}
|
|
36
|
+
*/
|
|
37
|
+
static visibleColumnFromColumn(lineContent, column, tabSize) {
|
|
38
|
+
const textLen = Math.min(column - 1, lineContent.length);
|
|
39
|
+
const text = lineContent.substring(0, textLen);
|
|
40
|
+
const iterator = new GraphemeIterator(text);
|
|
41
|
+
let result = 0;
|
|
42
|
+
while (!iterator.eol()) {
|
|
43
|
+
const codePoint = getNextCodePoint(text, textLen, iterator.offset);
|
|
44
|
+
iterator.nextGraphemeLength();
|
|
45
|
+
result = this._nextVisibleColumn(codePoint, result, tabSize);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns a column from a visible column.
|
|
51
|
+
* @see {@link CursorColumns}
|
|
52
|
+
*/
|
|
53
|
+
static columnFromVisibleColumn(lineContent, visibleColumn, tabSize) {
|
|
54
|
+
if (visibleColumn <= 0) {
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
const lineContentLength = lineContent.length;
|
|
58
|
+
const iterator = new GraphemeIterator(lineContent);
|
|
59
|
+
let beforeVisibleColumn = 0;
|
|
60
|
+
let beforeColumn = 1;
|
|
61
|
+
while (!iterator.eol()) {
|
|
62
|
+
const codePoint = getNextCodePoint(lineContent, lineContentLength, iterator.offset);
|
|
63
|
+
iterator.nextGraphemeLength();
|
|
64
|
+
const afterVisibleColumn = this._nextVisibleColumn(codePoint, beforeVisibleColumn, tabSize);
|
|
65
|
+
const afterColumn = iterator.offset + 1;
|
|
66
|
+
if (afterVisibleColumn >= visibleColumn) {
|
|
67
|
+
const beforeDelta = visibleColumn - beforeVisibleColumn;
|
|
68
|
+
const afterDelta = afterVisibleColumn - visibleColumn;
|
|
69
|
+
if (afterDelta < beforeDelta) {
|
|
70
|
+
return afterColumn;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return beforeColumn;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
beforeVisibleColumn = afterVisibleColumn;
|
|
77
|
+
beforeColumn = afterColumn;
|
|
78
|
+
}
|
|
79
|
+
// walked the entire string
|
|
80
|
+
return lineContentLength + 1;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* ATTENTION: This works with 0-based columns (as opposed to the regular 1-based columns)
|
|
84
|
+
* @see {@link CursorColumns}
|
|
85
|
+
*/
|
|
86
|
+
static nextRenderTabStop(visibleColumn, tabSize) {
|
|
87
|
+
return visibleColumn + tabSize - visibleColumn % tabSize;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* ATTENTION: This works with 0-based columns (as opposed to the regular 1-based columns)
|
|
91
|
+
* @see {@link CursorColumns}
|
|
92
|
+
*/
|
|
93
|
+
static nextIndentTabStop(visibleColumn, indentSize) {
|
|
94
|
+
return CursorColumns.nextRenderTabStop(visibleColumn, indentSize);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* ATTENTION: This works with 0-based columns (as opposed to the regular 1-based columns)
|
|
98
|
+
* @see {@link CursorColumns}
|
|
99
|
+
*/
|
|
100
|
+
static prevRenderTabStop(column, tabSize) {
|
|
101
|
+
return Math.max(0, column - 1 - (column - 1) % tabSize);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* ATTENTION: This works with 0-based columns (as opposed to the regular 1-based columns)
|
|
105
|
+
* @see {@link CursorColumns}
|
|
106
|
+
*/
|
|
107
|
+
static prevIndentTabStop(column, indentSize) {
|
|
108
|
+
return CursorColumns.prevRenderTabStop(column, indentSize);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { CursorColumns };
|