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,23 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
class EditorTheme {
|
|
6
|
+
get type() {
|
|
7
|
+
return this._theme.type;
|
|
8
|
+
}
|
|
9
|
+
get value() {
|
|
10
|
+
return this._theme;
|
|
11
|
+
}
|
|
12
|
+
constructor(theme) {
|
|
13
|
+
this._theme = theme;
|
|
14
|
+
}
|
|
15
|
+
update(theme) {
|
|
16
|
+
this._theme = theme;
|
|
17
|
+
}
|
|
18
|
+
getColor(color) {
|
|
19
|
+
return this._theme.getColor(color);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { EditorTheme };
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { stringDiff } from '../../../base/common/diff/diff.js';
|
|
2
|
+
import { Range } from '../core/range.js';
|
|
3
|
+
import { computeLinks } from '../languages/linkComputer.js';
|
|
4
|
+
import { BasicInplaceReplace } from '../languages/supports/inplaceReplaceSupport.js';
|
|
5
|
+
import { createMonacoBaseAPI } from './editorBaseApi.js';
|
|
6
|
+
import { StopWatch } from '../../../base/common/stopwatch.js';
|
|
7
|
+
import { UnicodeTextModelHighlighter } from './unicodeTextModelHighlighter.js';
|
|
8
|
+
import { linesDiffComputers } from '../diff/linesDiffComputers.js';
|
|
9
|
+
import { computeDefaultDocumentColors } from '../languages/defaultDocumentColorsComputer.js';
|
|
10
|
+
import { findSectionHeaders } from './findSectionHeaders.js';
|
|
11
|
+
import { WorkerTextModelSyncServer } from './textModelSync/textModelSync.impl.js';
|
|
12
|
+
|
|
13
|
+
/*---------------------------------------------------------------------------------------------
|
|
14
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
16
|
+
*--------------------------------------------------------------------------------------------*/
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
class EditorWorker {
|
|
21
|
+
constructor(_foreignModule = null) {
|
|
22
|
+
this._foreignModule = _foreignModule;
|
|
23
|
+
this._requestHandlerBrand = undefined;
|
|
24
|
+
this._workerTextModelSyncServer = new WorkerTextModelSyncServer();
|
|
25
|
+
}
|
|
26
|
+
dispose() {
|
|
27
|
+
}
|
|
28
|
+
async $ping() {
|
|
29
|
+
return 'pong';
|
|
30
|
+
}
|
|
31
|
+
_getModel(uri) {
|
|
32
|
+
return this._workerTextModelSyncServer.getModel(uri);
|
|
33
|
+
}
|
|
34
|
+
getModels() {
|
|
35
|
+
return this._workerTextModelSyncServer.getModels();
|
|
36
|
+
}
|
|
37
|
+
$acceptNewModel(data) {
|
|
38
|
+
this._workerTextModelSyncServer.$acceptNewModel(data);
|
|
39
|
+
}
|
|
40
|
+
$acceptModelChanged(uri, e) {
|
|
41
|
+
this._workerTextModelSyncServer.$acceptModelChanged(uri, e);
|
|
42
|
+
}
|
|
43
|
+
$acceptRemovedModel(uri) {
|
|
44
|
+
this._workerTextModelSyncServer.$acceptRemovedModel(uri);
|
|
45
|
+
}
|
|
46
|
+
async $computeUnicodeHighlights(url, options, range) {
|
|
47
|
+
const model = this._getModel(url);
|
|
48
|
+
if (!model) {
|
|
49
|
+
return { ranges: [], hasMore: false, ambiguousCharacterCount: 0, invisibleCharacterCount: 0, nonBasicAsciiCharacterCount: 0 };
|
|
50
|
+
}
|
|
51
|
+
return UnicodeTextModelHighlighter.computeUnicodeHighlights(model, options, range);
|
|
52
|
+
}
|
|
53
|
+
async $findSectionHeaders(url, options) {
|
|
54
|
+
const model = this._getModel(url);
|
|
55
|
+
if (!model) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
return findSectionHeaders(model, options);
|
|
59
|
+
}
|
|
60
|
+
// ---- BEGIN diff --------------------------------------------------------------------------
|
|
61
|
+
async $computeDiff(originalUrl, modifiedUrl, options, algorithm) {
|
|
62
|
+
const original = this._getModel(originalUrl);
|
|
63
|
+
const modified = this._getModel(modifiedUrl);
|
|
64
|
+
if (!original || !modified) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const result = EditorWorker.computeDiff(original, modified, options, algorithm);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
static computeDiff(originalTextModel, modifiedTextModel, options, algorithm) {
|
|
71
|
+
const diffAlgorithm = algorithm === 'advanced' ? linesDiffComputers.getDefault() : linesDiffComputers.getLegacy();
|
|
72
|
+
const originalLines = originalTextModel.getLinesContent();
|
|
73
|
+
const modifiedLines = modifiedTextModel.getLinesContent();
|
|
74
|
+
const result = diffAlgorithm.computeDiff(originalLines, modifiedLines, options);
|
|
75
|
+
const identical = (result.changes.length > 0 ? false : this._modelsAreIdentical(originalTextModel, modifiedTextModel));
|
|
76
|
+
function getLineChanges(changes) {
|
|
77
|
+
return changes.map(m => ([m.original.startLineNumber, m.original.endLineNumberExclusive, m.modified.startLineNumber, m.modified.endLineNumberExclusive, m.innerChanges?.map(m => [
|
|
78
|
+
m.originalRange.startLineNumber,
|
|
79
|
+
m.originalRange.startColumn,
|
|
80
|
+
m.originalRange.endLineNumber,
|
|
81
|
+
m.originalRange.endColumn,
|
|
82
|
+
m.modifiedRange.startLineNumber,
|
|
83
|
+
m.modifiedRange.startColumn,
|
|
84
|
+
m.modifiedRange.endLineNumber,
|
|
85
|
+
m.modifiedRange.endColumn,
|
|
86
|
+
])]));
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
identical,
|
|
90
|
+
quitEarly: result.hitTimeout,
|
|
91
|
+
changes: getLineChanges(result.changes),
|
|
92
|
+
moves: result.moves.map(m => ([
|
|
93
|
+
m.lineRangeMapping.original.startLineNumber,
|
|
94
|
+
m.lineRangeMapping.original.endLineNumberExclusive,
|
|
95
|
+
m.lineRangeMapping.modified.startLineNumber,
|
|
96
|
+
m.lineRangeMapping.modified.endLineNumberExclusive,
|
|
97
|
+
getLineChanges(m.changes)
|
|
98
|
+
])),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
static _modelsAreIdentical(original, modified) {
|
|
102
|
+
const originalLineCount = original.getLineCount();
|
|
103
|
+
const modifiedLineCount = modified.getLineCount();
|
|
104
|
+
if (originalLineCount !== modifiedLineCount) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
for (let line = 1; line <= originalLineCount; line++) {
|
|
108
|
+
const originalLine = original.getLineContent(line);
|
|
109
|
+
const modifiedLine = modified.getLineContent(line);
|
|
110
|
+
if (originalLine !== modifiedLine) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
// ---- END diff --------------------------------------------------------------------------
|
|
117
|
+
// ---- BEGIN minimal edits ---------------------------------------------------------------
|
|
118
|
+
static { this._diffLimit = 100000; }
|
|
119
|
+
async $computeMoreMinimalEdits(modelUrl, edits, pretty) {
|
|
120
|
+
const model = this._getModel(modelUrl);
|
|
121
|
+
if (!model) {
|
|
122
|
+
return edits;
|
|
123
|
+
}
|
|
124
|
+
const result = [];
|
|
125
|
+
let lastEol = undefined;
|
|
126
|
+
edits = edits.slice(0).sort((a, b) => {
|
|
127
|
+
if (a.range && b.range) {
|
|
128
|
+
return Range.compareRangesUsingStarts(a.range, b.range);
|
|
129
|
+
}
|
|
130
|
+
// eol only changes should go to the end
|
|
131
|
+
const aRng = a.range ? 0 : 1;
|
|
132
|
+
const bRng = b.range ? 0 : 1;
|
|
133
|
+
return aRng - bRng;
|
|
134
|
+
});
|
|
135
|
+
// merge adjacent edits
|
|
136
|
+
let writeIndex = 0;
|
|
137
|
+
for (let readIndex = 1; readIndex < edits.length; readIndex++) {
|
|
138
|
+
if (Range.getEndPosition(edits[writeIndex].range).equals(Range.getStartPosition(edits[readIndex].range))) {
|
|
139
|
+
edits[writeIndex].range = Range.fromPositions(Range.getStartPosition(edits[writeIndex].range), Range.getEndPosition(edits[readIndex].range));
|
|
140
|
+
edits[writeIndex].text += edits[readIndex].text;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
writeIndex++;
|
|
144
|
+
edits[writeIndex] = edits[readIndex];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
edits.length = writeIndex + 1;
|
|
148
|
+
for (let { range, text, eol } of edits) {
|
|
149
|
+
if (typeof eol === 'number') {
|
|
150
|
+
lastEol = eol;
|
|
151
|
+
}
|
|
152
|
+
if (Range.isEmpty(range) && !text) {
|
|
153
|
+
// empty change
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const original = model.getValueInRange(range);
|
|
157
|
+
text = text.replace(/\r\n|\n|\r/g, model.eol);
|
|
158
|
+
if (original === text) {
|
|
159
|
+
// noop
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
// make sure diff won't take too long
|
|
163
|
+
if (Math.max(text.length, original.length) > EditorWorker._diffLimit) {
|
|
164
|
+
result.push({ range, text });
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// compute diff between original and edit.text
|
|
168
|
+
const changes = stringDiff(original, text, pretty);
|
|
169
|
+
const editOffset = model.offsetAt(Range.lift(range).getStartPosition());
|
|
170
|
+
for (const change of changes) {
|
|
171
|
+
const start = model.positionAt(editOffset + change.originalStart);
|
|
172
|
+
const end = model.positionAt(editOffset + change.originalStart + change.originalLength);
|
|
173
|
+
const newEdit = {
|
|
174
|
+
text: text.substr(change.modifiedStart, change.modifiedLength),
|
|
175
|
+
range: { startLineNumber: start.lineNumber, startColumn: start.column, endLineNumber: end.lineNumber, endColumn: end.column }
|
|
176
|
+
};
|
|
177
|
+
if (model.getValueInRange(newEdit.range) !== newEdit.text) {
|
|
178
|
+
result.push(newEdit);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (typeof lastEol === 'number') {
|
|
183
|
+
result.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
// ---- END minimal edits ---------------------------------------------------------------
|
|
188
|
+
async $computeLinks(modelUrl) {
|
|
189
|
+
const model = this._getModel(modelUrl);
|
|
190
|
+
if (!model) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return computeLinks(model);
|
|
194
|
+
}
|
|
195
|
+
// --- BEGIN default document colors -----------------------------------------------------------
|
|
196
|
+
async $computeDefaultDocumentColors(modelUrl) {
|
|
197
|
+
const model = this._getModel(modelUrl);
|
|
198
|
+
if (!model) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
return computeDefaultDocumentColors(model);
|
|
202
|
+
}
|
|
203
|
+
// ---- BEGIN suggest --------------------------------------------------------------------------
|
|
204
|
+
static { this._suggestionsLimit = 10000; }
|
|
205
|
+
async $textualSuggest(modelUrls, leadingWord, wordDef, wordDefFlags) {
|
|
206
|
+
const sw = new StopWatch();
|
|
207
|
+
const wordDefRegExp = new RegExp(wordDef, wordDefFlags);
|
|
208
|
+
const seen = new Set();
|
|
209
|
+
outer: for (const url of modelUrls) {
|
|
210
|
+
const model = this._getModel(url);
|
|
211
|
+
if (!model) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
for (const word of model.words(wordDefRegExp)) {
|
|
215
|
+
if (word === leadingWord || !isNaN(Number(word))) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
seen.add(word);
|
|
219
|
+
if (seen.size > EditorWorker._suggestionsLimit) {
|
|
220
|
+
break outer;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return { words: Array.from(seen), duration: sw.elapsed() };
|
|
225
|
+
}
|
|
226
|
+
// ---- END suggest --------------------------------------------------------------------------
|
|
227
|
+
//#region -- word ranges --
|
|
228
|
+
async $computeWordRanges(modelUrl, range, wordDef, wordDefFlags) {
|
|
229
|
+
const model = this._getModel(modelUrl);
|
|
230
|
+
if (!model) {
|
|
231
|
+
return Object.create(null);
|
|
232
|
+
}
|
|
233
|
+
const wordDefRegExp = new RegExp(wordDef, wordDefFlags);
|
|
234
|
+
const result = Object.create(null);
|
|
235
|
+
for (let line = range.startLineNumber; line < range.endLineNumber; line++) {
|
|
236
|
+
const words = model.getLineWords(line, wordDefRegExp);
|
|
237
|
+
for (const word of words) {
|
|
238
|
+
if (!isNaN(Number(word.word))) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
let array = result[word.word];
|
|
242
|
+
if (!array) {
|
|
243
|
+
array = [];
|
|
244
|
+
result[word.word] = array;
|
|
245
|
+
}
|
|
246
|
+
array.push({
|
|
247
|
+
startLineNumber: line,
|
|
248
|
+
startColumn: word.startColumn,
|
|
249
|
+
endLineNumber: line,
|
|
250
|
+
endColumn: word.endColumn
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
async $navigateValueSet(modelUrl, range, up, wordDef, wordDefFlags) {
|
|
258
|
+
const model = this._getModel(modelUrl);
|
|
259
|
+
if (!model) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
const wordDefRegExp = new RegExp(wordDef, wordDefFlags);
|
|
263
|
+
if (range.startColumn === range.endColumn) {
|
|
264
|
+
range = {
|
|
265
|
+
startLineNumber: range.startLineNumber,
|
|
266
|
+
startColumn: range.startColumn,
|
|
267
|
+
endLineNumber: range.endLineNumber,
|
|
268
|
+
endColumn: range.endColumn + 1
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const selectionText = model.getValueInRange(range);
|
|
272
|
+
const wordRange = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn }, wordDefRegExp);
|
|
273
|
+
if (!wordRange) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
const word = model.getValueInRange(wordRange);
|
|
277
|
+
const result = BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
// ---- BEGIN foreign module support --------------------------------------------------------------------------
|
|
281
|
+
// foreign method request
|
|
282
|
+
$fmr(method, args) {
|
|
283
|
+
if (!this._foreignModule || typeof this._foreignModule[method] !== 'function') {
|
|
284
|
+
return Promise.reject(new Error('Missing requestHandler or method: ' + method));
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
return Promise.resolve(this._foreignModule[method].apply(this._foreignModule, args));
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
return Promise.reject(e);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (typeof importScripts === 'function') {
|
|
295
|
+
// Running in a web worker
|
|
296
|
+
globalThis.monaco = createMonacoBaseAPI();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export { EditorWorker };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createDecorator } from '../../../platform/instantiation/common/instantiation.js';
|
|
2
|
+
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
const IEditorWorkerService = createDecorator('editorWorkerService');
|
|
8
|
+
|
|
9
|
+
export { IEditorWorkerService };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
class EditorWorkerHost {
|
|
6
|
+
static { this.CHANNEL_NAME = 'editorWorkerHost'; }
|
|
7
|
+
static getChannel(workerServer) {
|
|
8
|
+
return workerServer.getChannel(EditorWorkerHost.CHANNEL_NAME);
|
|
9
|
+
}
|
|
10
|
+
static setChannel(workerClient, obj) {
|
|
11
|
+
workerClient.setChannel(EditorWorkerHost.CHANNEL_NAME, obj);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { EditorWorkerHost };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Emitter } from '../../../base/common/event.js';
|
|
2
|
+
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
const EditorZoom = new class {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._zoomLevel = 0;
|
|
10
|
+
this._onDidChangeZoomLevel = new Emitter();
|
|
11
|
+
this.onDidChangeZoomLevel = this._onDidChangeZoomLevel.event;
|
|
12
|
+
}
|
|
13
|
+
getZoomLevel() {
|
|
14
|
+
return this._zoomLevel;
|
|
15
|
+
}
|
|
16
|
+
setZoomLevel(zoomLevel) {
|
|
17
|
+
zoomLevel = Math.min(Math.max(-5, zoomLevel), 20);
|
|
18
|
+
if (this._zoomLevel === zoomLevel) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this._zoomLevel = zoomLevel;
|
|
22
|
+
this._onDidChangeZoomLevel.fire(this._zoomLevel);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { EditorZoom };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { distinct } from '../../../../base/common/arrays.js';
|
|
2
|
+
import { ignoreBracketsInToken } from '../supports.js';
|
|
3
|
+
import { BracketsUtils } from './richEditBrackets.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 BracketElectricCharacterSupport {
|
|
10
|
+
constructor(richEditBrackets) {
|
|
11
|
+
this._richEditBrackets = richEditBrackets;
|
|
12
|
+
}
|
|
13
|
+
getElectricCharacters() {
|
|
14
|
+
const result = [];
|
|
15
|
+
if (this._richEditBrackets) {
|
|
16
|
+
for (const bracket of this._richEditBrackets.brackets) {
|
|
17
|
+
for (const close of bracket.close) {
|
|
18
|
+
const lastChar = close.charAt(close.length - 1);
|
|
19
|
+
result.push(lastChar);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return distinct(result);
|
|
24
|
+
}
|
|
25
|
+
onElectricCharacter(character, context, column) {
|
|
26
|
+
if (!this._richEditBrackets || this._richEditBrackets.brackets.length === 0) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const tokenIndex = context.findTokenIndexAtOffset(column - 1);
|
|
30
|
+
if (ignoreBracketsInToken(context.getStandardTokenType(tokenIndex))) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const reversedBracketRegex = this._richEditBrackets.reversedRegex;
|
|
34
|
+
const text = context.getLineContent().substring(0, column - 1) + character;
|
|
35
|
+
const r = BracketsUtils.findPrevBracketInRange(reversedBracketRegex, 1, text, 0, text.length);
|
|
36
|
+
if (!r) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const bracketText = text.substring(r.startColumn - 1, r.endColumn - 1).toLowerCase();
|
|
40
|
+
const isOpen = this._richEditBrackets.textIsOpenBracket[bracketText];
|
|
41
|
+
if (isOpen) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const textBeforeBracket = context.getActualLineContentBefore(r.startColumn - 1);
|
|
45
|
+
if (!/^\s*$/.test(textBeforeBracket)) {
|
|
46
|
+
// There is other text on the line before the bracket
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
matchOpenBracket: bracketText
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { BracketElectricCharacterSupport };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
*/
|
|
7
|
+
class TokenMetadata {
|
|
8
|
+
static getLanguageId(metadata) {
|
|
9
|
+
return (metadata & 255 /* MetadataConsts.LANGUAGEID_MASK */) >>> 0 /* MetadataConsts.LANGUAGEID_OFFSET */;
|
|
10
|
+
}
|
|
11
|
+
static getTokenType(metadata) {
|
|
12
|
+
return (metadata & 768 /* MetadataConsts.TOKEN_TYPE_MASK */) >>> 8 /* MetadataConsts.TOKEN_TYPE_OFFSET */;
|
|
13
|
+
}
|
|
14
|
+
static containsBalancedBrackets(metadata) {
|
|
15
|
+
return (metadata & 1024 /* MetadataConsts.BALANCED_BRACKETS_MASK */) !== 0;
|
|
16
|
+
}
|
|
17
|
+
static getFontStyle(metadata) {
|
|
18
|
+
return (metadata & 30720 /* MetadataConsts.FONT_STYLE_MASK */) >>> 11 /* MetadataConsts.FONT_STYLE_OFFSET */;
|
|
19
|
+
}
|
|
20
|
+
static getForeground(metadata) {
|
|
21
|
+
return (metadata & 16744448 /* MetadataConsts.FOREGROUND_MASK */) >>> 15 /* MetadataConsts.FOREGROUND_OFFSET */;
|
|
22
|
+
}
|
|
23
|
+
static getBackground(metadata) {
|
|
24
|
+
return (metadata & 4278190080 /* MetadataConsts.BACKGROUND_MASK */) >>> 24 /* MetadataConsts.BACKGROUND_OFFSET */;
|
|
25
|
+
}
|
|
26
|
+
static getClassNameFromMetadata(metadata) {
|
|
27
|
+
const foreground = this.getForeground(metadata);
|
|
28
|
+
let className = 'mtk' + foreground;
|
|
29
|
+
const fontStyle = this.getFontStyle(metadata);
|
|
30
|
+
if (fontStyle & 1 /* FontStyle.Italic */) {
|
|
31
|
+
className += ' mtki';
|
|
32
|
+
}
|
|
33
|
+
if (fontStyle & 2 /* FontStyle.Bold */) {
|
|
34
|
+
className += ' mtkb';
|
|
35
|
+
}
|
|
36
|
+
if (fontStyle & 4 /* FontStyle.Underline */) {
|
|
37
|
+
className += ' mtku';
|
|
38
|
+
}
|
|
39
|
+
if (fontStyle & 8 /* FontStyle.Strikethrough */) {
|
|
40
|
+
className += ' mtks';
|
|
41
|
+
}
|
|
42
|
+
return className;
|
|
43
|
+
}
|
|
44
|
+
static getInlineStyleFromMetadata(metadata, colorMap) {
|
|
45
|
+
const foreground = this.getForeground(metadata);
|
|
46
|
+
const fontStyle = this.getFontStyle(metadata);
|
|
47
|
+
let result = `color: ${colorMap[foreground]};`;
|
|
48
|
+
if (fontStyle & 1 /* FontStyle.Italic */) {
|
|
49
|
+
result += 'font-style: italic;';
|
|
50
|
+
}
|
|
51
|
+
if (fontStyle & 2 /* FontStyle.Bold */) {
|
|
52
|
+
result += 'font-weight: bold;';
|
|
53
|
+
}
|
|
54
|
+
let textDecoration = '';
|
|
55
|
+
if (fontStyle & 4 /* FontStyle.Underline */) {
|
|
56
|
+
textDecoration += ' underline';
|
|
57
|
+
}
|
|
58
|
+
if (fontStyle & 8 /* FontStyle.Strikethrough */) {
|
|
59
|
+
textDecoration += ' line-through';
|
|
60
|
+
}
|
|
61
|
+
if (textDecoration) {
|
|
62
|
+
result += `text-decoration:${textDecoration};`;
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
static getPresentationFromMetadata(metadata) {
|
|
67
|
+
const foreground = this.getForeground(metadata);
|
|
68
|
+
const fontStyle = this.getFontStyle(metadata);
|
|
69
|
+
return {
|
|
70
|
+
foreground: foreground,
|
|
71
|
+
italic: Boolean(fontStyle & 1 /* FontStyle.Italic */),
|
|
72
|
+
bold: Boolean(fontStyle & 2 /* FontStyle.Bold */),
|
|
73
|
+
underline: Boolean(fontStyle & 4 /* FontStyle.Underline */),
|
|
74
|
+
strikethrough: Boolean(fontStyle & 8 /* FontStyle.Strikethrough */),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { TokenMetadata };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IndentAction } from './languageConfiguration.js';
|
|
2
|
+
import { getIndentationAtPosition } from './languageConfigurationRegistry.js';
|
|
3
|
+
import { IndentationContextProcessor } from './supports/indentationLineProcessor.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
|
+
function getEnterAction(autoIndent, model, range, languageConfigurationService) {
|
|
10
|
+
model.tokenization.forceTokenization(range.startLineNumber);
|
|
11
|
+
const languageId = model.getLanguageIdAtPosition(range.startLineNumber, range.startColumn);
|
|
12
|
+
const richEditSupport = languageConfigurationService.getLanguageConfiguration(languageId);
|
|
13
|
+
if (!richEditSupport) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const indentationContextProcessor = new IndentationContextProcessor(model, languageConfigurationService);
|
|
17
|
+
const processedContextTokens = indentationContextProcessor.getProcessedTokenContextAroundRange(range);
|
|
18
|
+
const previousLineText = processedContextTokens.previousLineProcessedTokens.getLineContent();
|
|
19
|
+
const beforeEnterText = processedContextTokens.beforeRangeProcessedTokens.getLineContent();
|
|
20
|
+
const afterEnterText = processedContextTokens.afterRangeProcessedTokens.getLineContent();
|
|
21
|
+
const enterResult = richEditSupport.onEnter(autoIndent, previousLineText, beforeEnterText, afterEnterText);
|
|
22
|
+
if (!enterResult) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const indentAction = enterResult.indentAction;
|
|
26
|
+
let appendText = enterResult.appendText;
|
|
27
|
+
const removeText = enterResult.removeText || 0;
|
|
28
|
+
// Here we add `\t` to appendText first because enterAction is leveraging appendText and removeText to change indentation.
|
|
29
|
+
if (!appendText) {
|
|
30
|
+
if ((indentAction === IndentAction.Indent) ||
|
|
31
|
+
(indentAction === IndentAction.IndentOutdent)) {
|
|
32
|
+
appendText = '\t';
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
appendText = '';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (indentAction === IndentAction.Indent) {
|
|
39
|
+
appendText = '\t' + appendText;
|
|
40
|
+
}
|
|
41
|
+
let indentation = getIndentationAtPosition(model, range.startLineNumber, range.startColumn);
|
|
42
|
+
if (removeText) {
|
|
43
|
+
indentation = indentation.substring(0, indentation.length - removeText);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
indentAction: indentAction,
|
|
47
|
+
appendText: appendText,
|
|
48
|
+
removeText: removeText,
|
|
49
|
+
indentation: indentation
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { getEnterAction };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
function countEOL(text) {
|
|
6
|
+
let eolCount = 0;
|
|
7
|
+
let firstLineLength = 0;
|
|
8
|
+
let lastLineStart = 0;
|
|
9
|
+
let eol = 0 /* StringEOL.Unknown */;
|
|
10
|
+
for (let i = 0, len = text.length; i < len; i++) {
|
|
11
|
+
const chr = text.charCodeAt(i);
|
|
12
|
+
if (chr === 13 /* CharCode.CarriageReturn */) {
|
|
13
|
+
if (eolCount === 0) {
|
|
14
|
+
firstLineLength = i;
|
|
15
|
+
}
|
|
16
|
+
eolCount++;
|
|
17
|
+
if (i + 1 < len && text.charCodeAt(i + 1) === 10 /* CharCode.LineFeed */) {
|
|
18
|
+
// \r\n... case
|
|
19
|
+
eol |= 2 /* StringEOL.CRLF */;
|
|
20
|
+
i++; // skip \n
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// \r... case
|
|
24
|
+
eol |= 3 /* StringEOL.Invalid */;
|
|
25
|
+
}
|
|
26
|
+
lastLineStart = i + 1;
|
|
27
|
+
}
|
|
28
|
+
else if (chr === 10 /* CharCode.LineFeed */) {
|
|
29
|
+
// \n... case
|
|
30
|
+
eol |= 1 /* StringEOL.LF */;
|
|
31
|
+
if (eolCount === 0) {
|
|
32
|
+
firstLineLength = i;
|
|
33
|
+
}
|
|
34
|
+
eolCount++;
|
|
35
|
+
lastLineStart = i + 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (eolCount === 0) {
|
|
39
|
+
firstLineLength = text.length;
|
|
40
|
+
}
|
|
41
|
+
return [eolCount, firstLineLength, text.length - lastLineStart, eol];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { countEOL };
|