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,183 @@
|
|
|
1
|
+
import { BugIndicatingError } from '../../../../base/common/errors.js';
|
|
2
|
+
import { OffsetRange } from '../ranges/offsetRange.js';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
class BaseEdit {
|
|
6
|
+
constructor(replacements) {
|
|
7
|
+
this.replacements = replacements;
|
|
8
|
+
let lastEndEx = -1;
|
|
9
|
+
for (const replacement of replacements) {
|
|
10
|
+
if (!(replacement.replaceRange.start >= lastEndEx)) {
|
|
11
|
+
throw new BugIndicatingError(`Edits must be disjoint and sorted. Found ${replacement} after ${lastEndEx}`);
|
|
12
|
+
}
|
|
13
|
+
lastEndEx = replacement.replaceRange.endExclusive;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
const edits = this.replacements.map(e => e.toString()).join(', ');
|
|
18
|
+
return `[${edits}]`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Normalizes the edit by removing empty replacements and joining touching replacements (if the replacements allow joining).
|
|
22
|
+
* Two edits have an equal normalized edit if and only if they have the same effect on any input.
|
|
23
|
+
*
|
|
24
|
+
* 
|
|
25
|
+
*
|
|
26
|
+
* Invariant:
|
|
27
|
+
* ```
|
|
28
|
+
* (forall base: TEdit.apply(base).equals(other.apply(base))) <-> this.normalize().equals(other.normalize())
|
|
29
|
+
* ```
|
|
30
|
+
* and
|
|
31
|
+
* ```
|
|
32
|
+
* forall base: TEdit.apply(base).equals(this.normalize().apply(base))
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
normalize() {
|
|
37
|
+
const newReplacements = [];
|
|
38
|
+
let lastReplacement;
|
|
39
|
+
for (const r of this.replacements) {
|
|
40
|
+
if (r.getNewLength() === 0 && r.replaceRange.length === 0) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (lastReplacement && lastReplacement.replaceRange.endExclusive === r.replaceRange.start) {
|
|
44
|
+
const joined = lastReplacement.tryJoinTouching(r);
|
|
45
|
+
if (joined) {
|
|
46
|
+
lastReplacement = joined;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (lastReplacement) {
|
|
51
|
+
newReplacements.push(lastReplacement);
|
|
52
|
+
}
|
|
53
|
+
lastReplacement = r;
|
|
54
|
+
}
|
|
55
|
+
if (lastReplacement) {
|
|
56
|
+
newReplacements.push(lastReplacement);
|
|
57
|
+
}
|
|
58
|
+
return this._createNew(newReplacements);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Combines two edits into one with the same effect.
|
|
62
|
+
*
|
|
63
|
+
* 
|
|
64
|
+
*
|
|
65
|
+
* Invariant:
|
|
66
|
+
* ```
|
|
67
|
+
* other.apply(this.apply(s0)) = this.compose(other).apply(s0)
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
compose(other) {
|
|
71
|
+
const edits1 = this.normalize();
|
|
72
|
+
const edits2 = other.normalize();
|
|
73
|
+
if (edits1.isEmpty()) {
|
|
74
|
+
return edits2;
|
|
75
|
+
}
|
|
76
|
+
if (edits2.isEmpty()) {
|
|
77
|
+
return edits1;
|
|
78
|
+
}
|
|
79
|
+
const edit1Queue = [...edits1.replacements];
|
|
80
|
+
const result = [];
|
|
81
|
+
let edit1ToEdit2 = 0;
|
|
82
|
+
for (const r2 of edits2.replacements) {
|
|
83
|
+
// Copy over edit1 unmodified until it touches edit2.
|
|
84
|
+
while (true) {
|
|
85
|
+
const r1 = edit1Queue[0];
|
|
86
|
+
if (!r1 || r1.replaceRange.start + edit1ToEdit2 + r1.getNewLength() >= r2.replaceRange.start) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
edit1Queue.shift();
|
|
90
|
+
result.push(r1);
|
|
91
|
+
edit1ToEdit2 += r1.getNewLength() - r1.replaceRange.length;
|
|
92
|
+
}
|
|
93
|
+
const firstEdit1ToEdit2 = edit1ToEdit2;
|
|
94
|
+
let firstIntersecting; // or touching
|
|
95
|
+
let lastIntersecting; // or touching
|
|
96
|
+
while (true) {
|
|
97
|
+
const r1 = edit1Queue[0];
|
|
98
|
+
if (!r1 || r1.replaceRange.start + edit1ToEdit2 > r2.replaceRange.endExclusive) {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
// else we intersect, because the new end of edit1 is after or equal to our start
|
|
102
|
+
if (!firstIntersecting) {
|
|
103
|
+
firstIntersecting = r1;
|
|
104
|
+
}
|
|
105
|
+
lastIntersecting = r1;
|
|
106
|
+
edit1Queue.shift();
|
|
107
|
+
edit1ToEdit2 += r1.getNewLength() - r1.replaceRange.length;
|
|
108
|
+
}
|
|
109
|
+
if (!firstIntersecting) {
|
|
110
|
+
result.push(r2.delta(-edit1ToEdit2));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const newReplaceRangeStart = Math.min(firstIntersecting.replaceRange.start, r2.replaceRange.start - firstEdit1ToEdit2);
|
|
114
|
+
const prefixLength = r2.replaceRange.start - (firstIntersecting.replaceRange.start + firstEdit1ToEdit2);
|
|
115
|
+
if (prefixLength > 0) {
|
|
116
|
+
const prefix = firstIntersecting.slice(OffsetRange.emptyAt(newReplaceRangeStart), new OffsetRange(0, prefixLength));
|
|
117
|
+
result.push(prefix);
|
|
118
|
+
}
|
|
119
|
+
if (!lastIntersecting) {
|
|
120
|
+
throw new BugIndicatingError(`Invariant violation: lastIntersecting is undefined`);
|
|
121
|
+
}
|
|
122
|
+
const suffixLength = (lastIntersecting.replaceRange.endExclusive + edit1ToEdit2) - r2.replaceRange.endExclusive;
|
|
123
|
+
if (suffixLength > 0) {
|
|
124
|
+
const e = lastIntersecting.slice(OffsetRange.ofStartAndLength(lastIntersecting.replaceRange.endExclusive, 0), new OffsetRange(lastIntersecting.getNewLength() - suffixLength, lastIntersecting.getNewLength()));
|
|
125
|
+
edit1Queue.unshift(e);
|
|
126
|
+
edit1ToEdit2 -= e.getNewLength() - e.replaceRange.length;
|
|
127
|
+
}
|
|
128
|
+
const newReplaceRange = new OffsetRange(newReplaceRangeStart, r2.replaceRange.endExclusive - edit1ToEdit2);
|
|
129
|
+
const middle = r2.slice(newReplaceRange, new OffsetRange(0, r2.getNewLength()));
|
|
130
|
+
result.push(middle);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
while (true) {
|
|
134
|
+
const item = edit1Queue.shift();
|
|
135
|
+
if (!item) {
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
result.push(item);
|
|
139
|
+
}
|
|
140
|
+
return this._createNew(result).normalize();
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Returns the range of each replacement in the applied value.
|
|
144
|
+
*/
|
|
145
|
+
getNewRanges() {
|
|
146
|
+
const ranges = [];
|
|
147
|
+
let offset = 0;
|
|
148
|
+
for (const e of this.replacements) {
|
|
149
|
+
ranges.push(OffsetRange.ofStartAndLength(e.replaceRange.start + offset, e.getNewLength()));
|
|
150
|
+
offset += e.getLengthDelta();
|
|
151
|
+
}
|
|
152
|
+
return ranges;
|
|
153
|
+
}
|
|
154
|
+
isEmpty() {
|
|
155
|
+
return this.replacements.length === 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
class BaseReplacement {
|
|
159
|
+
constructor(
|
|
160
|
+
/**
|
|
161
|
+
* The range to be replaced.
|
|
162
|
+
*/
|
|
163
|
+
replaceRange) {
|
|
164
|
+
this.replaceRange = replaceRange;
|
|
165
|
+
}
|
|
166
|
+
delta(offset) {
|
|
167
|
+
return this.slice(this.replaceRange.delta(offset), new OffsetRange(0, this.getNewLength()));
|
|
168
|
+
}
|
|
169
|
+
getLengthDelta() {
|
|
170
|
+
return this.getNewLength() - this.replaceRange.length;
|
|
171
|
+
}
|
|
172
|
+
toString() {
|
|
173
|
+
return `{ ${this.replaceRange.toString()} -> ${this.getNewLength()} }`;
|
|
174
|
+
}
|
|
175
|
+
get isEmpty() {
|
|
176
|
+
return this.getNewLength() === 0 && this.replaceRange.length === 0;
|
|
177
|
+
}
|
|
178
|
+
getRangeAfterReplace() {
|
|
179
|
+
return new OffsetRange(this.replaceRange.start, this.replaceRange.start + this.getNewLength());
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { BaseEdit, BaseReplacement };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Range } from './range.js';
|
|
2
|
+
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
class EditOperation {
|
|
8
|
+
static insert(position, text) {
|
|
9
|
+
return {
|
|
10
|
+
range: new Range(position.lineNumber, position.column, position.lineNumber, position.column),
|
|
11
|
+
text: text,
|
|
12
|
+
forceMoveMarkers: true
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
static delete(range) {
|
|
16
|
+
return {
|
|
17
|
+
range: range,
|
|
18
|
+
text: null
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static replace(range, text) {
|
|
22
|
+
return {
|
|
23
|
+
range: range,
|
|
24
|
+
text: text
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
static replaceMove(range, text) {
|
|
28
|
+
return {
|
|
29
|
+
range: range,
|
|
30
|
+
text: text,
|
|
31
|
+
forceMoveMarkers: true
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { EditOperation };
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { localize } from '../../../nls.js';
|
|
2
|
+
import { onUnexpectedError } from '../../../base/common/errors.js';
|
|
3
|
+
import { Selection } from '../core/selection.js';
|
|
4
|
+
import { URI } from '../../../base/common/uri.js';
|
|
5
|
+
import { compressConsecutiveTextChanges, TextChange } from '../core/textChange.js';
|
|
6
|
+
import { writeUInt32BE, readUInt32BE, writeUInt8, readUInt8 } from '../../../base/common/buffer.js';
|
|
7
|
+
import { basename } from '../../../base/common/resources.js';
|
|
8
|
+
import { EditSources } from '../textModelEditSource.js';
|
|
9
|
+
|
|
10
|
+
/*---------------------------------------------------------------------------------------------
|
|
11
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
13
|
+
*--------------------------------------------------------------------------------------------*/
|
|
14
|
+
function uriGetComparisonKey(resource) {
|
|
15
|
+
return resource.toString();
|
|
16
|
+
}
|
|
17
|
+
class SingleModelEditStackData {
|
|
18
|
+
static create(model, beforeCursorState) {
|
|
19
|
+
const alternativeVersionId = model.getAlternativeVersionId();
|
|
20
|
+
const eol = getModelEOL(model);
|
|
21
|
+
return new SingleModelEditStackData(alternativeVersionId, alternativeVersionId, eol, eol, beforeCursorState, beforeCursorState, []);
|
|
22
|
+
}
|
|
23
|
+
constructor(beforeVersionId, afterVersionId, beforeEOL, afterEOL, beforeCursorState, afterCursorState, changes) {
|
|
24
|
+
this.beforeVersionId = beforeVersionId;
|
|
25
|
+
this.afterVersionId = afterVersionId;
|
|
26
|
+
this.beforeEOL = beforeEOL;
|
|
27
|
+
this.afterEOL = afterEOL;
|
|
28
|
+
this.beforeCursorState = beforeCursorState;
|
|
29
|
+
this.afterCursorState = afterCursorState;
|
|
30
|
+
this.changes = changes;
|
|
31
|
+
}
|
|
32
|
+
append(model, textChanges, afterEOL, afterVersionId, afterCursorState) {
|
|
33
|
+
if (textChanges.length > 0) {
|
|
34
|
+
this.changes = compressConsecutiveTextChanges(this.changes, textChanges);
|
|
35
|
+
}
|
|
36
|
+
this.afterEOL = afterEOL;
|
|
37
|
+
this.afterVersionId = afterVersionId;
|
|
38
|
+
this.afterCursorState = afterCursorState;
|
|
39
|
+
}
|
|
40
|
+
static _writeSelectionsSize(selections) {
|
|
41
|
+
return 4 + 4 * 4 * (selections ? selections.length : 0);
|
|
42
|
+
}
|
|
43
|
+
static _writeSelections(b, selections, offset) {
|
|
44
|
+
writeUInt32BE(b, (selections ? selections.length : 0), offset);
|
|
45
|
+
offset += 4;
|
|
46
|
+
if (selections) {
|
|
47
|
+
for (const selection of selections) {
|
|
48
|
+
writeUInt32BE(b, selection.selectionStartLineNumber, offset);
|
|
49
|
+
offset += 4;
|
|
50
|
+
writeUInt32BE(b, selection.selectionStartColumn, offset);
|
|
51
|
+
offset += 4;
|
|
52
|
+
writeUInt32BE(b, selection.positionLineNumber, offset);
|
|
53
|
+
offset += 4;
|
|
54
|
+
writeUInt32BE(b, selection.positionColumn, offset);
|
|
55
|
+
offset += 4;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return offset;
|
|
59
|
+
}
|
|
60
|
+
static _readSelections(b, offset, dest) {
|
|
61
|
+
const count = readUInt32BE(b, offset);
|
|
62
|
+
offset += 4;
|
|
63
|
+
for (let i = 0; i < count; i++) {
|
|
64
|
+
const selectionStartLineNumber = readUInt32BE(b, offset);
|
|
65
|
+
offset += 4;
|
|
66
|
+
const selectionStartColumn = readUInt32BE(b, offset);
|
|
67
|
+
offset += 4;
|
|
68
|
+
const positionLineNumber = readUInt32BE(b, offset);
|
|
69
|
+
offset += 4;
|
|
70
|
+
const positionColumn = readUInt32BE(b, offset);
|
|
71
|
+
offset += 4;
|
|
72
|
+
dest.push(new Selection(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn));
|
|
73
|
+
}
|
|
74
|
+
return offset;
|
|
75
|
+
}
|
|
76
|
+
serialize() {
|
|
77
|
+
let necessarySize = (4 // beforeVersionId
|
|
78
|
+
+ 4 // afterVersionId
|
|
79
|
+
+ 1 // beforeEOL
|
|
80
|
+
+ 1 // afterEOL
|
|
81
|
+
+ SingleModelEditStackData._writeSelectionsSize(this.beforeCursorState)
|
|
82
|
+
+ SingleModelEditStackData._writeSelectionsSize(this.afterCursorState)
|
|
83
|
+
+ 4 // change count
|
|
84
|
+
);
|
|
85
|
+
for (const change of this.changes) {
|
|
86
|
+
necessarySize += change.writeSize();
|
|
87
|
+
}
|
|
88
|
+
const b = new Uint8Array(necessarySize);
|
|
89
|
+
let offset = 0;
|
|
90
|
+
writeUInt32BE(b, this.beforeVersionId, offset);
|
|
91
|
+
offset += 4;
|
|
92
|
+
writeUInt32BE(b, this.afterVersionId, offset);
|
|
93
|
+
offset += 4;
|
|
94
|
+
writeUInt8(b, this.beforeEOL, offset);
|
|
95
|
+
offset += 1;
|
|
96
|
+
writeUInt8(b, this.afterEOL, offset);
|
|
97
|
+
offset += 1;
|
|
98
|
+
offset = SingleModelEditStackData._writeSelections(b, this.beforeCursorState, offset);
|
|
99
|
+
offset = SingleModelEditStackData._writeSelections(b, this.afterCursorState, offset);
|
|
100
|
+
writeUInt32BE(b, this.changes.length, offset);
|
|
101
|
+
offset += 4;
|
|
102
|
+
for (const change of this.changes) {
|
|
103
|
+
offset = change.write(b, offset);
|
|
104
|
+
}
|
|
105
|
+
return b.buffer;
|
|
106
|
+
}
|
|
107
|
+
static deserialize(source) {
|
|
108
|
+
const b = new Uint8Array(source);
|
|
109
|
+
let offset = 0;
|
|
110
|
+
const beforeVersionId = readUInt32BE(b, offset);
|
|
111
|
+
offset += 4;
|
|
112
|
+
const afterVersionId = readUInt32BE(b, offset);
|
|
113
|
+
offset += 4;
|
|
114
|
+
const beforeEOL = readUInt8(b, offset);
|
|
115
|
+
offset += 1;
|
|
116
|
+
const afterEOL = readUInt8(b, offset);
|
|
117
|
+
offset += 1;
|
|
118
|
+
const beforeCursorState = [];
|
|
119
|
+
offset = SingleModelEditStackData._readSelections(b, offset, beforeCursorState);
|
|
120
|
+
const afterCursorState = [];
|
|
121
|
+
offset = SingleModelEditStackData._readSelections(b, offset, afterCursorState);
|
|
122
|
+
const changeCount = readUInt32BE(b, offset);
|
|
123
|
+
offset += 4;
|
|
124
|
+
const changes = [];
|
|
125
|
+
for (let i = 0; i < changeCount; i++) {
|
|
126
|
+
offset = TextChange.read(b, offset, changes);
|
|
127
|
+
}
|
|
128
|
+
return new SingleModelEditStackData(beforeVersionId, afterVersionId, beforeEOL, afterEOL, beforeCursorState, afterCursorState, changes);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
class SingleModelEditStackElement {
|
|
132
|
+
get type() {
|
|
133
|
+
return 0 /* UndoRedoElementType.Resource */;
|
|
134
|
+
}
|
|
135
|
+
get resource() {
|
|
136
|
+
if (URI.isUri(this.model)) {
|
|
137
|
+
return this.model;
|
|
138
|
+
}
|
|
139
|
+
return this.model.uri;
|
|
140
|
+
}
|
|
141
|
+
constructor(label, code, model, beforeCursorState) {
|
|
142
|
+
this.label = label;
|
|
143
|
+
this.code = code;
|
|
144
|
+
this.model = model;
|
|
145
|
+
this._data = SingleModelEditStackData.create(model, beforeCursorState);
|
|
146
|
+
}
|
|
147
|
+
toString() {
|
|
148
|
+
const data = (this._data instanceof SingleModelEditStackData ? this._data : SingleModelEditStackData.deserialize(this._data));
|
|
149
|
+
return data.changes.map(change => change.toString()).join(', ');
|
|
150
|
+
}
|
|
151
|
+
matchesResource(resource) {
|
|
152
|
+
const uri = (URI.isUri(this.model) ? this.model : this.model.uri);
|
|
153
|
+
return (uri.toString() === resource.toString());
|
|
154
|
+
}
|
|
155
|
+
setModel(model) {
|
|
156
|
+
this.model = model;
|
|
157
|
+
}
|
|
158
|
+
canAppend(model) {
|
|
159
|
+
return (this.model === model && this._data instanceof SingleModelEditStackData);
|
|
160
|
+
}
|
|
161
|
+
append(model, textChanges, afterEOL, afterVersionId, afterCursorState) {
|
|
162
|
+
if (this._data instanceof SingleModelEditStackData) {
|
|
163
|
+
this._data.append(model, textChanges, afterEOL, afterVersionId, afterCursorState);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
close() {
|
|
167
|
+
if (this._data instanceof SingleModelEditStackData) {
|
|
168
|
+
this._data = this._data.serialize();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
open() {
|
|
172
|
+
if (!(this._data instanceof SingleModelEditStackData)) {
|
|
173
|
+
this._data = SingleModelEditStackData.deserialize(this._data);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
undo() {
|
|
177
|
+
if (URI.isUri(this.model)) {
|
|
178
|
+
// don't have a model
|
|
179
|
+
throw new Error(`Invalid SingleModelEditStackElement`);
|
|
180
|
+
}
|
|
181
|
+
if (this._data instanceof SingleModelEditStackData) {
|
|
182
|
+
this._data = this._data.serialize();
|
|
183
|
+
}
|
|
184
|
+
const data = SingleModelEditStackData.deserialize(this._data);
|
|
185
|
+
this.model._applyUndo(data.changes, data.beforeEOL, data.beforeVersionId, data.beforeCursorState);
|
|
186
|
+
}
|
|
187
|
+
redo() {
|
|
188
|
+
if (URI.isUri(this.model)) {
|
|
189
|
+
// don't have a model
|
|
190
|
+
throw new Error(`Invalid SingleModelEditStackElement`);
|
|
191
|
+
}
|
|
192
|
+
if (this._data instanceof SingleModelEditStackData) {
|
|
193
|
+
this._data = this._data.serialize();
|
|
194
|
+
}
|
|
195
|
+
const data = SingleModelEditStackData.deserialize(this._data);
|
|
196
|
+
this.model._applyRedo(data.changes, data.afterEOL, data.afterVersionId, data.afterCursorState);
|
|
197
|
+
}
|
|
198
|
+
heapSize() {
|
|
199
|
+
if (this._data instanceof SingleModelEditStackData) {
|
|
200
|
+
this._data = this._data.serialize();
|
|
201
|
+
}
|
|
202
|
+
return this._data.byteLength + 168 /*heap overhead*/;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
class MultiModelEditStackElement {
|
|
206
|
+
get resources() {
|
|
207
|
+
return this._editStackElementsArr.map(editStackElement => editStackElement.resource);
|
|
208
|
+
}
|
|
209
|
+
constructor(label, code, editStackElements) {
|
|
210
|
+
this.label = label;
|
|
211
|
+
this.code = code;
|
|
212
|
+
this.type = 1 /* UndoRedoElementType.Workspace */;
|
|
213
|
+
this._isOpen = true;
|
|
214
|
+
this._editStackElementsArr = editStackElements.slice(0);
|
|
215
|
+
this._editStackElementsMap = new Map();
|
|
216
|
+
for (const editStackElement of this._editStackElementsArr) {
|
|
217
|
+
const key = uriGetComparisonKey(editStackElement.resource);
|
|
218
|
+
this._editStackElementsMap.set(key, editStackElement);
|
|
219
|
+
}
|
|
220
|
+
this._delegate = null;
|
|
221
|
+
}
|
|
222
|
+
prepareUndoRedo() {
|
|
223
|
+
if (this._delegate) {
|
|
224
|
+
return this._delegate.prepareUndoRedo(this);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
matchesResource(resource) {
|
|
228
|
+
const key = uriGetComparisonKey(resource);
|
|
229
|
+
return (this._editStackElementsMap.has(key));
|
|
230
|
+
}
|
|
231
|
+
setModel(model) {
|
|
232
|
+
const key = uriGetComparisonKey(URI.isUri(model) ? model : model.uri);
|
|
233
|
+
if (this._editStackElementsMap.has(key)) {
|
|
234
|
+
this._editStackElementsMap.get(key).setModel(model);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
canAppend(model) {
|
|
238
|
+
if (!this._isOpen) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
const key = uriGetComparisonKey(model.uri);
|
|
242
|
+
if (this._editStackElementsMap.has(key)) {
|
|
243
|
+
const editStackElement = this._editStackElementsMap.get(key);
|
|
244
|
+
return editStackElement.canAppend(model);
|
|
245
|
+
}
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
append(model, textChanges, afterEOL, afterVersionId, afterCursorState) {
|
|
249
|
+
const key = uriGetComparisonKey(model.uri);
|
|
250
|
+
const editStackElement = this._editStackElementsMap.get(key);
|
|
251
|
+
editStackElement.append(model, textChanges, afterEOL, afterVersionId, afterCursorState);
|
|
252
|
+
}
|
|
253
|
+
close() {
|
|
254
|
+
this._isOpen = false;
|
|
255
|
+
}
|
|
256
|
+
open() {
|
|
257
|
+
// cannot reopen
|
|
258
|
+
}
|
|
259
|
+
undo() {
|
|
260
|
+
this._isOpen = false;
|
|
261
|
+
for (const editStackElement of this._editStackElementsArr) {
|
|
262
|
+
editStackElement.undo();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
redo() {
|
|
266
|
+
for (const editStackElement of this._editStackElementsArr) {
|
|
267
|
+
editStackElement.redo();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
heapSize(resource) {
|
|
271
|
+
const key = uriGetComparisonKey(resource);
|
|
272
|
+
if (this._editStackElementsMap.has(key)) {
|
|
273
|
+
const editStackElement = this._editStackElementsMap.get(key);
|
|
274
|
+
return editStackElement.heapSize();
|
|
275
|
+
}
|
|
276
|
+
return 0;
|
|
277
|
+
}
|
|
278
|
+
split() {
|
|
279
|
+
return this._editStackElementsArr;
|
|
280
|
+
}
|
|
281
|
+
toString() {
|
|
282
|
+
const result = [];
|
|
283
|
+
for (const editStackElement of this._editStackElementsArr) {
|
|
284
|
+
result.push(`${basename(editStackElement.resource)}: ${editStackElement}`);
|
|
285
|
+
}
|
|
286
|
+
return `{${result.join(', ')}}`;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function getModelEOL(model) {
|
|
290
|
+
const eol = model.getEOL();
|
|
291
|
+
if (eol === '\n') {
|
|
292
|
+
return 0 /* EndOfLineSequence.LF */;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
return 1 /* EndOfLineSequence.CRLF */;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function isEditStackElement(element) {
|
|
299
|
+
if (!element) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
return ((element instanceof SingleModelEditStackElement) || (element instanceof MultiModelEditStackElement));
|
|
303
|
+
}
|
|
304
|
+
class EditStack {
|
|
305
|
+
constructor(model, undoRedoService) {
|
|
306
|
+
this._model = model;
|
|
307
|
+
this._undoRedoService = undoRedoService;
|
|
308
|
+
}
|
|
309
|
+
pushStackElement() {
|
|
310
|
+
const lastElement = this._undoRedoService.getLastElement(this._model.uri);
|
|
311
|
+
if (isEditStackElement(lastElement)) {
|
|
312
|
+
lastElement.close();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
popStackElement() {
|
|
316
|
+
const lastElement = this._undoRedoService.getLastElement(this._model.uri);
|
|
317
|
+
if (isEditStackElement(lastElement)) {
|
|
318
|
+
lastElement.open();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
clear() {
|
|
322
|
+
this._undoRedoService.removeElements(this._model.uri);
|
|
323
|
+
}
|
|
324
|
+
_getOrCreateEditStackElement(beforeCursorState, group) {
|
|
325
|
+
const lastElement = this._undoRedoService.getLastElement(this._model.uri);
|
|
326
|
+
if (isEditStackElement(lastElement) && lastElement.canAppend(this._model)) {
|
|
327
|
+
return lastElement;
|
|
328
|
+
}
|
|
329
|
+
const newElement = new SingleModelEditStackElement(localize(785, "Typing"), 'undoredo.textBufferEdit', this._model, beforeCursorState);
|
|
330
|
+
this._undoRedoService.pushElement(newElement, group);
|
|
331
|
+
return newElement;
|
|
332
|
+
}
|
|
333
|
+
pushEOL(eol) {
|
|
334
|
+
const editStackElement = this._getOrCreateEditStackElement(null, undefined);
|
|
335
|
+
this._model.setEOL(eol);
|
|
336
|
+
editStackElement.append(this._model, [], getModelEOL(this._model), this._model.getAlternativeVersionId(), null);
|
|
337
|
+
}
|
|
338
|
+
pushEditOperation(beforeCursorState, editOperations, cursorStateComputer, group, reason = EditSources.unknown({ name: 'pushEditOperation' })) {
|
|
339
|
+
const editStackElement = this._getOrCreateEditStackElement(beforeCursorState, group);
|
|
340
|
+
const inverseEditOperations = this._model.applyEdits(editOperations, true, reason);
|
|
341
|
+
const afterCursorState = EditStack._computeCursorState(cursorStateComputer, inverseEditOperations);
|
|
342
|
+
const textChanges = inverseEditOperations.map((op, index) => ({ index: index, textChange: op.textChange }));
|
|
343
|
+
textChanges.sort((a, b) => {
|
|
344
|
+
if (a.textChange.oldPosition === b.textChange.oldPosition) {
|
|
345
|
+
return a.index - b.index;
|
|
346
|
+
}
|
|
347
|
+
return a.textChange.oldPosition - b.textChange.oldPosition;
|
|
348
|
+
});
|
|
349
|
+
editStackElement.append(this._model, textChanges.map(op => op.textChange), getModelEOL(this._model), this._model.getAlternativeVersionId(), afterCursorState);
|
|
350
|
+
return afterCursorState;
|
|
351
|
+
}
|
|
352
|
+
static _computeCursorState(cursorStateComputer, inverseEditOperations) {
|
|
353
|
+
try {
|
|
354
|
+
return cursorStateComputer ? cursorStateComputer(inverseEditOperations) : null;
|
|
355
|
+
}
|
|
356
|
+
catch (e) {
|
|
357
|
+
onUnexpectedError(e);
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export { EditStack, MultiModelEditStackElement, SingleModelEditStackData, SingleModelEditStackElement, isEditStackElement };
|
|
@@ -0,0 +1,26 @@
|
|
|
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 InternalEditorAction {
|
|
6
|
+
constructor(id, label, alias, metadata, _precondition, _run, _contextKeyService) {
|
|
7
|
+
this.id = id;
|
|
8
|
+
this.label = label;
|
|
9
|
+
this.alias = alias;
|
|
10
|
+
this.metadata = metadata;
|
|
11
|
+
this._precondition = _precondition;
|
|
12
|
+
this._run = _run;
|
|
13
|
+
this._contextKeyService = _contextKeyService;
|
|
14
|
+
}
|
|
15
|
+
isSupported() {
|
|
16
|
+
return this._contextKeyService.contextMatchesRules(this._precondition);
|
|
17
|
+
}
|
|
18
|
+
run(args) {
|
|
19
|
+
if (!this.isSupported()) {
|
|
20
|
+
return Promise.resolve(undefined);
|
|
21
|
+
}
|
|
22
|
+
return this._run(args);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { InternalEditorAction };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CancellationTokenSource } from '../../../base/common/cancellation.js';
|
|
2
|
+
import { Emitter } from '../../../base/common/event.js';
|
|
3
|
+
import { KeyChord } from '../../../base/common/keyCodes.js';
|
|
4
|
+
import { URI } from '../../../base/common/uri.js';
|
|
5
|
+
import { Position } from '../core/position.js';
|
|
6
|
+
import { Range } from '../core/range.js';
|
|
7
|
+
import { Selection } from '../core/selection.js';
|
|
8
|
+
import { Token } from '../languages.js';
|
|
9
|
+
import { MarkerTag, MarkerSeverity, SelectionDirection, KeyCode } from '../standalone/standaloneEnums.js';
|
|
10
|
+
|
|
11
|
+
/*---------------------------------------------------------------------------------------------
|
|
12
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
13
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
14
|
+
*--------------------------------------------------------------------------------------------*/
|
|
15
|
+
class KeyMod {
|
|
16
|
+
static { this.CtrlCmd = 2048 /* ConstKeyMod.CtrlCmd */; }
|
|
17
|
+
static { this.Shift = 1024 /* ConstKeyMod.Shift */; }
|
|
18
|
+
static { this.Alt = 512 /* ConstKeyMod.Alt */; }
|
|
19
|
+
static { this.WinCtrl = 256 /* ConstKeyMod.WinCtrl */; }
|
|
20
|
+
static chord(firstPart, secondPart) {
|
|
21
|
+
return KeyChord(firstPart, secondPart);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function createMonacoBaseAPI() {
|
|
25
|
+
return {
|
|
26
|
+
editor: undefined, // undefined override expected here
|
|
27
|
+
languages: undefined, // undefined override expected here
|
|
28
|
+
CancellationTokenSource: CancellationTokenSource,
|
|
29
|
+
Emitter: Emitter,
|
|
30
|
+
KeyCode: KeyCode,
|
|
31
|
+
KeyMod: KeyMod,
|
|
32
|
+
Position: Position,
|
|
33
|
+
Range: Range,
|
|
34
|
+
Selection: Selection,
|
|
35
|
+
SelectionDirection: SelectionDirection,
|
|
36
|
+
MarkerSeverity: MarkerSeverity,
|
|
37
|
+
MarkerTag: MarkerTag,
|
|
38
|
+
Uri: URI,
|
|
39
|
+
Token: Token
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { KeyMod, createMonacoBaseAPI };
|