monaco-editor11 1.0.9 → 1.1.1
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 +12 -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,676 +0,0 @@
|
|
|
1
|
-
import { isObject, isString, isUndefined, isBoolean, isNumber } from '../../../base/common/types.js';
|
|
2
|
-
import { CursorState, SingleCursorState } from '../cursorCommon.js';
|
|
3
|
-
import { MoveOperations } from './cursorMoveOperations.js';
|
|
4
|
-
import { WordOperations } from './cursorWordOperations.js';
|
|
5
|
-
import { Position } from '../core/position.js';
|
|
6
|
-
import { Range } from '../core/range.js';
|
|
7
|
-
import { TextDirection } from '../model.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 CursorMoveCommands {
|
|
14
|
-
static addCursorDown(viewModel, cursors, useLogicalLine) {
|
|
15
|
-
const result = [];
|
|
16
|
-
let resultLen = 0;
|
|
17
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
18
|
-
const cursor = cursors[i];
|
|
19
|
-
result[resultLen++] = new CursorState(cursor.modelState, cursor.viewState);
|
|
20
|
-
if (useLogicalLine) {
|
|
21
|
-
result[resultLen++] = CursorState.fromModelState(MoveOperations.translateDown(viewModel.cursorConfig, viewModel.model, cursor.modelState));
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
result[resultLen++] = CursorState.fromViewState(MoveOperations.translateDown(viewModel.cursorConfig, viewModel, cursor.viewState));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
static addCursorUp(viewModel, cursors, useLogicalLine) {
|
|
30
|
-
const result = [];
|
|
31
|
-
let resultLen = 0;
|
|
32
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
33
|
-
const cursor = cursors[i];
|
|
34
|
-
result[resultLen++] = new CursorState(cursor.modelState, cursor.viewState);
|
|
35
|
-
if (useLogicalLine) {
|
|
36
|
-
result[resultLen++] = CursorState.fromModelState(MoveOperations.translateUp(viewModel.cursorConfig, viewModel.model, cursor.modelState));
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
result[resultLen++] = CursorState.fromViewState(MoveOperations.translateUp(viewModel.cursorConfig, viewModel, cursor.viewState));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
static moveToBeginningOfLine(viewModel, cursors, inSelectionMode) {
|
|
45
|
-
const result = [];
|
|
46
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
47
|
-
const cursor = cursors[i];
|
|
48
|
-
result[i] = this._moveToLineStart(viewModel, cursor, inSelectionMode);
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
static _moveToLineStart(viewModel, cursor, inSelectionMode) {
|
|
53
|
-
const currentViewStateColumn = cursor.viewState.position.column;
|
|
54
|
-
const currentModelStateColumn = cursor.modelState.position.column;
|
|
55
|
-
const isFirstLineOfWrappedLine = currentViewStateColumn === currentModelStateColumn;
|
|
56
|
-
const currentViewStatelineNumber = cursor.viewState.position.lineNumber;
|
|
57
|
-
const firstNonBlankColumn = viewModel.getLineFirstNonWhitespaceColumn(currentViewStatelineNumber);
|
|
58
|
-
const isBeginningOfViewLine = currentViewStateColumn === firstNonBlankColumn;
|
|
59
|
-
if (!isFirstLineOfWrappedLine && !isBeginningOfViewLine) {
|
|
60
|
-
return this._moveToLineStartByView(viewModel, cursor, inSelectionMode);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return this._moveToLineStartByModel(viewModel, cursor, inSelectionMode);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
static _moveToLineStartByView(viewModel, cursor, inSelectionMode) {
|
|
67
|
-
return CursorState.fromViewState(MoveOperations.moveToBeginningOfLine(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode));
|
|
68
|
-
}
|
|
69
|
-
static _moveToLineStartByModel(viewModel, cursor, inSelectionMode) {
|
|
70
|
-
return CursorState.fromModelState(MoveOperations.moveToBeginningOfLine(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode));
|
|
71
|
-
}
|
|
72
|
-
static moveToEndOfLine(viewModel, cursors, inSelectionMode, sticky) {
|
|
73
|
-
const result = [];
|
|
74
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
75
|
-
const cursor = cursors[i];
|
|
76
|
-
result[i] = this._moveToLineEnd(viewModel, cursor, inSelectionMode, sticky);
|
|
77
|
-
}
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
static _moveToLineEnd(viewModel, cursor, inSelectionMode, sticky) {
|
|
81
|
-
const viewStatePosition = cursor.viewState.position;
|
|
82
|
-
const viewModelMaxColumn = viewModel.getLineMaxColumn(viewStatePosition.lineNumber);
|
|
83
|
-
const isEndOfViewLine = viewStatePosition.column === viewModelMaxColumn;
|
|
84
|
-
const modelStatePosition = cursor.modelState.position;
|
|
85
|
-
const modelMaxColumn = viewModel.model.getLineMaxColumn(modelStatePosition.lineNumber);
|
|
86
|
-
const isEndLineOfWrappedLine = viewModelMaxColumn - viewStatePosition.column === modelMaxColumn - modelStatePosition.column;
|
|
87
|
-
if (isEndOfViewLine || isEndLineOfWrappedLine) {
|
|
88
|
-
return this._moveToLineEndByModel(viewModel, cursor, inSelectionMode, sticky);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return this._moveToLineEndByView(viewModel, cursor, inSelectionMode, sticky);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
static _moveToLineEndByView(viewModel, cursor, inSelectionMode, sticky) {
|
|
95
|
-
return CursorState.fromViewState(MoveOperations.moveToEndOfLine(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, sticky));
|
|
96
|
-
}
|
|
97
|
-
static _moveToLineEndByModel(viewModel, cursor, inSelectionMode, sticky) {
|
|
98
|
-
return CursorState.fromModelState(MoveOperations.moveToEndOfLine(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode, sticky));
|
|
99
|
-
}
|
|
100
|
-
static expandLineSelection(viewModel, cursors) {
|
|
101
|
-
const result = [];
|
|
102
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
103
|
-
const cursor = cursors[i];
|
|
104
|
-
const startLineNumber = cursor.modelState.selection.startLineNumber;
|
|
105
|
-
const lineCount = viewModel.model.getLineCount();
|
|
106
|
-
let endLineNumber = cursor.modelState.selection.endLineNumber;
|
|
107
|
-
let endColumn;
|
|
108
|
-
if (endLineNumber === lineCount) {
|
|
109
|
-
endColumn = viewModel.model.getLineMaxColumn(lineCount);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
endLineNumber++;
|
|
113
|
-
endColumn = 1;
|
|
114
|
-
}
|
|
115
|
-
result[i] = CursorState.fromModelState(new SingleCursorState(new Range(startLineNumber, 1, startLineNumber, 1), 0 /* SelectionStartKind.Simple */, 0, new Position(endLineNumber, endColumn), 0));
|
|
116
|
-
}
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
static moveToBeginningOfBuffer(viewModel, cursors, inSelectionMode) {
|
|
120
|
-
const result = [];
|
|
121
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
122
|
-
const cursor = cursors[i];
|
|
123
|
-
result[i] = CursorState.fromModelState(MoveOperations.moveToBeginningOfBuffer(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode));
|
|
124
|
-
}
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
static moveToEndOfBuffer(viewModel, cursors, inSelectionMode) {
|
|
128
|
-
const result = [];
|
|
129
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
130
|
-
const cursor = cursors[i];
|
|
131
|
-
result[i] = CursorState.fromModelState(MoveOperations.moveToEndOfBuffer(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode));
|
|
132
|
-
}
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
|
-
static selectAll(viewModel, cursor) {
|
|
136
|
-
const lineCount = viewModel.model.getLineCount();
|
|
137
|
-
const maxColumn = viewModel.model.getLineMaxColumn(lineCount);
|
|
138
|
-
return CursorState.fromModelState(new SingleCursorState(new Range(1, 1, 1, 1), 0 /* SelectionStartKind.Simple */, 0, new Position(lineCount, maxColumn), 0));
|
|
139
|
-
}
|
|
140
|
-
static line(viewModel, cursor, inSelectionMode, _position, _viewPosition) {
|
|
141
|
-
const position = viewModel.model.validatePosition(_position);
|
|
142
|
-
const viewPosition = (_viewPosition
|
|
143
|
-
? viewModel.coordinatesConverter.validateViewPosition(new Position(_viewPosition.lineNumber, _viewPosition.column), position)
|
|
144
|
-
: viewModel.coordinatesConverter.convertModelPositionToViewPosition(position));
|
|
145
|
-
if (!inSelectionMode) {
|
|
146
|
-
// Entering line selection for the first time
|
|
147
|
-
const lineCount = viewModel.model.getLineCount();
|
|
148
|
-
let selectToLineNumber = position.lineNumber + 1;
|
|
149
|
-
let selectToColumn = 1;
|
|
150
|
-
if (selectToLineNumber > lineCount) {
|
|
151
|
-
selectToLineNumber = lineCount;
|
|
152
|
-
selectToColumn = viewModel.model.getLineMaxColumn(selectToLineNumber);
|
|
153
|
-
}
|
|
154
|
-
return CursorState.fromModelState(new SingleCursorState(new Range(position.lineNumber, 1, selectToLineNumber, selectToColumn), 2 /* SelectionStartKind.Line */, 0, new Position(selectToLineNumber, selectToColumn), 0));
|
|
155
|
-
}
|
|
156
|
-
// Continuing line selection
|
|
157
|
-
const enteringLineNumber = cursor.modelState.selectionStart.getStartPosition().lineNumber;
|
|
158
|
-
if (position.lineNumber < enteringLineNumber) {
|
|
159
|
-
return CursorState.fromViewState(cursor.viewState.move(true, viewPosition.lineNumber, 1, 0));
|
|
160
|
-
}
|
|
161
|
-
else if (position.lineNumber > enteringLineNumber) {
|
|
162
|
-
const lineCount = viewModel.getLineCount();
|
|
163
|
-
let selectToViewLineNumber = viewPosition.lineNumber + 1;
|
|
164
|
-
let selectToViewColumn = 1;
|
|
165
|
-
if (selectToViewLineNumber > lineCount) {
|
|
166
|
-
selectToViewLineNumber = lineCount;
|
|
167
|
-
selectToViewColumn = viewModel.getLineMaxColumn(selectToViewLineNumber);
|
|
168
|
-
}
|
|
169
|
-
return CursorState.fromViewState(cursor.viewState.move(true, selectToViewLineNumber, selectToViewColumn, 0));
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
const endPositionOfSelectionStart = cursor.modelState.selectionStart.getEndPosition();
|
|
173
|
-
return CursorState.fromModelState(cursor.modelState.move(true, endPositionOfSelectionStart.lineNumber, endPositionOfSelectionStart.column, 0));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
static word(viewModel, cursor, inSelectionMode, _position) {
|
|
177
|
-
const position = viewModel.model.validatePosition(_position);
|
|
178
|
-
return CursorState.fromModelState(WordOperations.word(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode, position));
|
|
179
|
-
}
|
|
180
|
-
static cancelSelection(viewModel, cursor) {
|
|
181
|
-
if (!cursor.modelState.hasSelection()) {
|
|
182
|
-
return new CursorState(cursor.modelState, cursor.viewState);
|
|
183
|
-
}
|
|
184
|
-
const lineNumber = cursor.viewState.position.lineNumber;
|
|
185
|
-
const column = cursor.viewState.position.column;
|
|
186
|
-
return CursorState.fromViewState(new SingleCursorState(new Range(lineNumber, column, lineNumber, column), 0 /* SelectionStartKind.Simple */, 0, new Position(lineNumber, column), 0));
|
|
187
|
-
}
|
|
188
|
-
static moveTo(viewModel, cursor, inSelectionMode, _position, _viewPosition) {
|
|
189
|
-
if (inSelectionMode) {
|
|
190
|
-
if (cursor.modelState.selectionStartKind === 1 /* SelectionStartKind.Word */) {
|
|
191
|
-
return this.word(viewModel, cursor, inSelectionMode, _position);
|
|
192
|
-
}
|
|
193
|
-
if (cursor.modelState.selectionStartKind === 2 /* SelectionStartKind.Line */) {
|
|
194
|
-
return this.line(viewModel, cursor, inSelectionMode, _position, _viewPosition);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
const position = viewModel.model.validatePosition(_position);
|
|
198
|
-
const viewPosition = (_viewPosition
|
|
199
|
-
? viewModel.coordinatesConverter.validateViewPosition(new Position(_viewPosition.lineNumber, _viewPosition.column), position)
|
|
200
|
-
: viewModel.coordinatesConverter.convertModelPositionToViewPosition(position));
|
|
201
|
-
return CursorState.fromViewState(cursor.viewState.move(inSelectionMode, viewPosition.lineNumber, viewPosition.column, 0));
|
|
202
|
-
}
|
|
203
|
-
static simpleMove(viewModel, cursors, direction, inSelectionMode, value, unit) {
|
|
204
|
-
switch (direction) {
|
|
205
|
-
case 0 /* CursorMove.Direction.Left */: {
|
|
206
|
-
if (unit === 4 /* CursorMove.Unit.HalfLine */) {
|
|
207
|
-
// Move left by half the current line length
|
|
208
|
-
return this._moveHalfLineLeft(viewModel, cursors, inSelectionMode);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
// Move left by `moveParams.value` columns
|
|
212
|
-
return this._moveLeft(viewModel, cursors, inSelectionMode, value);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
case 1 /* CursorMove.Direction.Right */: {
|
|
216
|
-
if (unit === 4 /* CursorMove.Unit.HalfLine */) {
|
|
217
|
-
// Move right by half the current line length
|
|
218
|
-
return this._moveHalfLineRight(viewModel, cursors, inSelectionMode);
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
// Move right by `moveParams.value` columns
|
|
222
|
-
return this._moveRight(viewModel, cursors, inSelectionMode, value);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
case 2 /* CursorMove.Direction.Up */: {
|
|
226
|
-
if (unit === 2 /* CursorMove.Unit.WrappedLine */) {
|
|
227
|
-
// Move up by view lines
|
|
228
|
-
return this._moveUpByViewLines(viewModel, cursors, inSelectionMode, value);
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
// Move up by model lines
|
|
232
|
-
return this._moveUpByModelLines(viewModel, cursors, inSelectionMode, value);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
case 3 /* CursorMove.Direction.Down */: {
|
|
236
|
-
if (unit === 2 /* CursorMove.Unit.WrappedLine */) {
|
|
237
|
-
// Move down by view lines
|
|
238
|
-
return this._moveDownByViewLines(viewModel, cursors, inSelectionMode, value);
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
// Move down by model lines
|
|
242
|
-
return this._moveDownByModelLines(viewModel, cursors, inSelectionMode, value);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
case 4 /* CursorMove.Direction.PrevBlankLine */: {
|
|
246
|
-
if (unit === 2 /* CursorMove.Unit.WrappedLine */) {
|
|
247
|
-
return cursors.map(cursor => CursorState.fromViewState(MoveOperations.moveToPrevBlankLine(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode)));
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
return cursors.map(cursor => CursorState.fromModelState(MoveOperations.moveToPrevBlankLine(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode)));
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
case 5 /* CursorMove.Direction.NextBlankLine */: {
|
|
254
|
-
if (unit === 2 /* CursorMove.Unit.WrappedLine */) {
|
|
255
|
-
return cursors.map(cursor => CursorState.fromViewState(MoveOperations.moveToNextBlankLine(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode)));
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
return cursors.map(cursor => CursorState.fromModelState(MoveOperations.moveToNextBlankLine(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode)));
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
case 6 /* CursorMove.Direction.WrappedLineStart */: {
|
|
262
|
-
// Move to the beginning of the current view line
|
|
263
|
-
return this._moveToViewMinColumn(viewModel, cursors, inSelectionMode);
|
|
264
|
-
}
|
|
265
|
-
case 7 /* CursorMove.Direction.WrappedLineFirstNonWhitespaceCharacter */: {
|
|
266
|
-
// Move to the first non-whitespace column of the current view line
|
|
267
|
-
return this._moveToViewFirstNonWhitespaceColumn(viewModel, cursors, inSelectionMode);
|
|
268
|
-
}
|
|
269
|
-
case 8 /* CursorMove.Direction.WrappedLineColumnCenter */: {
|
|
270
|
-
// Move to the "center" of the current view line
|
|
271
|
-
return this._moveToViewCenterColumn(viewModel, cursors, inSelectionMode);
|
|
272
|
-
}
|
|
273
|
-
case 9 /* CursorMove.Direction.WrappedLineEnd */: {
|
|
274
|
-
// Move to the end of the current view line
|
|
275
|
-
return this._moveToViewMaxColumn(viewModel, cursors, inSelectionMode);
|
|
276
|
-
}
|
|
277
|
-
case 10 /* CursorMove.Direction.WrappedLineLastNonWhitespaceCharacter */: {
|
|
278
|
-
// Move to the last non-whitespace column of the current view line
|
|
279
|
-
return this._moveToViewLastNonWhitespaceColumn(viewModel, cursors, inSelectionMode);
|
|
280
|
-
}
|
|
281
|
-
default:
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
static viewportMove(viewModel, cursors, direction, inSelectionMode, value) {
|
|
286
|
-
const visibleViewRange = viewModel.getCompletelyVisibleViewRange();
|
|
287
|
-
const visibleModelRange = viewModel.coordinatesConverter.convertViewRangeToModelRange(visibleViewRange);
|
|
288
|
-
switch (direction) {
|
|
289
|
-
case 11 /* CursorMove.Direction.ViewPortTop */: {
|
|
290
|
-
// Move to the nth line start in the viewport (from the top)
|
|
291
|
-
const modelLineNumber = this._firstLineNumberInRange(viewModel.model, visibleModelRange, value);
|
|
292
|
-
const modelColumn = viewModel.model.getLineFirstNonWhitespaceColumn(modelLineNumber);
|
|
293
|
-
return [this._moveToModelPosition(viewModel, cursors[0], inSelectionMode, modelLineNumber, modelColumn)];
|
|
294
|
-
}
|
|
295
|
-
case 13 /* CursorMove.Direction.ViewPortBottom */: {
|
|
296
|
-
// Move to the nth line start in the viewport (from the bottom)
|
|
297
|
-
const modelLineNumber = this._lastLineNumberInRange(viewModel.model, visibleModelRange, value);
|
|
298
|
-
const modelColumn = viewModel.model.getLineFirstNonWhitespaceColumn(modelLineNumber);
|
|
299
|
-
return [this._moveToModelPosition(viewModel, cursors[0], inSelectionMode, modelLineNumber, modelColumn)];
|
|
300
|
-
}
|
|
301
|
-
case 12 /* CursorMove.Direction.ViewPortCenter */: {
|
|
302
|
-
// Move to the line start in the viewport center
|
|
303
|
-
const modelLineNumber = Math.round((visibleModelRange.startLineNumber + visibleModelRange.endLineNumber) / 2);
|
|
304
|
-
const modelColumn = viewModel.model.getLineFirstNonWhitespaceColumn(modelLineNumber);
|
|
305
|
-
return [this._moveToModelPosition(viewModel, cursors[0], inSelectionMode, modelLineNumber, modelColumn)];
|
|
306
|
-
}
|
|
307
|
-
case 14 /* CursorMove.Direction.ViewPortIfOutside */: {
|
|
308
|
-
// Move to a position inside the viewport
|
|
309
|
-
const result = [];
|
|
310
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
311
|
-
const cursor = cursors[i];
|
|
312
|
-
result[i] = this.findPositionInViewportIfOutside(viewModel, cursor, visibleViewRange, inSelectionMode);
|
|
313
|
-
}
|
|
314
|
-
return result;
|
|
315
|
-
}
|
|
316
|
-
default:
|
|
317
|
-
return null;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
static findPositionInViewportIfOutside(viewModel, cursor, visibleViewRange, inSelectionMode) {
|
|
321
|
-
const viewLineNumber = cursor.viewState.position.lineNumber;
|
|
322
|
-
if (visibleViewRange.startLineNumber <= viewLineNumber && viewLineNumber <= visibleViewRange.endLineNumber - 1) {
|
|
323
|
-
// Nothing to do, cursor is in viewport
|
|
324
|
-
return new CursorState(cursor.modelState, cursor.viewState);
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
let newViewLineNumber;
|
|
328
|
-
if (viewLineNumber > visibleViewRange.endLineNumber - 1) {
|
|
329
|
-
newViewLineNumber = visibleViewRange.endLineNumber - 1;
|
|
330
|
-
}
|
|
331
|
-
else if (viewLineNumber < visibleViewRange.startLineNumber) {
|
|
332
|
-
newViewLineNumber = visibleViewRange.startLineNumber;
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
newViewLineNumber = viewLineNumber;
|
|
336
|
-
}
|
|
337
|
-
const position = MoveOperations.vertical(viewModel.cursorConfig, viewModel, viewLineNumber, cursor.viewState.position.column, cursor.viewState.leftoverVisibleColumns, newViewLineNumber, false);
|
|
338
|
-
return CursorState.fromViewState(cursor.viewState.move(inSelectionMode, position.lineNumber, position.column, position.leftoverVisibleColumns));
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Find the nth line start included in the range (from the start).
|
|
343
|
-
*/
|
|
344
|
-
static _firstLineNumberInRange(model, range, count) {
|
|
345
|
-
let startLineNumber = range.startLineNumber;
|
|
346
|
-
if (range.startColumn !== model.getLineMinColumn(startLineNumber)) {
|
|
347
|
-
// Move on to the second line if the first line start is not included in the range
|
|
348
|
-
startLineNumber++;
|
|
349
|
-
}
|
|
350
|
-
return Math.min(range.endLineNumber, startLineNumber + count - 1);
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Find the nth line start included in the range (from the end).
|
|
354
|
-
*/
|
|
355
|
-
static _lastLineNumberInRange(model, range, count) {
|
|
356
|
-
let startLineNumber = range.startLineNumber;
|
|
357
|
-
if (range.startColumn !== model.getLineMinColumn(startLineNumber)) {
|
|
358
|
-
// Move on to the second line if the first line start is not included in the range
|
|
359
|
-
startLineNumber++;
|
|
360
|
-
}
|
|
361
|
-
return Math.max(startLineNumber, range.endLineNumber - count + 1);
|
|
362
|
-
}
|
|
363
|
-
static _moveLeft(viewModel, cursors, inSelectionMode, noOfColumns) {
|
|
364
|
-
return cursors.map(cursor => {
|
|
365
|
-
const direction = viewModel.getTextDirection(cursor.viewState.position.lineNumber);
|
|
366
|
-
const isRtl = direction === TextDirection.RTL;
|
|
367
|
-
return CursorState.fromViewState(isRtl
|
|
368
|
-
? MoveOperations.moveRight(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, noOfColumns)
|
|
369
|
-
: MoveOperations.moveLeft(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, noOfColumns));
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
static _moveHalfLineLeft(viewModel, cursors, inSelectionMode) {
|
|
373
|
-
const result = [];
|
|
374
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
375
|
-
const cursor = cursors[i];
|
|
376
|
-
const viewLineNumber = cursor.viewState.position.lineNumber;
|
|
377
|
-
const halfLine = Math.round(viewModel.getLineLength(viewLineNumber) / 2);
|
|
378
|
-
result[i] = CursorState.fromViewState(MoveOperations.moveLeft(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, halfLine));
|
|
379
|
-
}
|
|
380
|
-
return result;
|
|
381
|
-
}
|
|
382
|
-
static _moveRight(viewModel, cursors, inSelectionMode, noOfColumns) {
|
|
383
|
-
return cursors.map(cursor => {
|
|
384
|
-
const direction = viewModel.getTextDirection(cursor.viewState.position.lineNumber);
|
|
385
|
-
const isRtl = direction === TextDirection.RTL;
|
|
386
|
-
return CursorState.fromViewState(isRtl
|
|
387
|
-
? MoveOperations.moveLeft(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, noOfColumns)
|
|
388
|
-
: MoveOperations.moveRight(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, noOfColumns));
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
static _moveHalfLineRight(viewModel, cursors, inSelectionMode) {
|
|
392
|
-
const result = [];
|
|
393
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
394
|
-
const cursor = cursors[i];
|
|
395
|
-
const viewLineNumber = cursor.viewState.position.lineNumber;
|
|
396
|
-
const halfLine = Math.round(viewModel.getLineLength(viewLineNumber) / 2);
|
|
397
|
-
result[i] = CursorState.fromViewState(MoveOperations.moveRight(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, halfLine));
|
|
398
|
-
}
|
|
399
|
-
return result;
|
|
400
|
-
}
|
|
401
|
-
static _moveDownByViewLines(viewModel, cursors, inSelectionMode, linesCount) {
|
|
402
|
-
const result = [];
|
|
403
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
404
|
-
const cursor = cursors[i];
|
|
405
|
-
result[i] = CursorState.fromViewState(MoveOperations.moveDown(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, linesCount));
|
|
406
|
-
}
|
|
407
|
-
return result;
|
|
408
|
-
}
|
|
409
|
-
static _moveDownByModelLines(viewModel, cursors, inSelectionMode, linesCount) {
|
|
410
|
-
const result = [];
|
|
411
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
412
|
-
const cursor = cursors[i];
|
|
413
|
-
result[i] = CursorState.fromModelState(MoveOperations.moveDown(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode, linesCount));
|
|
414
|
-
}
|
|
415
|
-
return result;
|
|
416
|
-
}
|
|
417
|
-
static _moveUpByViewLines(viewModel, cursors, inSelectionMode, linesCount) {
|
|
418
|
-
const result = [];
|
|
419
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
420
|
-
const cursor = cursors[i];
|
|
421
|
-
result[i] = CursorState.fromViewState(MoveOperations.moveUp(viewModel.cursorConfig, viewModel, cursor.viewState, inSelectionMode, linesCount));
|
|
422
|
-
}
|
|
423
|
-
return result;
|
|
424
|
-
}
|
|
425
|
-
static _moveUpByModelLines(viewModel, cursors, inSelectionMode, linesCount) {
|
|
426
|
-
const result = [];
|
|
427
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
428
|
-
const cursor = cursors[i];
|
|
429
|
-
result[i] = CursorState.fromModelState(MoveOperations.moveUp(viewModel.cursorConfig, viewModel.model, cursor.modelState, inSelectionMode, linesCount));
|
|
430
|
-
}
|
|
431
|
-
return result;
|
|
432
|
-
}
|
|
433
|
-
static _moveToViewPosition(viewModel, cursor, inSelectionMode, toViewLineNumber, toViewColumn) {
|
|
434
|
-
return CursorState.fromViewState(cursor.viewState.move(inSelectionMode, toViewLineNumber, toViewColumn, 0));
|
|
435
|
-
}
|
|
436
|
-
static _moveToModelPosition(viewModel, cursor, inSelectionMode, toModelLineNumber, toModelColumn) {
|
|
437
|
-
return CursorState.fromModelState(cursor.modelState.move(inSelectionMode, toModelLineNumber, toModelColumn, 0));
|
|
438
|
-
}
|
|
439
|
-
static _moveToViewMinColumn(viewModel, cursors, inSelectionMode) {
|
|
440
|
-
const result = [];
|
|
441
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
442
|
-
const cursor = cursors[i];
|
|
443
|
-
const viewLineNumber = cursor.viewState.position.lineNumber;
|
|
444
|
-
const viewColumn = viewModel.getLineMinColumn(viewLineNumber);
|
|
445
|
-
result[i] = this._moveToViewPosition(viewModel, cursor, inSelectionMode, viewLineNumber, viewColumn);
|
|
446
|
-
}
|
|
447
|
-
return result;
|
|
448
|
-
}
|
|
449
|
-
static _moveToViewFirstNonWhitespaceColumn(viewModel, cursors, inSelectionMode) {
|
|
450
|
-
const result = [];
|
|
451
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
452
|
-
const cursor = cursors[i];
|
|
453
|
-
const viewLineNumber = cursor.viewState.position.lineNumber;
|
|
454
|
-
const viewColumn = viewModel.getLineFirstNonWhitespaceColumn(viewLineNumber);
|
|
455
|
-
result[i] = this._moveToViewPosition(viewModel, cursor, inSelectionMode, viewLineNumber, viewColumn);
|
|
456
|
-
}
|
|
457
|
-
return result;
|
|
458
|
-
}
|
|
459
|
-
static _moveToViewCenterColumn(viewModel, cursors, inSelectionMode) {
|
|
460
|
-
const result = [];
|
|
461
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
462
|
-
const cursor = cursors[i];
|
|
463
|
-
const viewLineNumber = cursor.viewState.position.lineNumber;
|
|
464
|
-
const viewColumn = Math.round((viewModel.getLineMaxColumn(viewLineNumber) + viewModel.getLineMinColumn(viewLineNumber)) / 2);
|
|
465
|
-
result[i] = this._moveToViewPosition(viewModel, cursor, inSelectionMode, viewLineNumber, viewColumn);
|
|
466
|
-
}
|
|
467
|
-
return result;
|
|
468
|
-
}
|
|
469
|
-
static _moveToViewMaxColumn(viewModel, cursors, inSelectionMode) {
|
|
470
|
-
const result = [];
|
|
471
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
472
|
-
const cursor = cursors[i];
|
|
473
|
-
const viewLineNumber = cursor.viewState.position.lineNumber;
|
|
474
|
-
const viewColumn = viewModel.getLineMaxColumn(viewLineNumber);
|
|
475
|
-
result[i] = this._moveToViewPosition(viewModel, cursor, inSelectionMode, viewLineNumber, viewColumn);
|
|
476
|
-
}
|
|
477
|
-
return result;
|
|
478
|
-
}
|
|
479
|
-
static _moveToViewLastNonWhitespaceColumn(viewModel, cursors, inSelectionMode) {
|
|
480
|
-
const result = [];
|
|
481
|
-
for (let i = 0, len = cursors.length; i < len; i++) {
|
|
482
|
-
const cursor = cursors[i];
|
|
483
|
-
const viewLineNumber = cursor.viewState.position.lineNumber;
|
|
484
|
-
const viewColumn = viewModel.getLineLastNonWhitespaceColumn(viewLineNumber);
|
|
485
|
-
result[i] = this._moveToViewPosition(viewModel, cursor, inSelectionMode, viewLineNumber, viewColumn);
|
|
486
|
-
}
|
|
487
|
-
return result;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
var CursorMove;
|
|
491
|
-
(function (CursorMove) {
|
|
492
|
-
const isCursorMoveArgs = function (arg) {
|
|
493
|
-
if (!isObject(arg)) {
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
const cursorMoveArg = arg;
|
|
497
|
-
if (!isString(cursorMoveArg.to)) {
|
|
498
|
-
return false;
|
|
499
|
-
}
|
|
500
|
-
if (!isUndefined(cursorMoveArg.select) && !isBoolean(cursorMoveArg.select)) {
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
if (!isUndefined(cursorMoveArg.by) && !isString(cursorMoveArg.by)) {
|
|
504
|
-
return false;
|
|
505
|
-
}
|
|
506
|
-
if (!isUndefined(cursorMoveArg.value) && !isNumber(cursorMoveArg.value)) {
|
|
507
|
-
return false;
|
|
508
|
-
}
|
|
509
|
-
if (!isUndefined(cursorMoveArg.noHistory) && !isBoolean(cursorMoveArg.noHistory)) {
|
|
510
|
-
return false;
|
|
511
|
-
}
|
|
512
|
-
return true;
|
|
513
|
-
};
|
|
514
|
-
CursorMove.metadata = {
|
|
515
|
-
description: 'Move cursor to a logical position in the view',
|
|
516
|
-
args: [
|
|
517
|
-
{
|
|
518
|
-
name: 'Cursor move argument object',
|
|
519
|
-
description: `Property-value pairs that can be passed through this argument:
|
|
520
|
-
* 'to': A mandatory logical position value providing where to move the cursor.
|
|
521
|
-
\`\`\`
|
|
522
|
-
'left', 'right', 'up', 'down', 'prevBlankLine', 'nextBlankLine',
|
|
523
|
-
'wrappedLineStart', 'wrappedLineEnd', 'wrappedLineColumnCenter'
|
|
524
|
-
'wrappedLineFirstNonWhitespaceCharacter', 'wrappedLineLastNonWhitespaceCharacter'
|
|
525
|
-
'viewPortTop', 'viewPortCenter', 'viewPortBottom', 'viewPortIfOutside'
|
|
526
|
-
\`\`\`
|
|
527
|
-
* 'by': Unit to move. Default is computed based on 'to' value.
|
|
528
|
-
\`\`\`
|
|
529
|
-
'line', 'wrappedLine', 'character', 'halfLine'
|
|
530
|
-
\`\`\`
|
|
531
|
-
* 'value': Number of units to move. Default is '1'.
|
|
532
|
-
* 'select': If 'true' makes the selection. Default is 'false'.
|
|
533
|
-
* 'noHistory': If 'true' does not add the movement to navigation history. Default is 'false'.
|
|
534
|
-
`,
|
|
535
|
-
constraint: isCursorMoveArgs,
|
|
536
|
-
schema: {
|
|
537
|
-
'type': 'object',
|
|
538
|
-
'required': ['to'],
|
|
539
|
-
'properties': {
|
|
540
|
-
'to': {
|
|
541
|
-
'type': 'string',
|
|
542
|
-
'enum': ['left', 'right', 'up', 'down', 'prevBlankLine', 'nextBlankLine', 'wrappedLineStart', 'wrappedLineEnd', 'wrappedLineColumnCenter', 'wrappedLineFirstNonWhitespaceCharacter', 'wrappedLineLastNonWhitespaceCharacter', 'viewPortTop', 'viewPortCenter', 'viewPortBottom', 'viewPortIfOutside']
|
|
543
|
-
},
|
|
544
|
-
'by': {
|
|
545
|
-
'type': 'string',
|
|
546
|
-
'enum': ['line', 'wrappedLine', 'character', 'halfLine']
|
|
547
|
-
},
|
|
548
|
-
'value': {
|
|
549
|
-
'type': 'number',
|
|
550
|
-
'default': 1
|
|
551
|
-
},
|
|
552
|
-
'select': {
|
|
553
|
-
'type': 'boolean',
|
|
554
|
-
'default': false
|
|
555
|
-
},
|
|
556
|
-
'noHistory': {
|
|
557
|
-
'type': 'boolean',
|
|
558
|
-
'default': false
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
]
|
|
564
|
-
};
|
|
565
|
-
/**
|
|
566
|
-
* Positions in the view for cursor move command.
|
|
567
|
-
*/
|
|
568
|
-
CursorMove.RawDirection = {
|
|
569
|
-
Left: 'left',
|
|
570
|
-
Right: 'right',
|
|
571
|
-
Up: 'up',
|
|
572
|
-
Down: 'down',
|
|
573
|
-
PrevBlankLine: 'prevBlankLine',
|
|
574
|
-
NextBlankLine: 'nextBlankLine',
|
|
575
|
-
WrappedLineStart: 'wrappedLineStart',
|
|
576
|
-
WrappedLineFirstNonWhitespaceCharacter: 'wrappedLineFirstNonWhitespaceCharacter',
|
|
577
|
-
WrappedLineColumnCenter: 'wrappedLineColumnCenter',
|
|
578
|
-
WrappedLineEnd: 'wrappedLineEnd',
|
|
579
|
-
WrappedLineLastNonWhitespaceCharacter: 'wrappedLineLastNonWhitespaceCharacter',
|
|
580
|
-
ViewPortTop: 'viewPortTop',
|
|
581
|
-
ViewPortCenter: 'viewPortCenter',
|
|
582
|
-
ViewPortBottom: 'viewPortBottom',
|
|
583
|
-
ViewPortIfOutside: 'viewPortIfOutside'
|
|
584
|
-
};
|
|
585
|
-
/**
|
|
586
|
-
* Units for Cursor move 'by' argument
|
|
587
|
-
*/
|
|
588
|
-
CursorMove.RawUnit = {
|
|
589
|
-
Line: 'line',
|
|
590
|
-
WrappedLine: 'wrappedLine',
|
|
591
|
-
Character: 'character',
|
|
592
|
-
HalfLine: 'halfLine'
|
|
593
|
-
};
|
|
594
|
-
function parse(args) {
|
|
595
|
-
if (!args.to) {
|
|
596
|
-
// illegal arguments
|
|
597
|
-
return null;
|
|
598
|
-
}
|
|
599
|
-
let direction;
|
|
600
|
-
switch (args.to) {
|
|
601
|
-
case CursorMove.RawDirection.Left:
|
|
602
|
-
direction = 0 /* Direction.Left */;
|
|
603
|
-
break;
|
|
604
|
-
case CursorMove.RawDirection.Right:
|
|
605
|
-
direction = 1 /* Direction.Right */;
|
|
606
|
-
break;
|
|
607
|
-
case CursorMove.RawDirection.Up:
|
|
608
|
-
direction = 2 /* Direction.Up */;
|
|
609
|
-
break;
|
|
610
|
-
case CursorMove.RawDirection.Down:
|
|
611
|
-
direction = 3 /* Direction.Down */;
|
|
612
|
-
break;
|
|
613
|
-
case CursorMove.RawDirection.PrevBlankLine:
|
|
614
|
-
direction = 4 /* Direction.PrevBlankLine */;
|
|
615
|
-
break;
|
|
616
|
-
case CursorMove.RawDirection.NextBlankLine:
|
|
617
|
-
direction = 5 /* Direction.NextBlankLine */;
|
|
618
|
-
break;
|
|
619
|
-
case CursorMove.RawDirection.WrappedLineStart:
|
|
620
|
-
direction = 6 /* Direction.WrappedLineStart */;
|
|
621
|
-
break;
|
|
622
|
-
case CursorMove.RawDirection.WrappedLineFirstNonWhitespaceCharacter:
|
|
623
|
-
direction = 7 /* Direction.WrappedLineFirstNonWhitespaceCharacter */;
|
|
624
|
-
break;
|
|
625
|
-
case CursorMove.RawDirection.WrappedLineColumnCenter:
|
|
626
|
-
direction = 8 /* Direction.WrappedLineColumnCenter */;
|
|
627
|
-
break;
|
|
628
|
-
case CursorMove.RawDirection.WrappedLineEnd:
|
|
629
|
-
direction = 9 /* Direction.WrappedLineEnd */;
|
|
630
|
-
break;
|
|
631
|
-
case CursorMove.RawDirection.WrappedLineLastNonWhitespaceCharacter:
|
|
632
|
-
direction = 10 /* Direction.WrappedLineLastNonWhitespaceCharacter */;
|
|
633
|
-
break;
|
|
634
|
-
case CursorMove.RawDirection.ViewPortTop:
|
|
635
|
-
direction = 11 /* Direction.ViewPortTop */;
|
|
636
|
-
break;
|
|
637
|
-
case CursorMove.RawDirection.ViewPortBottom:
|
|
638
|
-
direction = 13 /* Direction.ViewPortBottom */;
|
|
639
|
-
break;
|
|
640
|
-
case CursorMove.RawDirection.ViewPortCenter:
|
|
641
|
-
direction = 12 /* Direction.ViewPortCenter */;
|
|
642
|
-
break;
|
|
643
|
-
case CursorMove.RawDirection.ViewPortIfOutside:
|
|
644
|
-
direction = 14 /* Direction.ViewPortIfOutside */;
|
|
645
|
-
break;
|
|
646
|
-
default:
|
|
647
|
-
// illegal arguments
|
|
648
|
-
return null;
|
|
649
|
-
}
|
|
650
|
-
let unit = 0 /* Unit.None */;
|
|
651
|
-
switch (args.by) {
|
|
652
|
-
case CursorMove.RawUnit.Line:
|
|
653
|
-
unit = 1 /* Unit.Line */;
|
|
654
|
-
break;
|
|
655
|
-
case CursorMove.RawUnit.WrappedLine:
|
|
656
|
-
unit = 2 /* Unit.WrappedLine */;
|
|
657
|
-
break;
|
|
658
|
-
case CursorMove.RawUnit.Character:
|
|
659
|
-
unit = 3 /* Unit.Character */;
|
|
660
|
-
break;
|
|
661
|
-
case CursorMove.RawUnit.HalfLine:
|
|
662
|
-
unit = 4 /* Unit.HalfLine */;
|
|
663
|
-
break;
|
|
664
|
-
}
|
|
665
|
-
return {
|
|
666
|
-
direction: direction,
|
|
667
|
-
unit: unit,
|
|
668
|
-
select: (!!args.select),
|
|
669
|
-
value: (args.value || 1),
|
|
670
|
-
noHistory: (!!args.noHistory)
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
CursorMove.parse = parse;
|
|
674
|
-
})(CursorMove || (CursorMove = {}));
|
|
675
|
-
|
|
676
|
-
export { CursorMove, CursorMoveCommands };
|