monaco-editor-core
Version:
A browser based code editor
134 lines (133 loc) • 4.73 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { equals } from '../../base/common/objects.js';
/**
* Vertical Lane in the overview ruler of the editor.
*/
export var OverviewRulerLane;
(function (OverviewRulerLane) {
OverviewRulerLane[OverviewRulerLane["Left"] = 1] = "Left";
OverviewRulerLane[OverviewRulerLane["Center"] = 2] = "Center";
OverviewRulerLane[OverviewRulerLane["Right"] = 4] = "Right";
OverviewRulerLane[OverviewRulerLane["Full"] = 7] = "Full";
})(OverviewRulerLane || (OverviewRulerLane = {}));
/**
* Vertical Lane in the glyph margin of the editor.
*/
export var GlyphMarginLane;
(function (GlyphMarginLane) {
GlyphMarginLane[GlyphMarginLane["Left"] = 1] = "Left";
GlyphMarginLane[GlyphMarginLane["Center"] = 2] = "Center";
GlyphMarginLane[GlyphMarginLane["Right"] = 3] = "Right";
})(GlyphMarginLane || (GlyphMarginLane = {}));
export var InjectedTextCursorStops;
(function (InjectedTextCursorStops) {
InjectedTextCursorStops[InjectedTextCursorStops["Both"] = 0] = "Both";
InjectedTextCursorStops[InjectedTextCursorStops["Right"] = 1] = "Right";
InjectedTextCursorStops[InjectedTextCursorStops["Left"] = 2] = "Left";
InjectedTextCursorStops[InjectedTextCursorStops["None"] = 3] = "None";
})(InjectedTextCursorStops || (InjectedTextCursorStops = {}));
export class TextModelResolvedOptions {
get originalIndentSize() {
return this._indentSizeIsTabSize ? 'tabSize' : this.indentSize;
}
/**
* @internal
*/
constructor(src) {
this._textModelResolvedOptionsBrand = undefined;
this.tabSize = Math.max(1, src.tabSize | 0);
if (src.indentSize === 'tabSize') {
this.indentSize = this.tabSize;
this._indentSizeIsTabSize = true;
}
else {
this.indentSize = Math.max(1, src.indentSize | 0);
this._indentSizeIsTabSize = false;
}
this.insertSpaces = Boolean(src.insertSpaces);
this.defaultEOL = src.defaultEOL | 0;
this.trimAutoWhitespace = Boolean(src.trimAutoWhitespace);
this.bracketPairColorizationOptions = src.bracketPairColorizationOptions;
}
/**
* @internal
*/
equals(other) {
return (this.tabSize === other.tabSize
&& this._indentSizeIsTabSize === other._indentSizeIsTabSize
&& this.indentSize === other.indentSize
&& this.insertSpaces === other.insertSpaces
&& this.defaultEOL === other.defaultEOL
&& this.trimAutoWhitespace === other.trimAutoWhitespace
&& equals(this.bracketPairColorizationOptions, other.bracketPairColorizationOptions));
}
/**
* @internal
*/
createChangeEvent(newOpts) {
return {
tabSize: this.tabSize !== newOpts.tabSize,
indentSize: this.indentSize !== newOpts.indentSize,
insertSpaces: this.insertSpaces !== newOpts.insertSpaces,
trimAutoWhitespace: this.trimAutoWhitespace !== newOpts.trimAutoWhitespace,
};
}
}
export class FindMatch {
/**
* @internal
*/
constructor(range, matches) {
this._findMatchBrand = undefined;
this.range = range;
this.matches = matches;
}
}
/**
* @internal
*/
export function isITextSnapshot(obj) {
return (obj && typeof obj.read === 'function');
}
/**
* @internal
*/
export class ValidAnnotatedEditOperation {
constructor(identifier, range, text, forceMoveMarkers, isAutoWhitespaceEdit, _isTracked) {
this.identifier = identifier;
this.range = range;
this.text = text;
this.forceMoveMarkers = forceMoveMarkers;
this.isAutoWhitespaceEdit = isAutoWhitespaceEdit;
this._isTracked = _isTracked;
}
}
/**
* @internal
*/
export class SearchData {
constructor(regex, wordSeparators, simpleSearch) {
this.regex = regex;
this.wordSeparators = wordSeparators;
this.simpleSearch = simpleSearch;
}
}
/**
* @internal
*/
export class ApplyEditsResult {
constructor(reverseEdits, changes, trimAutoWhitespaceLineNumbers) {
this.reverseEdits = reverseEdits;
this.changes = changes;
this.trimAutoWhitespaceLineNumbers = trimAutoWhitespaceLineNumbers;
}
}
/**
* @internal
*/
export function shouldSynchronizeModel(model) {
return (!model.isTooLargeForSyncing() && !model.isForSimpleWidget);
}