monaco-editor
Version:
A browser based code editor
1,204 lines • 4.84 MB
JavaScript
define("vs/editor-ECyZhXSU", ["require", "exports", "./editorWorkerHost-DOv8Y9y5"], (function(require, exports, editorWorkerHost) {
"use strict";
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
const EditorZoom = new class {
constructor() {
this._zoomLevel = 0;
this._onDidChangeZoomLevel = new editorWorkerHost.Emitter();
this.onDidChangeZoomLevel = this._onDidChangeZoomLevel.event;
}
getZoomLevel() {
return this._zoomLevel;
}
setZoomLevel(zoomLevel) {
zoomLevel = Math.min(Math.max(-5, zoomLevel), 20);
if (this._zoomLevel === zoomLevel) {
return;
}
this._zoomLevel = zoomLevel;
this._onDidChangeZoomLevel.fire(this._zoomLevel);
}
}();
const GOLDEN_LINE_HEIGHT_RATIO = editorWorkerHost.isMacintosh ? 1.5 : 1.35;
const MINIMUM_LINE_HEIGHT = 8;
class BareFontInfo {
/**
* @internal
*/
static _create(fontFamily, fontWeight, fontSize, fontFeatureSettings, fontVariationSettings, lineHeight, letterSpacing, pixelRatio, ignoreEditorZoom) {
if (lineHeight === 0) {
lineHeight = GOLDEN_LINE_HEIGHT_RATIO * fontSize;
} else if (lineHeight < MINIMUM_LINE_HEIGHT) {
lineHeight = lineHeight * fontSize;
}
lineHeight = Math.round(lineHeight);
if (lineHeight < MINIMUM_LINE_HEIGHT) {
lineHeight = MINIMUM_LINE_HEIGHT;
}
const editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1);
fontSize *= editorZoomLevelMultiplier;
lineHeight *= editorZoomLevelMultiplier;
if (fontVariationSettings === FONT_VARIATION_TRANSLATE) {
if (fontWeight === "normal" || fontWeight === "bold") {
fontVariationSettings = FONT_VARIATION_OFF;
} else {
const fontWeightAsNumber = parseInt(fontWeight, 10);
fontVariationSettings = `'wght' ${fontWeightAsNumber}`;
fontWeight = "normal";
}
}
return new BareFontInfo({
pixelRatio,
fontFamily,
fontWeight,
fontSize,
fontFeatureSettings,
fontVariationSettings,
lineHeight,
letterSpacing
});
}
/**
* @internal
*/
constructor(opts) {
this._bareFontInfoBrand = void 0;
this.pixelRatio = opts.pixelRatio;
this.fontFamily = String(opts.fontFamily);
this.fontWeight = String(opts.fontWeight);
this.fontSize = opts.fontSize;
this.fontFeatureSettings = opts.fontFeatureSettings;
this.fontVariationSettings = opts.fontVariationSettings;
this.lineHeight = opts.lineHeight | 0;
this.letterSpacing = opts.letterSpacing;
}
/**
* @internal
*/
getId() {
return `${this.pixelRatio}-${this.fontFamily}-${this.fontWeight}-${this.fontSize}-${this.fontFeatureSettings}-${this.fontVariationSettings}-${this.lineHeight}-${this.letterSpacing}`;
}
/**
* @internal
*/
getMassagedFontFamily() {
const fallbackFontFamily = EDITOR_FONT_DEFAULTS.fontFamily;
const fontFamily = BareFontInfo._wrapInQuotes(this.fontFamily);
if (this.fontFamily !== fallbackFontFamily) {
return `${fontFamily}, ${fallbackFontFamily}`;
}
return fontFamily;
}
static _wrapInQuotes(fontFamily) {
if (/[,"']/.test(fontFamily)) {
return fontFamily;
}
if (/[+ ]/.test(fontFamily)) {
return `"${fontFamily}"`;
}
return fontFamily;
}
}
const SERIALIZED_FONT_INFO_VERSION = 2;
class FontInfo extends BareFontInfo {
/**
* @internal
*/
constructor(opts, isTrusted) {
super(opts);
this._editorStylingBrand = void 0;
this.version = SERIALIZED_FONT_INFO_VERSION;
this.isTrusted = isTrusted;
this.isMonospace = opts.isMonospace;
this.typicalHalfwidthCharacterWidth = opts.typicalHalfwidthCharacterWidth;
this.typicalFullwidthCharacterWidth = opts.typicalFullwidthCharacterWidth;
this.canUseHalfwidthRightwardsArrow = opts.canUseHalfwidthRightwardsArrow;
this.spaceWidth = opts.spaceWidth;
this.middotWidth = opts.middotWidth;
this.wsmiddotWidth = opts.wsmiddotWidth;
this.maxDigitWidth = opts.maxDigitWidth;
}
/**
* @internal
*/
equals(other) {
return this.fontFamily === other.fontFamily && this.fontWeight === other.fontWeight && this.fontSize === other.fontSize && this.fontFeatureSettings === other.fontFeatureSettings && this.fontVariationSettings === other.fontVariationSettings && this.lineHeight === other.lineHeight && this.letterSpacing === other.letterSpacing && this.typicalHalfwidthCharacterWidth === other.typicalHalfwidthCharacterWidth && this.typicalFullwidthCharacterWidth === other.typicalFullwidthCharacterWidth && this.canUseHalfwidthRightwardsArrow === other.canUseHalfwidthRightwardsArrow && this.spaceWidth === other.spaceWidth && this.middotWidth === other.middotWidth && this.wsmiddotWidth === other.wsmiddotWidth && this.maxDigitWidth === other.maxDigitWidth;
}
}
const FONT_VARIATION_OFF = "normal";
const FONT_VARIATION_TRANSLATE = "translate";
const DEFAULT_WINDOWS_FONT_FAMILY = "Consolas, 'Courier New', monospace";
const DEFAULT_MAC_FONT_FAMILY = "Menlo, Monaco, 'Courier New', monospace";
const DEFAULT_LINUX_FONT_FAMILY = "'Droid Sans Mono', monospace";
const EDITOR_FONT_DEFAULTS = {
fontFamily: editorWorkerHost.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : editorWorkerHost.isWindows ? DEFAULT_WINDOWS_FONT_FAMILY : DEFAULT_LINUX_FONT_FAMILY,
fontWeight: "normal",
fontSize: editorWorkerHost.isMacintosh ? 12 : 14,
lineHeight: 0,
letterSpacing: 0
};
const EDITOR_MODEL_DEFAULTS = {
tabSize: 4,
indentSize: 4,
insertSpaces: true,
detectIndentation: true,
trimAutoWhitespace: true,
largeFileOptimizations: true,
bracketPairColorizationOptions: {
enabled: true,
independentColorPoolPerBracketType: false
}
};
const MINIMAP_GUTTER_WIDTH = 8;
class ConfigurationChangedEvent {
/**
* @internal
*/
constructor(values) {
this._values = values;
}
hasChanged(id) {
return this._values[id];
}
}
class ComputeOptionsMemory {
constructor() {
this.stableMinimapLayoutInput = null;
this.stableFitMaxMinimapScale = 0;
this.stableFitRemainingWidth = 0;
}
}
class BaseEditorOption {
constructor(id, name, defaultValue, schema) {
this.id = id;
this.name = name;
this.defaultValue = defaultValue;
this.schema = schema;
}
applyUpdate(value, update) {
return applyUpdate(value, update);
}
compute(env, options, value) {
return value;
}
}
class ApplyUpdateResult {
constructor(newValue, didChange) {
this.newValue = newValue;
this.didChange = didChange;
}
}
function applyUpdate(value, update) {
if (typeof value !== "object" || typeof update !== "object" || !value || !update) {
return new ApplyUpdateResult(update, value !== update);
}
if (Array.isArray(value) || Array.isArray(update)) {
const arrayEquals2 = Array.isArray(value) && Array.isArray(update) && editorWorkerHost.equals(value, update);
return new ApplyUpdateResult(update, !arrayEquals2);
}
let didChange = false;
for (const key in update) {
if (update.hasOwnProperty(key)) {
const result = applyUpdate(value[key], update[key]);
if (result.didChange) {
value[key] = result.newValue;
didChange = true;
}
}
}
return new ApplyUpdateResult(value, didChange);
}
class ComputedEditorOption {
constructor(id, defaultValue) {
this.schema = void 0;
this.id = id;
this.name = "_never_";
this.defaultValue = defaultValue;
}
applyUpdate(value, update) {
return applyUpdate(value, update);
}
validate(input) {
return this.defaultValue;
}
}
class SimpleEditorOption {
constructor(id, name, defaultValue, schema) {
this.id = id;
this.name = name;
this.defaultValue = defaultValue;
this.schema = schema;
}
applyUpdate(value, update) {
return applyUpdate(value, update);
}
compute(env, options, value) {
return value;
}
}
function boolean(value, defaultValue) {
if (typeof value === "undefined") {
return defaultValue;
}
if (value === "false") {
return false;
}
return Boolean(value);
}
class EditorBooleanOption extends SimpleEditorOption {
constructor(id, name, defaultValue, schema = void 0) {
if (typeof schema !== "undefined") {
schema.type = "boolean";
schema.default = defaultValue;
}
super(id, name, defaultValue, schema);
}
validate(input) {
return boolean(input, this.defaultValue);
}
}
function clampedInt(value, defaultValue, minimum, maximum) {
if (typeof value === "string") {
value = parseInt(value, 10);
}
if (typeof value !== "number" || isNaN(value)) {
return defaultValue;
}
let r = value;
r = Math.max(minimum, r);
r = Math.min(maximum, r);
return r | 0;
}
class EditorIntOption extends SimpleEditorOption {
static clampedInt(value, defaultValue, minimum, maximum) {
return clampedInt(value, defaultValue, minimum, maximum);
}
constructor(id, name, defaultValue, minimum, maximum, schema = void 0) {
if (typeof schema !== "undefined") {
schema.type = "integer";
schema.default = defaultValue;
schema.minimum = minimum;
schema.maximum = maximum;
}
super(id, name, defaultValue, schema);
this.minimum = minimum;
this.maximum = maximum;
}
validate(input) {
return EditorIntOption.clampedInt(input, this.defaultValue, this.minimum, this.maximum);
}
}
function clampedFloat(value, defaultValue, minimum, maximum) {
if (typeof value === "undefined") {
return defaultValue;
}
const r = EditorFloatOption.float(value, defaultValue);
return EditorFloatOption.clamp(r, minimum, maximum);
}
class EditorFloatOption extends SimpleEditorOption {
static clamp(n, min, max) {
if (n < min) {
return min;
}
if (n > max) {
return max;
}
return n;
}
static float(value, defaultValue) {
if (typeof value === "string") {
value = parseFloat(value);
}
if (typeof value !== "number" || isNaN(value)) {
return defaultValue;
}
return value;
}
constructor(id, name, defaultValue, validationFn, schema, minimum, maximum) {
if (typeof schema !== "undefined") {
schema.type = "number";
schema.default = defaultValue;
schema.minimum = minimum;
schema.maximum = maximum;
}
super(id, name, defaultValue, schema);
this.validationFn = validationFn;
this.minimum = minimum;
this.maximum = maximum;
}
validate(input) {
return this.validationFn(EditorFloatOption.float(input, this.defaultValue));
}
}
class EditorStringOption extends SimpleEditorOption {
static string(value, defaultValue) {
if (typeof value !== "string") {
return defaultValue;
}
return value;
}
constructor(id, name, defaultValue, schema = void 0) {
if (typeof schema !== "undefined") {
schema.type = "string";
schema.default = defaultValue;
}
super(id, name, defaultValue, schema);
}
validate(input) {
return EditorStringOption.string(input, this.defaultValue);
}
}
function stringSet(value, defaultValue, allowedValues, renamedValues) {
if (typeof value !== "string") {
return defaultValue;
}
if (renamedValues && value in renamedValues) {
return renamedValues[value];
}
if (allowedValues.indexOf(value) === -1) {
return defaultValue;
}
return value;
}
class EditorStringEnumOption extends SimpleEditorOption {
constructor(id, name, defaultValue, allowedValues, schema = void 0) {
if (typeof schema !== "undefined") {
schema.type = "string";
schema.enum = allowedValues.slice(0);
schema.default = defaultValue;
}
super(id, name, defaultValue, schema);
this._allowedValues = allowedValues;
}
validate(input) {
return stringSet(input, this.defaultValue, this._allowedValues);
}
}
class EditorEnumOption extends BaseEditorOption {
constructor(id, name, defaultValue, defaultStringValue, allowedValues, convert, schema = void 0) {
if (typeof schema !== "undefined") {
schema.type = "string";
schema.enum = allowedValues;
schema.default = defaultStringValue;
}
super(id, name, defaultValue, schema);
this._allowedValues = allowedValues;
this._convert = convert;
}
validate(input) {
if (typeof input !== "string") {
return this.defaultValue;
}
if (this._allowedValues.indexOf(input) === -1) {
return this.defaultValue;
}
return this._convert(input);
}
}
function _autoIndentFromString(autoIndent) {
switch (autoIndent) {
case "none":
return 0;
case "keep":
return 1;
case "brackets":
return 2;
case "advanced":
return 3;
case "full":
return 4;
}
}
class EditorAccessibilitySupport extends BaseEditorOption {
constructor() {
super(2, "accessibilitySupport", 0, {
type: "string",
enum: ["auto", "on", "off"],
enumDescriptions: [
editorWorkerHost.localize(220, "Use platform APIs to detect when a Screen Reader is attached."),
editorWorkerHost.localize(221, "Optimize for usage with a Screen Reader."),
editorWorkerHost.localize(222, "Assume a screen reader is not attached.")
],
default: "auto",
tags: ["accessibility"],
description: editorWorkerHost.localize(223, "Controls if the UI should run in a mode where it is optimized for screen readers.")
});
}
validate(input) {
switch (input) {
case "auto":
return 0;
case "off":
return 1;
case "on":
return 2;
}
return this.defaultValue;
}
compute(env, options, value) {
if (value === 0) {
return env.accessibilitySupport;
}
return value;
}
}
class EditorComments extends BaseEditorOption {
constructor() {
const defaults = {
insertSpace: true,
ignoreEmptyLines: true
};
super(29, "comments", defaults, {
"editor.comments.insertSpace": {
type: "boolean",
default: defaults.insertSpace,
description: editorWorkerHost.localize(224, "Controls whether a space character is inserted when commenting.")
},
"editor.comments.ignoreEmptyLines": {
type: "boolean",
default: defaults.ignoreEmptyLines,
description: editorWorkerHost.localize(225, "Controls if empty lines should be ignored with toggle, add or remove actions for line comments.")
}
});
}
validate(_input) {
if (!_input || typeof _input !== "object") {
return this.defaultValue;
}
const input = _input;
return {
insertSpace: boolean(input.insertSpace, this.defaultValue.insertSpace),
ignoreEmptyLines: boolean(input.ignoreEmptyLines, this.defaultValue.ignoreEmptyLines)
};
}
}
function cursorBlinkingStyleFromString(cursorBlinkingStyle) {
switch (cursorBlinkingStyle) {
case "blink":
return 1;
case "smooth":
return 2;
case "phase":
return 3;
case "expand":
return 4;
case "solid":
return 5;
}
}
var TextEditorCursorStyle;
(function(TextEditorCursorStyle2) {
TextEditorCursorStyle2[TextEditorCursorStyle2["Line"] = 1] = "Line";
TextEditorCursorStyle2[TextEditorCursorStyle2["Block"] = 2] = "Block";
TextEditorCursorStyle2[TextEditorCursorStyle2["Underline"] = 3] = "Underline";
TextEditorCursorStyle2[TextEditorCursorStyle2["LineThin"] = 4] = "LineThin";
TextEditorCursorStyle2[TextEditorCursorStyle2["BlockOutline"] = 5] = "BlockOutline";
TextEditorCursorStyle2[TextEditorCursorStyle2["UnderlineThin"] = 6] = "UnderlineThin";
})(TextEditorCursorStyle || (TextEditorCursorStyle = {}));
function cursorStyleFromString(cursorStyle) {
switch (cursorStyle) {
case "line":
return TextEditorCursorStyle.Line;
case "block":
return TextEditorCursorStyle.Block;
case "underline":
return TextEditorCursorStyle.Underline;
case "line-thin":
return TextEditorCursorStyle.LineThin;
case "block-outline":
return TextEditorCursorStyle.BlockOutline;
case "underline-thin":
return TextEditorCursorStyle.UnderlineThin;
}
}
class EditorClassName extends ComputedEditorOption {
constructor() {
super(162, "");
}
compute(env, options, _) {
const classNames = ["monaco-editor"];
if (options.get(
48
/* EditorOption.extraEditorClassName */
)) {
classNames.push(options.get(
48
/* EditorOption.extraEditorClassName */
));
}
if (env.extraEditorClassName) {
classNames.push(env.extraEditorClassName);
}
if (options.get(
82
/* EditorOption.mouseStyle */
) === "default") {
classNames.push("mouse-default");
} else if (options.get(
82
/* EditorOption.mouseStyle */
) === "copy") {
classNames.push("mouse-copy");
}
if (options.get(
127
/* EditorOption.showUnused */
)) {
classNames.push("showUnused");
}
if (options.get(
157
/* EditorOption.showDeprecated */
)) {
classNames.push("showDeprecated");
}
return classNames.join(" ");
}
}
class EditorEmptySelectionClipboard extends EditorBooleanOption {
constructor() {
super(45, "emptySelectionClipboard", true, { description: editorWorkerHost.localize(226, "Controls whether copying without a selection copies the current line.") });
}
compute(env, options, value) {
return value && env.emptySelectionClipboard;
}
}
class EditorFind extends BaseEditorOption {
constructor() {
const defaults = {
cursorMoveOnType: true,
findOnType: true,
seedSearchStringFromSelection: "always",
autoFindInSelection: "never",
globalFindClipboard: false,
addExtraSpaceOnTop: true,
loop: true,
closeOnResult: false,
history: "workspace",
replaceHistory: "workspace"
};
super(50, "find", defaults, {
"editor.find.cursorMoveOnType": {
type: "boolean",
default: defaults.cursorMoveOnType,
description: editorWorkerHost.localize(227, "Controls whether the cursor should jump to find matches while typing.")
},
"editor.find.seedSearchStringFromSelection": {
type: "string",
enum: ["never", "always", "selection"],
default: defaults.seedSearchStringFromSelection,
enumDescriptions: [
editorWorkerHost.localize(228, "Never seed search string from the editor selection."),
editorWorkerHost.localize(229, "Always seed search string from the editor selection, including word at cursor position."),
editorWorkerHost.localize(230, "Only seed search string from the editor selection.")
],
description: editorWorkerHost.localize(231, "Controls whether the search string in the Find Widget is seeded from the editor selection.")
},
"editor.find.autoFindInSelection": {
type: "string",
enum: ["never", "always", "multiline"],
default: defaults.autoFindInSelection,
enumDescriptions: [
editorWorkerHost.localize(232, "Never turn on Find in Selection automatically (default)."),
editorWorkerHost.localize(233, "Always turn on Find in Selection automatically."),
editorWorkerHost.localize(234, "Turn on Find in Selection automatically when multiple lines of content are selected.")
],
description: editorWorkerHost.localize(235, "Controls the condition for turning on Find in Selection automatically.")
},
"editor.find.globalFindClipboard": {
type: "boolean",
default: defaults.globalFindClipboard,
description: editorWorkerHost.localize(236, "Controls whether the Find Widget should read or modify the shared find clipboard on macOS."),
included: editorWorkerHost.isMacintosh
},
"editor.find.addExtraSpaceOnTop": {
type: "boolean",
default: defaults.addExtraSpaceOnTop,
description: editorWorkerHost.localize(237, "Controls whether the Find Widget should add extra lines on top of the editor. When true, you can scroll beyond the first line when the Find Widget is visible.")
},
"editor.find.loop": {
type: "boolean",
default: defaults.loop,
description: editorWorkerHost.localize(238, "Controls whether the search automatically restarts from the beginning (or the end) when no further matches can be found.")
},
"editor.find.closeOnResult": {
type: "boolean",
default: defaults.closeOnResult,
description: editorWorkerHost.localize(239, "Controls whether the Find Widget closes after an explicit find navigation command lands on a result.")
},
"editor.find.history": {
type: "string",
enum: ["never", "workspace"],
default: "workspace",
enumDescriptions: [
editorWorkerHost.localize(240, "Do not store search history from the find widget."),
editorWorkerHost.localize(241, "Store search history across the active workspace")
],
description: editorWorkerHost.localize(242, "Controls how the find widget history should be stored")
},
"editor.find.replaceHistory": {
type: "string",
enum: ["never", "workspace"],
default: "workspace",
enumDescriptions: [
editorWorkerHost.localize(243, "Do not store history from the replace widget."),
editorWorkerHost.localize(244, "Store replace history across the active workspace")
],
description: editorWorkerHost.localize(245, "Controls how the replace widget history should be stored")
},
"editor.find.findOnType": {
type: "boolean",
default: defaults.findOnType,
description: editorWorkerHost.localize(246, "Controls whether the Find Widget should search as you type.")
}
});
}
validate(_input) {
if (!_input || typeof _input !== "object") {
return this.defaultValue;
}
const input = _input;
return {
cursorMoveOnType: boolean(input.cursorMoveOnType, this.defaultValue.cursorMoveOnType),
findOnType: boolean(input.findOnType, this.defaultValue.findOnType),
seedSearchStringFromSelection: typeof input.seedSearchStringFromSelection === "boolean" ? input.seedSearchStringFromSelection ? "always" : "never" : stringSet(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection, ["never", "always", "selection"]),
autoFindInSelection: typeof input.autoFindInSelection === "boolean" ? input.autoFindInSelection ? "always" : "never" : stringSet(input.autoFindInSelection, this.defaultValue.autoFindInSelection, ["never", "always", "multiline"]),
globalFindClipboard: boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard),
addExtraSpaceOnTop: boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop),
loop: boolean(input.loop, this.defaultValue.loop),
closeOnResult: boolean(input.closeOnResult, this.defaultValue.closeOnResult),
history: stringSet(input.history, this.defaultValue.history, ["never", "workspace"]),
replaceHistory: stringSet(input.replaceHistory, this.defaultValue.replaceHistory, ["never", "workspace"])
};
}
}
const _EditorFontLigatures = class _EditorFontLigatures extends BaseEditorOption {
constructor() {
super(60, "fontLigatures", _EditorFontLigatures.OFF, {
anyOf: [
{
type: "boolean",
description: editorWorkerHost.localize(247, "Enables/Disables font ligatures ('calt' and 'liga' font features). Change this to a string for fine-grained control of the 'font-feature-settings' CSS property.")
},
{
type: "string",
description: editorWorkerHost.localize(248, "Explicit 'font-feature-settings' CSS property. A boolean can be passed instead if one only needs to turn on/off ligatures.")
}
],
description: editorWorkerHost.localize(249, "Configures font ligatures or font features. Can be either a boolean to enable/disable ligatures or a string for the value of the CSS 'font-feature-settings' property."),
default: false
});
}
validate(input) {
if (typeof input === "undefined") {
return this.defaultValue;
}
if (typeof input === "string") {
if (input === "false" || input.length === 0) {
return _EditorFontLigatures.OFF;
}
if (input === "true") {
return _EditorFontLigatures.ON;
}
return input;
}
if (Boolean(input)) {
return _EditorFontLigatures.ON;
}
return _EditorFontLigatures.OFF;
}
};
_EditorFontLigatures.OFF = '"liga" off, "calt" off';
_EditorFontLigatures.ON = '"liga" on, "calt" on';
let EditorFontLigatures = _EditorFontLigatures;
const _EditorFontVariations = class _EditorFontVariations extends BaseEditorOption {
constructor() {
super(63, "fontVariations", _EditorFontVariations.OFF, {
anyOf: [
{
type: "boolean",
description: editorWorkerHost.localize(250, "Enables/Disables the translation from font-weight to font-variation-settings. Change this to a string for fine-grained control of the 'font-variation-settings' CSS property.")
},
{
type: "string",
description: editorWorkerHost.localize(251, "Explicit 'font-variation-settings' CSS property. A boolean can be passed instead if one only needs to translate font-weight to font-variation-settings.")
}
],
description: editorWorkerHost.localize(252, "Configures font variations. Can be either a boolean to enable/disable the translation from font-weight to font-variation-settings or a string for the value of the CSS 'font-variation-settings' property."),
default: false
});
}
validate(input) {
if (typeof input === "undefined") {
return this.defaultValue;
}
if (typeof input === "string") {
if (input === "false") {
return _EditorFontVariations.OFF;
}
if (input === "true") {
return _EditorFontVariations.TRANSLATE;
}
return input;
}
if (Boolean(input)) {
return _EditorFontVariations.TRANSLATE;
}
return _EditorFontVariations.OFF;
}
compute(env, options, value) {
return env.fontInfo.fontVariationSettings;
}
};
_EditorFontVariations.OFF = FONT_VARIATION_OFF;
_EditorFontVariations.TRANSLATE = FONT_VARIATION_TRANSLATE;
let EditorFontVariations = _EditorFontVariations;
class EditorFontInfo extends ComputedEditorOption {
constructor() {
super(59, new FontInfo({
pixelRatio: 0,
fontFamily: "",
fontWeight: "",
fontSize: 0,
fontFeatureSettings: "",
fontVariationSettings: "",
lineHeight: 0,
letterSpacing: 0,
isMonospace: false,
typicalHalfwidthCharacterWidth: 0,
typicalFullwidthCharacterWidth: 0,
canUseHalfwidthRightwardsArrow: false,
spaceWidth: 0,
middotWidth: 0,
wsmiddotWidth: 0,
maxDigitWidth: 0
}, false));
}
compute(env, options, _) {
return env.fontInfo;
}
}
class EffectiveCursorStyle extends ComputedEditorOption {
constructor() {
super(161, TextEditorCursorStyle.Line);
}
compute(env, options, _) {
return env.inputMode === "overtype" ? options.get(
92
/* EditorOption.overtypeCursorStyle */
) : options.get(
34
/* EditorOption.cursorStyle */
);
}
}
class EffectiveEditContextEnabled extends ComputedEditorOption {
constructor() {
super(170, false);
}
compute(env, options) {
return env.editContextSupported && options.get(
44
/* EditorOption.editContext */
);
}
}
class EffectiveAllowVariableFonts extends ComputedEditorOption {
constructor() {
super(172, false);
}
compute(env, options) {
const accessibilitySupport = env.accessibilitySupport;
if (accessibilitySupport === 2) {
return options.get(
7
/* EditorOption.allowVariableFontsInAccessibilityMode */
);
} else {
return options.get(
6
/* EditorOption.allowVariableFonts */
);
}
}
}
class EditorFontSize extends SimpleEditorOption {
constructor() {
super(61, "fontSize", EDITOR_FONT_DEFAULTS.fontSize, {
type: "number",
minimum: 6,
maximum: 100,
default: EDITOR_FONT_DEFAULTS.fontSize,
description: editorWorkerHost.localize(253, "Controls the font size in pixels.")
});
}
validate(input) {
const r = EditorFloatOption.float(input, this.defaultValue);
if (r === 0) {
return EDITOR_FONT_DEFAULTS.fontSize;
}
return EditorFloatOption.clamp(r, 6, 100);
}
compute(env, options, value) {
return env.fontInfo.fontSize;
}
}
const _EditorFontWeight = class _EditorFontWeight extends BaseEditorOption {
constructor() {
super(62, "fontWeight", EDITOR_FONT_DEFAULTS.fontWeight, {
anyOf: [
{
type: "number",
minimum: _EditorFontWeight.MINIMUM_VALUE,
maximum: _EditorFontWeight.MAXIMUM_VALUE,
errorMessage: editorWorkerHost.localize(254, 'Only "normal" and "bold" keywords or numbers between 1 and 1000 are allowed.')
},
{
type: "string",
pattern: "^(normal|bold|1000|[1-9][0-9]{0,2})$"
},
{
enum: _EditorFontWeight.SUGGESTION_VALUES
}
],
default: EDITOR_FONT_DEFAULTS.fontWeight,
description: editorWorkerHost.localize(255, 'Controls the font weight. Accepts "normal" and "bold" keywords or numbers between 1 and 1000.')
});
}
validate(input) {
if (input === "normal" || input === "bold") {
return input;
}
return String(EditorIntOption.clampedInt(input, EDITOR_FONT_DEFAULTS.fontWeight, _EditorFontWeight.MINIMUM_VALUE, _EditorFontWeight.MAXIMUM_VALUE));
}
};
_EditorFontWeight.SUGGESTION_VALUES = ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900"];
_EditorFontWeight.MINIMUM_VALUE = 1;
_EditorFontWeight.MAXIMUM_VALUE = 1e3;
let EditorFontWeight = _EditorFontWeight;
class EditorGoToLocation extends BaseEditorOption {
constructor() {
const defaults = {
multiple: "peek",
multipleDefinitions: "peek",
multipleTypeDefinitions: "peek",
multipleDeclarations: "peek",
multipleImplementations: "peek",
multipleReferences: "peek",
multipleTests: "peek",
alternativeDefinitionCommand: "editor.action.goToReferences",
alternativeTypeDefinitionCommand: "editor.action.goToReferences",
alternativeDeclarationCommand: "editor.action.goToReferences",
alternativeImplementationCommand: "",
alternativeReferenceCommand: "",
alternativeTestsCommand: ""
};
const jsonSubset = {
type: "string",
enum: ["peek", "gotoAndPeek", "goto"],
default: defaults.multiple,
enumDescriptions: [
editorWorkerHost.localize(256, "Show Peek view of the results (default)"),
editorWorkerHost.localize(257, "Go to the primary result and show a Peek view"),
editorWorkerHost.localize(258, "Go to the primary result and enable Peek-less navigation to others")
]
};
const alternativeCommandOptions = ["", "editor.action.referenceSearch.trigger", "editor.action.goToReferences", "editor.action.peekImplementation", "editor.action.goToImplementation", "editor.action.peekTypeDefinition", "editor.action.goToTypeDefinition", "editor.action.peekDeclaration", "editor.action.revealDeclaration", "editor.action.peekDefinition", "editor.action.revealDefinitionAside", "editor.action.revealDefinition"];
super(67, "gotoLocation", defaults, {
"editor.gotoLocation.multiple": {
deprecationMessage: editorWorkerHost.localize(259, "This setting is deprecated, please use separate settings like 'editor.editor.gotoLocation.multipleDefinitions' or 'editor.editor.gotoLocation.multipleImplementations' instead.")
},
"editor.gotoLocation.multipleDefinitions": {
description: editorWorkerHost.localize(260, "Controls the behavior the 'Go to Definition'-command when multiple target locations exist."),
...jsonSubset
},
"editor.gotoLocation.multipleTypeDefinitions": {
description: editorWorkerHost.localize(261, "Controls the behavior the 'Go to Type Definition'-command when multiple target locations exist."),
...jsonSubset
},
"editor.gotoLocation.multipleDeclarations": {
description: editorWorkerHost.localize(262, "Controls the behavior the 'Go to Declaration'-command when multiple target locations exist."),
...jsonSubset
},
"editor.gotoLocation.multipleImplementations": {
description: editorWorkerHost.localize(263, "Controls the behavior the 'Go to Implementations'-command when multiple target locations exist."),
...jsonSubset
},
"editor.gotoLocation.multipleReferences": {
description: editorWorkerHost.localize(264, "Controls the behavior the 'Go to References'-command when multiple target locations exist."),
...jsonSubset
},
"editor.gotoLocation.alternativeDefinitionCommand": {
type: "string",
default: defaults.alternativeDefinitionCommand,
enum: alternativeCommandOptions,
description: editorWorkerHost.localize(265, "Alternative command id that is being executed when the result of 'Go to Definition' is the current location.")
},
"editor.gotoLocation.alternativeTypeDefinitionCommand": {
type: "string",
default: defaults.alternativeTypeDefinitionCommand,
enum: alternativeCommandOptions,
description: editorWorkerHost.localize(266, "Alternative command id that is being executed when the result of 'Go to Type Definition' is the current location.")
},
"editor.gotoLocation.alternativeDeclarationCommand": {
type: "string",
default: defaults.alternativeDeclarationCommand,
enum: alternativeCommandOptions,
description: editorWorkerHost.localize(267, "Alternative command id that is being executed when the result of 'Go to Declaration' is the current location.")
},
"editor.gotoLocation.alternativeImplementationCommand": {
type: "string",
default: defaults.alternativeImplementationCommand,
enum: alternativeCommandOptions,
description: editorWorkerHost.localize(268, "Alternative command id that is being executed when the result of 'Go to Implementation' is the current location.")
},
"editor.gotoLocation.alternativeReferenceCommand": {
type: "string",
default: defaults.alternativeReferenceCommand,
enum: alternativeCommandOptions,
description: editorWorkerHost.localize(269, "Alternative command id that is being executed when the result of 'Go to Reference' is the current location.")
}
});
}
validate(_input) {
if (!_input || typeof _input !== "object") {
return this.defaultValue;
}
const input = _input;
return {
multiple: stringSet(input.multiple, this.defaultValue.multiple, ["peek", "gotoAndPeek", "goto"]),
multipleDefinitions: stringSet(input.multipleDefinitions, "peek", ["peek", "gotoAndPeek", "goto"]),
multipleTypeDefinitions: stringSet(input.multipleTypeDefinitions, "peek", ["peek", "gotoAndPeek", "goto"]),
multipleDeclarations: stringSet(input.multipleDeclarations, "peek", ["peek", "gotoAndPeek", "goto"]),
multipleImplementations: stringSet(input.multipleImplementations, "peek", ["peek", "gotoAndPeek", "goto"]),
multipleReferences: stringSet(input.multipleReferences, "peek", ["peek", "gotoAndPeek", "goto"]),
multipleTests: stringSet(input.multipleTests, "peek", ["peek", "gotoAndPeek", "goto"]),
alternativeDefinitionCommand: EditorStringOption.string(input.alternativeDefinitionCommand, this.defaultValue.alternativeDefinitionCommand),
alternativeTypeDefinitionCommand: EditorStringOption.string(input.alternativeTypeDefinitionCommand, this.defaultValue.alternativeTypeDefinitionCommand),
alternativeDeclarationCommand: EditorStringOption.string(input.alternativeDeclarationCommand, this.defaultValue.alternativeDeclarationCommand),
alternativeImplementationCommand: EditorStringOption.string(input.alternativeImplementationCommand, this.defaultValue.alternativeImplementationCommand),
alternativeReferenceCommand: EditorStringOption.string(input.alternativeReferenceCommand, this.defaultValue.alternativeReferenceCommand),
alternativeTestsCommand: EditorStringOption.string(input.alternativeTestsCommand, this.defaultValue.alternativeTestsCommand)
};
}
}
class EditorHover extends BaseEditorOption {
constructor() {
const defaults = {
enabled: "on",
delay: 300,
hidingDelay: 300,
sticky: true,
above: true,
showLongLineWarning: true
};
super(69, "hover", defaults, {
"editor.hover.enabled": {
type: "string",
enum: ["on", "off", "onKeyboardModifier"],
default: defaults.enabled,
markdownEnumDescriptions: [
editorWorkerHost.localize(270, "Hover is enabled."),
editorWorkerHost.localize(271, "Hover is disabled."),
editorWorkerHost.localize(272, "Hover is shown when holding `{0}` or `Alt` (the opposite modifier of `#editor.multiCursorModifier#`)", editorWorkerHost.isMacintosh ? `Command` : `Control`)
],
description: editorWorkerHost.localize(273, "Controls whether the hover is shown."),
keywords: ["hint", "info", "tooltip"]
},
"editor.hover.delay": {
type: "number",
default: defaults.delay,
minimum: 0,
maximum: 1e4,
description: editorWorkerHost.localize(274, "Controls the delay in milliseconds after which the hover is shown.")
},
"editor.hover.sticky": {
type: "boolean",
default: defaults.sticky,
description: editorWorkerHost.localize(275, "Controls whether the hover should remain visible when mouse is moved over it.")
},
"editor.hover.hidingDelay": {
type: "integer",
minimum: 0,
default: defaults.hidingDelay,
markdownDescription: editorWorkerHost.localize(276, "Controls the delay in milliseconds after which the hover is hidden. Requires `#editor.hover.sticky#` to be enabled.")
},
"editor.hover.above": {
type: "boolean",
default: defaults.above,
description: editorWorkerHost.localize(277, "Prefer showing hovers above the line, if there's space.")
},
"editor.hover.showLongLineWarning": {
type: "boolean",
default: defaults.showLongLineWarning,
description: editorWorkerHost.localize(278, "Controls whether long line warning hovers are shown, such as when tokenization is skipped or rendering is paused.")
}
});
}
validate(_input) {
if (!_input || typeof _input !== "object") {
return this.defaultValue;
}
const input = _input;
return {
enabled: stringSet(input.enabled, this.defaultValue.enabled, ["on", "off", "onKeyboardModifier"]),
delay: EditorIntOption.clampedInt(input.delay, this.defaultValue.delay, 0, 1e4),
sticky: boolean(input.sticky, this.defaultValue.sticky),
hidingDelay: EditorIntOption.clampedInt(input.hidingDelay, this.defaultValue.hidingDelay, 0, 6e5),
above: boolean(input.above, this.defaultValue.above),
showLongLineWarning: boolean(input.showLongLineWarning, this.defaultValue.showLongLineWarning)
};
}
}
class EditorLayoutInfoComputer extends ComputedEditorOption {
constructor() {
super(165, {
width: 0,
height: 0,
glyphMarginLeft: 0,
glyphMarginWidth: 0,
glyphMarginDecorationLaneCount: 0,
lineNumbersLeft: 0,
lineNumbersWidth: 0,
decorationsLeft: 0,
decorationsWidth: 0,
contentLeft: 0,
contentWidth: 0,
minimap: {
renderMinimap: 0,
minimapLeft: 0,
minimapWidth: 0,
minimapHeightIsEditorHeight: false,
minimapIsSampling: false,
minimapScale: 1,
minimapLineHeight: 1,
minimapCanvasInnerWidth: 0,
minimapCanvasInnerHeight: 0,
minimapCanvasOuterWidth: 0,
minimapCanvasOuterHeight: 0
},
viewportColumn: 0,
isWordWrapMinified: false,
isViewportWrapping: false,
wrappingColumn: -1,
verticalScrollbarWidth: 0,
horizontalScrollbarHeight: 0,
overviewRuler: {
top: 0,
width: 0,
height: 0,
right: 0
}
});
}
compute(env, options, _) {
return EditorLayoutInfoComputer.computeLayout(options, {
memory: env.memory,
outerWidth: env.outerWidth,
outerHeight: env.outerHeight,
isDominatedByLongLines: env.isDominatedByLongLines,
lineHeight: env.fontInfo.lineHeight,
viewLineCount: env.viewLineCount,
lineNumbersDigitCount: env.lineNumbersDigitCount,
typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
maxDigitWidth: env.fontInfo.maxDigitWidth,
pixelRatio: env.pixelRatio,
glyphMarginDecorationLaneCount: env.glyphMarginDecorationLaneCount
});
}
static computeContainedMinimapLineCount(input) {
const typicalViewportLineCount = input.height / input.lineHeight;
const extraLinesBeforeFirstLine = Math.floor(input.paddingTop / input.lineHeight);
let extraLinesBeyondLastLine = Math.floor(input.paddingBottom / input.lineHeight);
if (input.scrollBeyondLastLine) {
extraLinesBeyondLastLine = Math.max(extraLinesBeyondLastLine, typicalViewportLineCount - 1);
}
const desiredRatio = (extraLinesBeforeFirstLine + input.viewLineCount + extraLinesBeyondLastLine) / (input.pixelRatio * input.height);
const minimapLineCount = Math.floor(input.viewLineCount / desiredRatio);
return { typicalViewportLineCount, extraLinesBeforeFirstLine, extraLinesBeyondLastLine, desiredRatio, minimapLineCount };
}
static _computeMinimapLayout(input, memory) {
const outerWidth = input.outerWidth;
const outerHeight = input.outerHeight;
const pixelRatio = input.pixelRatio;
if (!input.minimap.enabled) {
return {
renderMinimap: 0,
minimapLeft: 0,
minimapWidth: 0,
minimapHeightIsEditorHeight: false,
minimapIsSampling: false,
minimapScale: 1,
minimapLineHeight: 1,
minimapCanvasInnerWidth: 0,
minimapCanvasInnerHeight: Math.floor(pixelRatio * outerHeight),
minimapCanvasOuterWidth: 0,
minimapCanvasOuterHeight: outerHeight
};
}
const stableMinimapLayoutInput = memory.stableMinimapLayoutInput;
const couldUseMemory = stableMinimapLayoutInput && input.outerHeight === stableMinimapLayoutInput.outerHeight && input.lineHeight === stableMinimapLayoutInput.lineHeight && input.typicalHalfwidthCharacterWidth === stableMinimapLayoutInput.typicalHalfwidthCharacterWidth && input.pixelRatio === stableMinimapLayoutInput.pixelRatio && input.scrollBeyondLastLine === stableMinimapLayoutInput.scrollBeyondLastLine && input.paddingTop === stableMinimapLayoutInput.paddingTop && input.paddingBottom === stableMinimapLayoutInput.paddingBottom && input.minimap.enabled === stableMinimapLayoutInput.minimap.enabled && input.minimap.side === stableMinimapLayoutInput.minimap.side && input.minimap.size === stableMinimapLayoutInput.minimap.size && input.minimap.showSlider === stableMinimapLayoutInput.minimap.showSlider && input.minimap.renderCharacters === stableMinimapLayoutInput.minimap.renderCharacters && input.minimap.maxColumn === stableMinimapLayoutInput.minimap.maxColumn && input.minimap.scale === stableMinimapLayoutInput.minimap.scale && input.verticalScrollbarWidth === stableMinimapLayoutInput.verticalScrollbarWidth && input.isViewportWrapping === stableMinimapLayoutInput.isViewportWrapping;
const lineHeight = input.lineHeight;
const typicalHalfwidthCharacterWidth = input.typicalHalfwidthCharacterWidth;
const scrollBeyondLastLine = input.scrollBeyondLastLine;
const minimapRenderCharacters = input.minimap.renderCharacters;
let minimapScale = pixelRatio >= 2 ? Math.round(input.minimap.scale * 2) : input.minimap.scale;
const minimapMaxColumn = input.minimap.maxColumn;
const minimapSize = input.minimap.size;
const minimapSide = input.minimap.side;
const verticalScrollbarWidth = input.verticalScrollbarWidth;
const viewLineCount = input.viewLineCount;
const remainingWidth = input.remainingWidth;
const isViewportWrapping = input.isViewportWrapping;
const baseCharHeight = minimapRenderCharacters ? 2 : 3;
let minimapCanvasInnerHeight = Math.floor(pixelRatio * outerHeight);
const minimapCanvasOuterHeight = minimapCanvasInnerHeight / pixelRatio;
let minimapHeightIsEditorHeight = false;
let minimapIsSampling = false;
let minimapLineHeight = baseCharHeight * minimapScale;
let minimapCharWidth = minimapScale / pixelRatio;
let minimapWidthMultiplier = 1;
if (minimapSize === "fill" || minimapSize === "fit") {
const { typicalViewportLineCount, extraLinesBeforeFirstLine, extraLinesBeyondLastLine, desiredRatio, minimapLineCount } = EditorLayoutInfoComputer.computeContainedMinimapLineCount({
viewLineCount,
scrollBeyondLastLine,
paddingTop: input.paddingTop,
paddingBottom: input.paddingBottom,
height: outerHeight,
lineHeight,
pixelRatio
});
const ratio = viewLineCount / minimapLineCount;
if (ratio > 1) {
minimapHeightIsEditorHeight = true;
minimapIsSampling = true;
minimapScale = 1;
minimapLineHeight = 1;
minimapCharWidth = minimapScale / pixelRatio;
} else {
let fitBecomesFill = false;
let maxMinimapScale = minimapScale + 1;
if (minimapSize === "fit") {
const effectiveMinimapHeight = Math.ceil((extraLinesBeforeFirstLine + viewLineCount + extraLinesBeyondLastLine) * minimapLineHeight);
if (isViewportWrapping && couldUseMemory && remainingWidth <= memory.stableFitRemainingWidth) {
fitBecomesFill = true;
maxMinimapScale = memory.stableFitMaxMinimapScale;
} else {
fitBecomesFill = effectiveMinimapHeight > minimapCanvasInnerHeight;
}
}
if (minimapSize === "fill" || fitBecomesFill) {
minimapHeightIsEditorHeight = true;
const configuredMinimapScale = minimapScale;
minimapLineHeight = Math.min(lineHeight * pixelRatio, Math.max(1, Math.floor(1 / desiredRatio)));
if (isViewportWrapping && couldUseMemory && remainingWidth <= memory.stableFitRemainingWidth) {
maxMinimapScale = memory.stableFitMaxMinimapScale;
}
minimapScale = Math.min(maxMinimapScale, Math.max(1, Math.floor(minimapLineHeight / baseCharHeight)));
if (minimapScale > configuredMinimapScale) {
minimapWidthMultiplier = Math.min(2, minimapScale / configuredMinimapScale);
}
minimapCharWidth = minimapScale / pixelRatio / minimapWidthMultiplier;
minimapCanvasInnerHeight = Math.ceil(Math.max(typicalViewportLineCount, extraLinesBeforeFirstLine + viewLineCount + extraLinesBeyondLastLine) * minimapLineHeight);
if (isViewportWrapping) {
memory.stableMinimapLayoutI