Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -2,19 +2,18 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as nls from 'vs/nls';
import { Event, Emitter } from 'vs/base/common/event';
import { Emitter, Event } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import * as objects from 'vs/base/common/objects';
import * as platform from 'vs/base/common/platform';
import { Extensions, IConfigurationRegistry, IConfigurationNode, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { FontInfo, BareFontInfo } from 'vs/editor/common/config/fontInfo';
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
import * as editorOptions from 'vs/editor/common/config/editorOptions';
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ConfigurationScope, Extensions, IConfigurationNode, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
import EDITOR_DEFAULTS = editorOptions.EDITOR_DEFAULTS;
import EDITOR_FONT_DEFAULTS = editorOptions.EDITOR_FONT_DEFAULTS;
import EDITOR_MODEL_DEFAULTS = editorOptions.EDITOR_MODEL_DEFAULTS;
@@ -83,9 +82,9 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
this._rawOptions.minimap = objects.mixin({}, this._rawOptions.minimap || {});
this._rawOptions.find = objects.mixin({}, this._rawOptions.find || {});
this._rawOptions.hover = objects.mixin({}, this._rawOptions.hover || {});
this._rawOptions.parameterHints = objects.mixin({}, this._rawOptions.parameterHints || {});
this._validatedOptions = editorOptions.EditorOptionsValidator.validate(this._rawOptions, EDITOR_DEFAULTS);
this.editor = null;
this._isDominatedByLongLines = false;
this._lineNumbersDigitCount = 1;
@@ -282,19 +281,17 @@ const editorConfiguration: IConfigurationNode = {
'type': 'number',
'default': EDITOR_MODEL_DEFAULTS.tabSize,
'minimum': 1,
'description': nls.localize('tabSize', "The number of spaces a tab is equal to. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on."),
'errorMessage': nls.localize('tabSize.errorMessage', "Expected 'number'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
'markdownDescription': nls.localize('tabSize', "The number of spaces a tab is equal to. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on.")
},
'editor.insertSpaces': {
'type': 'boolean',
'default': EDITOR_MODEL_DEFAULTS.insertSpaces,
'description': nls.localize('insertSpaces', "Insert spaces when pressing `Tab`. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on."),
'errorMessage': nls.localize('insertSpaces.errorMessage', "Expected 'boolean'. Note that the value \"auto\" has been replaced by the `editor.detectIndentation` setting.")
'markdownDescription': nls.localize('insertSpaces', "Insert spaces when pressing `Tab`. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on.")
},
'editor.detectIndentation': {
'type': 'boolean',
'default': EDITOR_MODEL_DEFAULTS.detectIndentation,
'description': nls.localize('detectIndentation', "Controls whether `#editor.tabSize#` and `#editor.insertSpaces#` will be automatically detected when a file is opened based on the file contents.")
'markdownDescription': nls.localize('detectIndentation', "Controls whether `#editor.tabSize#` and `#editor.insertSpaces#` will be automatically detected when a file is opened based on the file contents.")
},
'editor.roundedSelection': {
'type': 'boolean',
@@ -351,7 +348,7 @@ const editorConfiguration: IConfigurationNode = {
'editor.hover.delay': {
'type': 'number',
'default': EDITOR_DEFAULTS.contribInfo.hover.delay,
'description': nls.localize('hover.delay', "Time delay in milliseconds after which to the hover is shown.")
'description': nls.localize('hover.delay', "Controls the delay in milliseconds after which the hover is shown.")
},
'editor.hover.sticky': {
'type': 'boolean',
@@ -366,7 +363,7 @@ const editorConfiguration: IConfigurationNode = {
'editor.find.autoFindInSelection': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.find.autoFindInSelection,
'description': nls.localize('find.autoFindInSelection', "Controls whether the find operation is carried on selected text or the entire file in the editor.")
'description': nls.localize('find.autoFindInSelection', "Controls whether the find operation is carried out on selected text or the entire file in the editor.")
},
'editor.find.globalFindClipboard': {
'type': 'boolean',
@@ -377,7 +374,7 @@ const editorConfiguration: IConfigurationNode = {
'editor.wordWrap': {
'type': 'string',
'enum': ['off', 'on', 'wordWrapColumn', 'bounded'],
'enumDescriptions': [
'markdownEnumDescriptions': [
nls.localize('wordWrap.off', "Lines will never wrap."),
nls.localize('wordWrap.on', "Lines will wrap at the viewport width."),
nls.localize({
@@ -407,7 +404,7 @@ const editorConfiguration: IConfigurationNode = {
'type': 'integer',
'default': EDITOR_DEFAULTS.wordWrapColumn,
'minimum': 1,
'description': nls.localize({
'markdownDescription': nls.localize({
key: 'wordWrapColumn',
comment: [
'- `editor.wordWrap` refers to a different setting and should not be localized.',
@@ -430,17 +427,17 @@ const editorConfiguration: IConfigurationNode = {
'editor.mouseWheelScrollSensitivity': {
'type': 'number',
'default': EDITOR_DEFAULTS.viewInfo.scrollbar.mouseWheelScrollSensitivity,
'description': nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.")
'markdownDescription': nls.localize('mouseWheelScrollSensitivity', "A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.")
},
'editor.multiCursorModifier': {
'type': 'string',
'enum': ['ctrlCmd', 'alt'],
'enumDescriptions': [
'markdownEnumDescriptions': [
nls.localize('multiCursorModifier.ctrlCmd', "Maps to `Control` on Windows and Linux and to `Command` on macOS."),
nls.localize('multiCursorModifier.alt', "Maps to `Alt` on Windows and Linux and to `Option` on macOS.")
],
'default': 'alt',
'description': nls.localize({
'markdownDescription': nls.localize({
key: 'multiCursorModifier',
comment: [
'- `ctrlCmd` refers to a value the setting can take and should not be localized.',
@@ -488,16 +485,53 @@ const editorConfiguration: IConfigurationNode = {
'minimum': 0,
'description': nls.localize('quickSuggestionsDelay', "Controls the delay in milliseconds after which quick suggestions will show up.")
},
'editor.parameterHints': {
'editor.parameterHints.enabled': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.parameterHints,
'description': nls.localize('parameterHints', "Enables a pop-up that shows parameter documentation and type information as you type.")
'default': EDITOR_DEFAULTS.contribInfo.parameterHints.enabled,
'description': nls.localize('parameterHints.enabled', "Enables a pop-up that shows parameter documentation and type information as you type.")
},
'editor.parameterHints.cycle': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.parameterHints.cycle,
'description': nls.localize('parameterHints.cycle', "Controls whether the parameter hints menu cycles or closes when reaching the end of the list.")
},
'editor.autoClosingBrackets': {
'type': 'boolean',
type: 'string',
enum: ['always', 'languageDefined', 'beforeWhitespace', 'never'],
enumDescriptions: [
'',
nls.localize('editor.autoClosingBrackets.languageDefined', "Use language configurations to determine when to autoclose brackets."),
nls.localize('editor.autoClosingBrackets.beforeWhitespace', "Autoclose brackets only when the cursor is to the left of whitespace."),
'',
],
'default': EDITOR_DEFAULTS.autoClosingBrackets,
'description': nls.localize('autoClosingBrackets', "Controls whether the editor should automatically close brackets after the user adds an opening bracket.")
},
'editor.autoClosingQuotes': {
type: 'string',
enum: ['always', 'languageDefined', 'beforeWhitespace', 'never'],
enumDescriptions: [
'',
nls.localize('editor.autoClosingQuotes.languageDefined', "Use language configurations to determine when to autoclose quotes."),
nls.localize('editor.autoClosingQuotes.beforeWhitespace', "Autoclose quotes only when the cursor is to the left of whitespace."),
'',
],
'default': EDITOR_DEFAULTS.autoClosingQuotes,
'description': nls.localize('autoClosingQuotes', "Controls whether the editor should automatically close quotes after the user adds an opening quote.")
},
'editor.autoSurround': {
type: 'string',
enum: ['languageDefined', 'brackets', 'quotes', 'never'],
enumDescriptions: [
nls.localize('editor.autoSurround.languageDefined', "Use language configurations to determine when to automatically surround selections."),
nls.localize('editor.autoSurround.brackets', "Surround with brackets but not quotes."),
nls.localize('editor.autoSurround.quotes', "Surround with quotes but not brackets."),
''
],
'default': EDITOR_DEFAULTS.autoSurround,
'description': nls.localize('autoSurround', "Controls whether the editor should automatically surround selections.")
},
'editor.formatOnType': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.formatOnType,
@@ -522,17 +556,17 @@ const editorConfiguration: IConfigurationNode = {
'type': 'string',
'enum': ['on', 'smart', 'off'],
'default': EDITOR_DEFAULTS.contribInfo.acceptSuggestionOnEnter,
'enumDescriptions': [
'markdownEnumDescriptions': [
'',
nls.localize('acceptSuggestionOnEnterSmart', "Only accept a suggestion with `Enter` when it makes a textual change."),
''
],
'description': nls.localize('acceptSuggestionOnEnter', "Controls whether suggestions should be accepted on `Enter`, in addition to `Tab`. Helps to avoid ambiguity between inserting new lines or accepting suggestions.")
'markdownDescription': nls.localize('acceptSuggestionOnEnter', "Controls whether suggestions should be accepted on `Enter`, in addition to `Tab`. Helps to avoid ambiguity between inserting new lines or accepting suggestions.")
},
'editor.acceptSuggestionOnCommitCharacter': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.acceptSuggestionOnCommitCharacter,
'description': nls.localize('acceptSuggestionOnCommitCharacter', "Controls whether suggestions should be accepted on commit characters. For example, in JavaScript, the semi-colon (`;`) can be a commit character that accepts a suggestion and types that character.")
'markdownDescription': nls.localize('acceptSuggestionOnCommitCharacter', "Controls whether suggestions should be accepted on commit characters. For example, in JavaScript, the semi-colon (`;`) can be a commit character that accepts a suggestion and types that character.")
},
'editor.snippetSuggestions': {
'type': 'string',
@@ -551,6 +585,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.emptySelectionClipboard,
'description': nls.localize('emptySelectionClipboard', "Controls whether copying without a selection copies the current line.")
},
'editor.copyWithSyntaxHighlighting': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.copyWithSyntaxHighlighting,
'description': nls.localize('copyWithSyntaxHighlighting', "Controls whether syntax highlighting should be copied into the clipboard.")
},
'editor.wordBasedSuggestions': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.wordBasedSuggestions,
@@ -559,7 +598,7 @@ const editorConfiguration: IConfigurationNode = {
'editor.suggestSelection': {
'type': 'string',
'enum': ['first', 'recentlyUsed', 'recentlyUsedByPrefix'],
'enumDescriptions': [
'markdownEnumDescriptions': [
nls.localize('suggestSelection.first', "Always select the first suggestion."),
nls.localize('suggestSelection.recentlyUsed', "Select recent suggestions unless further typing selects one, e.g. `console.| -> console.log` because `log` has been completed recently."),
nls.localize('suggestSelection.recentlyUsedByPrefix', "Select suggestions based on previous prefixes that have completed those suggestions, e.g. `co -> console` and `con -> const`."),
@@ -571,19 +610,35 @@ const editorConfiguration: IConfigurationNode = {
'type': 'integer',
'default': 0,
'minimum': 0,
'description': nls.localize('suggestFontSize', "Font size for the suggest widget.")
'markdownDescription': nls.localize('suggestFontSize', "Font size for the suggest widget. When set to `0`, the value of `#editor.fontSize#` is used.")
},
'editor.suggestLineHeight': {
'type': 'integer',
'default': 0,
'minimum': 0,
'description': nls.localize('suggestLineHeight', "Line height for the suggest widget.")
'markdownDescription': nls.localize('suggestLineHeight', "Line height for the suggest widget. When set to `0`, the value of `#editor.lineHeight#` is used.")
},
'editor.tabCompletion': {
type: 'string',
default: 'off',
enum: ['on', 'off', 'onlySnippets'],
enumDescriptions: [
nls.localize('tabCompletion.on', "Tab complete will insert the best matching suggestion when pressing tab."),
nls.localize('tabCompletion.off', "Disable tab completions."),
nls.localize('tabCompletion.onlySnippets', "Tab complete snippets when their prefix match. Works best when 'quickSuggestions' aren't enabled."),
],
description: nls.localize('tabCompletion', "Enables tab completions.")
},
'editor.suggest.filterGraceful': {
type: 'boolean',
default: true,
description: nls.localize('suggest.filterGraceful', "Controls whether filtering and sorting suggestions accounts for small typos.")
},
'editor.suggest.localityBonus': {
type: 'boolean',
default: false,
description: nls.localize('suggest.localityBonus', "Controls whether sorting favours words that appear close to the cursor.")
},
'editor.suggest.snippetsPreventQuickSuggestions': {
type: 'boolean',
default: true,
@@ -618,7 +673,12 @@ const editorConfiguration: IConfigurationNode = {
'editor.mouseWheelZoom': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.viewInfo.mouseWheelZoom,
'description': nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding `Ctrl`.")
'markdownDescription': nls.localize('mouseWheelZoom', "Zoom the font of the editor when using mouse wheel and holding `Ctrl`.")
},
'editor.cursorSmoothCaretAnimation': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.viewInfo.cursorSmoothCaretAnimation,
'description': nls.localize('cursorSmoothCaretAnimation', "Controls whether the smooth caret animation should be enabled.")
},
'editor.cursorStyle': {
'type': 'string',
@@ -629,7 +689,7 @@ const editorConfiguration: IConfigurationNode = {
'editor.cursorWidth': {
'type': 'integer',
'default': EDITOR_DEFAULTS.viewInfo.cursorWidth,
'description': nls.localize('cursorWidth', "Controls the width of the cursor when `#editor.cursorStyle#` is set to `line`.")
'markdownDescription': nls.localize('cursorWidth', "Controls the width of the cursor when `#editor.cursorStyle#` is set to `line`.")
},
'editor.fontLigatures': {
'type': 'boolean',
@@ -693,7 +753,7 @@ const editorConfiguration: IConfigurationNode = {
'type': 'string',
'enum': ['auto', 'indentation'],
'default': EDITOR_DEFAULTS.contribInfo.foldingStrategy,
'description': nls.localize('foldingStrategy', "Controls the strategy for computing folding ranges. `auto` uses a language specific folding strategy, if available. `indentation` uses the indentation based folding strategy.")
'markdownDescription': nls.localize('foldingStrategy', "Controls the strategy for computing folding ranges. `auto` uses a language specific folding strategy, if available. `indentation` uses the indentation based folding strategy.")
},
'editor.showFoldingControls': {
'type': 'string',
@@ -724,7 +784,7 @@ const editorConfiguration: IConfigurationNode = {
'editor.stablePeek': {
'type': 'boolean',
'default': false,
'description': nls.localize('stablePeek', "Keep peek editors open even when double clicking their content or when hitting `Escape`.")
'markdownDescription': nls.localize('stablePeek', "Keep peek editors open even when double clicking their content or when hitting `Escape`.")
},
'editor.dragAndDrop': {
'type': 'boolean',
@@ -810,12 +870,12 @@ const editorConfiguration: IConfigurationNode = {
}
};
let cachedEditorConfigurationKeys: { [key: string]: boolean; } = null;
let cachedEditorConfigurationKeys: { [key: string]: boolean; } | null = null;
function getEditorConfigurationKeys(): { [key: string]: boolean; } {
if (cachedEditorConfigurationKeys === null) {
cachedEditorConfigurationKeys = Object.create(null);
Object.keys(editorConfiguration.properties).forEach((prop) => {
cachedEditorConfigurationKeys[prop] = true;
cachedEditorConfigurationKeys = <{ [key: string]: boolean; }>Object.create(null);
Object.keys(editorConfiguration.properties!).forEach((prop) => {
cachedEditorConfigurationKeys![prop] = true;
});
}
return cachedEditorConfigurationKeys;

View File

@@ -2,16 +2,15 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as nls from 'vs/nls';
import * as arrays from 'vs/base/common/arrays';
import * as objects from 'vs/base/common/objects';
import * as platform from 'vs/base/common/platform';
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { FontInfo } from 'vs/editor/common/config/fontInfo';
import { Constants } from 'vs/editor/common/core/uint';
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
import * as arrays from 'vs/base/common/arrays';
import * as objects from 'vs/base/common/objects';
/**
* Configuration options for editor scrollbars
@@ -24,16 +23,14 @@ export interface IEditorScrollbarOptions {
arrowSize?: number;
/**
* Render vertical scrollbar.
* Accepted values: 'auto', 'visible', 'hidden'.
* Defaults to 'auto'.
*/
vertical?: string;
vertical?: 'auto' | 'visible' | 'hidden';
/**
* Render horizontal scrollbar.
* Accepted values: 'auto', 'visible', 'hidden'.
* Defaults to 'auto'.
*/
horizontal?: string;
horizontal?: 'auto' | 'visible' | 'hidden';
/**
* Cast horizontal and vertical shadows when the content is scrolled.
* Defaults to true.
@@ -95,13 +92,23 @@ export interface IEditorFindOptions {
globalFindClipboard: boolean;
}
/**
* Configuration options for auto closing quotes and brackets
*/
export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';
/**
* Configuration options for auto wrapping quotes and brackets
*/
export type EditorAutoSurroundStrategy = 'languageDefined' | 'quotes' | 'brackets' | 'never';
/**
* Configuration options for editor minimap
*/
export interface IEditorMinimapOptions {
/**
* Enable the rendering of the minimap.
* Defaults to false.
* Defaults to true.
*/
enabled?: boolean;
/**
@@ -158,6 +165,22 @@ export interface IEditorHoverOptions {
sticky?: boolean;
}
/**
* Configuration options for parameter hints
*/
export interface IEditorParameterHintOptions {
/**
* Enable parameter hints.
* Defaults to true.
*/
enabled?: boolean;
/**
* Enable cycling of parameter hints.
* Defaults to false.
*/
cycle?: boolean;
}
export interface ISuggestOptions {
/**
* Enable graceful matching. Defaults to true.
@@ -167,6 +190,15 @@ export interface ISuggestOptions {
* Prevent quick suggestions when a snippet is active. Defaults to true.
*/
snippetsPreventQuickSuggestions?: boolean;
/**
* Favours words that appear close to the cursor.
*/
localityBonus?: boolean;
/**
* Enable using global storage for remembering suggestions.
*/
useGlobalStorageForSuggestions?: boolean;
}
/**
@@ -297,6 +329,11 @@ export interface IEditorOptions {
* @internal
*/
mouseStyle?: 'text' | 'default' | 'copy';
/**
* Enable smooth caret animation.
* Defaults to false.
*/
cursorSmoothCaretAnimation?: boolean;
/**
* Control the cursor style, either 'block' or 'line'.
* Defaults to 'line'.
@@ -451,19 +488,29 @@ export interface IEditorOptions {
*/
quickSuggestionsDelay?: number;
/**
* Enables parameter hints
* Parameter hint options.
*/
parameterHints?: boolean;
parameterHints?: IEditorParameterHintOptions;
/**
* Render icons in suggestions box.
* Defaults to true.
*/
iconsInSuggestions?: boolean;
/**
* Enable auto closing brackets.
* Defaults to true.
* Options for auto closing brackets.
* Defaults to language defined behavior.
*/
autoClosingBrackets?: boolean;
autoClosingBrackets?: EditorAutoClosingStrategy;
/**
* Options for auto closing quotes.
* Defaults to language defined behavior.
*/
autoClosingQuotes?: EditorAutoClosingStrategy;
/**
* Options for auto surrounding.
* Defaults to always allowing auto surrounding.
*/
autoSurround?: EditorAutoSurroundStrategy;
/**
* Enable auto indentation adjustment.
* Defaults to false.
@@ -507,6 +554,10 @@ export interface IEditorOptions {
* Copying without a selection copies the current line.
*/
emptySelectionClipboard?: boolean;
/**
* Syntax highlighting is copied.
*/
copyWithSyntaxHighlighting?: boolean;
/**
* Enable word based suggestions. Defaults to 'true'
*/
@@ -525,6 +576,10 @@ export interface IEditorOptions {
* Defaults to the editor line height.
*/
suggestLineHeight?: number;
/**
* Enable tab completion.
*/
tabCompletion?: boolean | 'on' | 'off' | 'onlySnippets';
/**
* Enable selection highlight.
* Defaults to true.
@@ -658,7 +713,7 @@ export interface IDiffEditorOptions extends IEditorOptions {
originalEditable?: boolean;
}
export enum RenderMinimap {
export const enum RenderMinimap {
None = 0,
Small = 1,
Large = 2,
@@ -669,7 +724,7 @@ export enum RenderMinimap {
/**
* Describes how to indent wrapped lines.
*/
export enum WrappingIndent {
export const enum WrappingIndent {
/**
* No indentation => wrapped lines begin at column 1.
*/
@@ -691,7 +746,7 @@ export enum WrappingIndent {
/**
* The kind of animation in which the editor's cursor should be rendered.
*/
export enum TextEditorCursorBlinkingStyle {
export const enum TextEditorCursorBlinkingStyle {
/**
* Hidden
*/
@@ -787,7 +842,7 @@ export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): string
}
}
function _cursorStyleFromString(cursorStyle: string, defaultValue: TextEditorCursorStyle): TextEditorCursorStyle {
function _cursorStyleFromString(cursorStyle: string | undefined, defaultValue: TextEditorCursorStyle): TextEditorCursorStyle {
if (typeof cursorStyle !== 'string') {
return defaultValue;
}
@@ -849,6 +904,13 @@ export interface InternalSuggestOptions {
readonly filterGraceful: boolean;
readonly snippets: 'top' | 'bottom' | 'inline' | 'none';
readonly snippetsPreventQuickSuggestions: boolean;
readonly localityBonus: boolean;
readonly shareSuggestSelections: boolean;
}
export interface InternalParameterHintOptions {
readonly enabled: boolean;
readonly cycle: boolean;
}
export interface EditorWrappingInfo {
@@ -877,7 +939,7 @@ export interface InternalEditorViewOptions {
readonly rulers: number[];
readonly ariaLabel: string;
readonly renderLineNumbers: RenderLineNumbersType;
readonly renderCustomLineNumbers: (lineNumber: number) => string;
readonly renderCustomLineNumbers: ((lineNumber: number) => string) | null;
readonly selectOnLineNumbers: boolean;
readonly glyphMargin: boolean;
readonly revealHorizontalRightPadding: number;
@@ -886,6 +948,7 @@ export interface InternalEditorViewOptions {
readonly overviewRulerBorder: boolean;
readonly cursorBlinking: TextEditorCursorBlinkingStyle;
readonly mouseWheelZoom: boolean;
readonly cursorSmoothCaretAnimation: boolean;
readonly cursorStyle: TextEditorCursorStyle;
readonly cursorWidth: number;
readonly hideCursorInOverviewRuler: boolean;
@@ -911,18 +974,18 @@ export interface EditorContribOptions {
readonly contextmenu: boolean;
readonly quickSuggestions: boolean | { other: boolean, comments: boolean, strings: boolean };
readonly quickSuggestionsDelay: number;
readonly parameterHints: boolean;
readonly parameterHints: InternalParameterHintOptions;
readonly iconsInSuggestions: boolean;
readonly formatOnType: boolean;
readonly formatOnPaste: boolean;
readonly suggestOnTriggerCharacters: boolean;
readonly acceptSuggestionOnEnter: 'on' | 'smart' | 'off';
readonly acceptSuggestionOnCommitCharacter: boolean;
// readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none';
readonly wordBasedSuggestions: boolean;
readonly suggestSelection: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
readonly suggestFontSize: number;
readonly suggestLineHeight: number;
readonly tabCompletion: 'on' | 'off' | 'onlySnippets';
readonly suggest: InternalSuggestOptions;
readonly selectionHighlight: boolean;
readonly occurrencesHighlight: boolean;
@@ -959,10 +1022,13 @@ export interface IValidatedEditorOptions {
readonly wordWrapBreakBeforeCharacters: string;
readonly wordWrapBreakAfterCharacters: string;
readonly wordWrapBreakObtrusiveCharacters: string;
readonly autoClosingBrackets: boolean;
readonly autoClosingBrackets: EditorAutoClosingStrategy;
readonly autoClosingQuotes: EditorAutoClosingStrategy;
readonly autoSurround: EditorAutoSurroundStrategy;
readonly autoIndent: boolean;
readonly dragAndDrop: boolean;
readonly emptySelectionClipboard: boolean;
readonly copyWithSyntaxHighlighting: boolean;
readonly useTabStops: boolean;
readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
readonly multiCursorMergeOverlapping: boolean;
@@ -994,12 +1060,15 @@ export class InternalEditorOptions {
// ---- cursor options
readonly wordSeparators: string;
readonly autoClosingBrackets: boolean;
readonly autoClosingBrackets: EditorAutoClosingStrategy;
readonly autoClosingQuotes: EditorAutoClosingStrategy;
readonly autoSurround: EditorAutoSurroundStrategy;
readonly autoIndent: boolean;
readonly useTabStops: boolean;
readonly tabFocusMode: boolean;
readonly dragAndDrop: boolean;
readonly emptySelectionClipboard: boolean;
readonly copyWithSyntaxHighlighting: boolean;
// ---- grouped options
readonly layoutInfo: EditorLayoutInfo;
@@ -1021,12 +1090,15 @@ export class InternalEditorOptions {
multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
multiCursorMergeOverlapping: boolean;
wordSeparators: string;
autoClosingBrackets: boolean;
autoClosingBrackets: EditorAutoClosingStrategy;
autoClosingQuotes: EditorAutoClosingStrategy;
autoSurround: EditorAutoSurroundStrategy;
autoIndent: boolean;
useTabStops: boolean;
tabFocusMode: boolean;
dragAndDrop: boolean;
emptySelectionClipboard: boolean;
copyWithSyntaxHighlighting: boolean;
layoutInfo: EditorLayoutInfo;
fontInfo: FontInfo;
viewInfo: InternalEditorViewOptions;
@@ -1044,11 +1116,14 @@ export class InternalEditorOptions {
this.multiCursorMergeOverlapping = source.multiCursorMergeOverlapping;
this.wordSeparators = source.wordSeparators;
this.autoClosingBrackets = source.autoClosingBrackets;
this.autoClosingQuotes = source.autoClosingQuotes;
this.autoSurround = source.autoSurround;
this.autoIndent = source.autoIndent;
this.useTabStops = source.useTabStops;
this.tabFocusMode = source.tabFocusMode;
this.dragAndDrop = source.dragAndDrop;
this.emptySelectionClipboard = source.emptySelectionClipboard;
this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting;
this.layoutInfo = source.layoutInfo;
this.fontInfo = source.fontInfo;
this.viewInfo = source.viewInfo;
@@ -1072,12 +1147,15 @@ export class InternalEditorOptions {
&& this.multiCursorMergeOverlapping === other.multiCursorMergeOverlapping
&& this.wordSeparators === other.wordSeparators
&& this.autoClosingBrackets === other.autoClosingBrackets
&& this.autoClosingQuotes === other.autoClosingQuotes
&& this.autoSurround === other.autoSurround
&& this.autoIndent === other.autoIndent
&& this.useTabStops === other.useTabStops
&& this.tabFocusMode === other.tabFocusMode
&& this.dragAndDrop === other.dragAndDrop
&& this.showUnused === other.showUnused
&& this.emptySelectionClipboard === other.emptySelectionClipboard
&& this.copyWithSyntaxHighlighting === other.copyWithSyntaxHighlighting
&& InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, other.layoutInfo)
&& this.fontInfo.equals(other.fontInfo)
&& InternalEditorOptions._equalsViewOptions(this.viewInfo, other.viewInfo)
@@ -1101,11 +1179,14 @@ export class InternalEditorOptions {
multiCursorMergeOverlapping: (this.multiCursorMergeOverlapping !== newOpts.multiCursorMergeOverlapping),
wordSeparators: (this.wordSeparators !== newOpts.wordSeparators),
autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets),
autoClosingQuotes: (this.autoClosingQuotes !== newOpts.autoClosingQuotes),
autoSurround: (this.autoSurround !== newOpts.autoSurround),
autoIndent: (this.autoIndent !== newOpts.autoIndent),
useTabStops: (this.useTabStops !== newOpts.useTabStops),
tabFocusMode: (this.tabFocusMode !== newOpts.tabFocusMode),
dragAndDrop: (this.dragAndDrop !== newOpts.dragAndDrop),
emptySelectionClipboard: (this.emptySelectionClipboard !== newOpts.emptySelectionClipboard),
copyWithSyntaxHighlighting: (this.copyWithSyntaxHighlighting !== newOpts.copyWithSyntaxHighlighting),
layoutInfo: (!InternalEditorOptions._equalsLayoutInfo(this.layoutInfo, newOpts.layoutInfo)),
fontInfo: (!this.fontInfo.equals(newOpts.fontInfo)),
viewInfo: (!InternalEditorOptions._equalsViewOptions(this.viewInfo, newOpts.viewInfo)),
@@ -1174,6 +1255,7 @@ export class InternalEditorOptions {
&& a.overviewRulerBorder === b.overviewRulerBorder
&& a.cursorBlinking === b.cursorBlinking
&& a.mouseWheelZoom === b.mouseWheelZoom
&& a.cursorSmoothCaretAnimation === b.cursorSmoothCaretAnimation
&& a.cursorStyle === b.cursorStyle
&& a.cursorWidth === b.cursorWidth
&& a.hideCursorInOverviewRuler === b.hideCursorInOverviewRuler
@@ -1237,6 +1319,16 @@ export class InternalEditorOptions {
);
}
/**
* @internal
*/
private static _equalsParameterHintOptions(a: InternalParameterHintOptions, b: InternalParameterHintOptions): boolean {
return (
a.enabled === b.enabled
&& a.cycle === b.cycle
);
}
/**
* @internal
*/
@@ -1259,7 +1351,9 @@ export class InternalEditorOptions {
} else {
return a.filterGraceful === b.filterGraceful
&& a.snippets === b.snippets
&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions;
&& a.snippetsPreventQuickSuggestions === b.snippetsPreventQuickSuggestions
&& a.localityBonus === b.localityBonus
&& a.shareSuggestSelections === b.shareSuggestSelections;
}
}
@@ -1291,7 +1385,7 @@ export class InternalEditorOptions {
&& a.contextmenu === b.contextmenu
&& InternalEditorOptions._equalsQuickSuggestions(a.quickSuggestions, b.quickSuggestions)
&& a.quickSuggestionsDelay === b.quickSuggestionsDelay
&& a.parameterHints === b.parameterHints
&& this._equalsParameterHintOptions(a.parameterHints, b.parameterHints)
&& a.iconsInSuggestions === b.iconsInSuggestions
&& a.formatOnType === b.formatOnType
&& a.formatOnPaste === b.formatOnPaste
@@ -1302,6 +1396,7 @@ export class InternalEditorOptions {
&& a.suggestSelection === b.suggestSelection
&& a.suggestFontSize === b.suggestFontSize
&& a.suggestLineHeight === b.suggestLineHeight
&& a.tabCompletion === b.tabCompletion
&& this._equalsSuggestOptions(a.suggest, b.suggest)
&& a.selectionHighlight === b.selectionHighlight
&& a.occurrencesHighlight === b.occurrencesHighlight
@@ -1472,11 +1567,14 @@ export interface IConfigurationChangedEvent {
readonly multiCursorMergeOverlapping: boolean;
readonly wordSeparators: boolean;
readonly autoClosingBrackets: boolean;
readonly autoClosingQuotes: boolean;
readonly autoSurround: boolean;
readonly autoIndent: boolean;
readonly useTabStops: boolean;
readonly tabFocusMode: boolean;
readonly dragAndDrop: boolean;
readonly emptySelectionClipboard: boolean;
readonly copyWithSyntaxHighlighting: boolean;
readonly layoutInfo: boolean;
readonly fontInfo: boolean;
readonly viewInfo: boolean;
@@ -1511,7 +1609,7 @@ function _boolean<T>(value: any, defaultValue: T): boolean | T {
return Boolean(value);
}
function _booleanMap(value: { [key: string]: boolean }, defaultValue: { [key: string]: boolean }): { [key: string]: boolean } {
function _booleanMap(value: { [key: string]: boolean } | undefined, defaultValue: { [key: string]: boolean }): { [key: string]: boolean } {
if (!value) {
return defaultValue;
}
@@ -1533,7 +1631,7 @@ function _string(value: any, defaultValue: string): string {
return value;
}
function _stringSet<T>(value: T, defaultValue: T, allowedValues: T[]): T {
function _stringSet<T>(value: T | undefined, defaultValue: T, allowedValues: T[]): T {
if (typeof value !== 'string') {
return defaultValue;
}
@@ -1566,7 +1664,7 @@ function _float(value: any, defaultValue: number): number {
return r;
}
function _wrappingIndentFromString(wrappingIndent: string, defaultValue: WrappingIndent): WrappingIndent {
function _wrappingIndentFromString(wrappingIndent: string | undefined, defaultValue: WrappingIndent): WrappingIndent {
if (typeof wrappingIndent !== 'string') {
return defaultValue;
}
@@ -1581,7 +1679,7 @@ function _wrappingIndentFromString(wrappingIndent: string, defaultValue: Wrappin
}
}
function _cursorBlinkingStyleFromString(cursorBlinkingStyle: string, defaultValue: TextEditorCursorBlinkingStyle): TextEditorCursorBlinkingStyle {
function _cursorBlinkingStyleFromString(cursorBlinkingStyle: string | undefined, defaultValue: TextEditorCursorBlinkingStyle): TextEditorCursorBlinkingStyle {
if (typeof cursorBlinkingStyle !== 'string') {
return defaultValue;
}
@@ -1601,7 +1699,7 @@ function _cursorBlinkingStyleFromString(cursorBlinkingStyle: string, defaultValu
return TextEditorCursorBlinkingStyle.Blink;
}
function _scrollbarVisibilityFromString(visibility: string, defaultValue: ScrollbarVisibility): ScrollbarVisibility {
function _scrollbarVisibilityFromString(visibility: string | undefined, defaultValue: ScrollbarVisibility): ScrollbarVisibility {
if (typeof visibility !== 'string') {
return defaultValue;
}
@@ -1640,7 +1738,7 @@ export class EditorOptionsValidator {
const viewInfo = this._sanitizeViewInfo(opts, defaults.viewInfo);
const contribInfo = this._sanitizeContribInfo(opts, defaults.contribInfo);
let configuredMulticursorModifier: 'altKey' | 'metaKey' | 'ctrlKey';
let configuredMulticursorModifier: 'altKey' | 'metaKey' | 'ctrlKey' | undefined = undefined;
if (typeof opts.multiCursorModifier === 'string') {
if (opts.multiCursorModifier === 'ctrlCmd') {
configuredMulticursorModifier = platform.isMacintosh ? 'metaKey' : 'ctrlKey';
@@ -1650,6 +1748,20 @@ export class EditorOptionsValidator {
}
const multiCursorModifier = _stringSet<'altKey' | 'metaKey' | 'ctrlKey'>(configuredMulticursorModifier, defaults.multiCursorModifier, ['altKey', 'metaKey', 'ctrlKey']);
let autoClosingBrackets: EditorAutoClosingStrategy;
let autoClosingQuotes: EditorAutoClosingStrategy;
let autoSurround: EditorAutoSurroundStrategy;
if (typeof opts.autoClosingBrackets === 'boolean' && opts.autoClosingBrackets === false) {
// backwards compatibility: disable all on boolean false
autoClosingBrackets = 'never';
autoClosingQuotes = 'never';
autoSurround = 'never';
} else {
autoClosingBrackets = _stringSet<EditorAutoClosingStrategy>(opts.autoClosingBrackets, defaults.autoClosingBrackets, ['always', 'languageDefined', 'beforeWhitespace', 'never']);
autoClosingQuotes = _stringSet<EditorAutoClosingStrategy>(opts.autoClosingQuotes, defaults.autoClosingQuotes, ['always', 'languageDefined', 'beforeWhitespace', 'never']);
autoSurround = _stringSet<EditorAutoSurroundStrategy>(opts.autoSurround, defaults.autoSurround, ['languageDefined', 'brackets', 'quotes', 'never']);
}
return {
inDiffEditor: _boolean(opts.inDiffEditor, defaults.inDiffEditor),
wordSeparators: _string(opts.wordSeparators, defaults.wordSeparators),
@@ -1666,10 +1778,13 @@ export class EditorOptionsValidator {
wordWrapBreakBeforeCharacters: _string(opts.wordWrapBreakBeforeCharacters, defaults.wordWrapBreakBeforeCharacters),
wordWrapBreakAfterCharacters: _string(opts.wordWrapBreakAfterCharacters, defaults.wordWrapBreakAfterCharacters),
wordWrapBreakObtrusiveCharacters: _string(opts.wordWrapBreakObtrusiveCharacters, defaults.wordWrapBreakObtrusiveCharacters),
autoClosingBrackets: _boolean(opts.autoClosingBrackets, defaults.autoClosingBrackets),
autoClosingBrackets,
autoClosingQuotes,
autoSurround,
autoIndent: _boolean(opts.autoIndent, defaults.autoIndent),
dragAndDrop: _boolean(opts.dragAndDrop, defaults.dragAndDrop),
emptySelectionClipboard: _boolean(opts.emptySelectionClipboard, defaults.emptySelectionClipboard),
copyWithSyntaxHighlighting: _boolean(opts.copyWithSyntaxHighlighting, defaults.copyWithSyntaxHighlighting),
useTabStops: _boolean(opts.useTabStops, defaults.useTabStops),
multiCursorModifier: multiCursorModifier,
multiCursorMergeOverlapping: _boolean(opts.multiCursorMergeOverlapping, defaults.multiCursorMergeOverlapping),
@@ -1680,7 +1795,7 @@ export class EditorOptionsValidator {
};
}
private static _sanitizeScrollbarOpts(opts: IEditorScrollbarOptions, defaults: InternalEditorScrollbarOptions, mouseWheelScrollSensitivity: number): InternalEditorScrollbarOptions {
private static _sanitizeScrollbarOpts(opts: IEditorScrollbarOptions | undefined, defaults: InternalEditorScrollbarOptions, mouseWheelScrollSensitivity: number): InternalEditorScrollbarOptions {
if (typeof opts !== 'object') {
return defaults;
}
@@ -1707,7 +1822,7 @@ export class EditorOptionsValidator {
};
}
private static _sanitizeMinimapOpts(opts: IEditorMinimapOptions, defaults: InternalEditorMinimapOptions): InternalEditorMinimapOptions {
private static _sanitizeMinimapOpts(opts: IEditorMinimapOptions | undefined, defaults: InternalEditorMinimapOptions): InternalEditorMinimapOptions {
if (typeof opts !== 'object') {
return defaults;
}
@@ -1720,7 +1835,7 @@ export class EditorOptionsValidator {
};
}
private static _santizeFindOpts(opts: IEditorFindOptions, defaults: InternalEditorFindOptions): InternalEditorFindOptions {
private static _santizeFindOpts(opts: IEditorFindOptions | undefined, defaults: InternalEditorFindOptions): InternalEditorFindOptions {
if (typeof opts !== 'object') {
return defaults;
}
@@ -1732,7 +1847,18 @@ export class EditorOptionsValidator {
};
}
private static _santizeHoverOpts(_opts: boolean | IEditorHoverOptions, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions {
private static _sanitizeParameterHintOpts(opts: IEditorParameterHintOptions | undefined, defaults: InternalParameterHintOptions): InternalParameterHintOptions {
if (typeof opts !== 'object') {
return defaults;
}
return {
enabled: _boolean(opts.enabled, defaults.enabled),
cycle: _boolean(opts.cycle, defaults.cycle)
};
}
private static _santizeHoverOpts(_opts: boolean | IEditorHoverOptions | undefined, defaults: InternalEditorHoverOptions): InternalEditorHoverOptions {
let opts: IEditorHoverOptions;
if (typeof _opts === 'boolean') {
opts = {
@@ -1757,9 +1883,20 @@ export class EditorOptionsValidator {
filterGraceful: _boolean(suggestOpts.filterGraceful, defaults.filterGraceful),
snippets: _stringSet<'top' | 'bottom' | 'inline' | 'none'>(opts.snippetSuggestions, defaults.snippets, ['top', 'bottom', 'inline', 'none']),
snippetsPreventQuickSuggestions: _boolean(suggestOpts.snippetsPreventQuickSuggestions, defaults.filterGraceful),
localityBonus: _boolean(suggestOpts.localityBonus, defaults.localityBonus),
shareSuggestSelections: _boolean(suggestOpts.useGlobalStorageForSuggestions, defaults.shareSuggestSelections)
};
}
private static _sanitizeTabCompletionOpts(opts: boolean | 'on' | 'off' | 'onlySnippets' | undefined, defaults: 'on' | 'off' | 'onlySnippets'): 'on' | 'off' | 'onlySnippets' {
if (opts === false) {
return 'off';
} else if (opts === true) {
return 'onlySnippets';
} else {
return _stringSet<'on' | 'off' | 'onlySnippets'>(opts, defaults, ['on', 'off', 'onlySnippets']);
}
}
private static _sanitizeViewInfo(opts: IEditorOptions, defaults: InternalEditorViewOptions): InternalEditorViewOptions {
@@ -1772,7 +1909,7 @@ export class EditorOptionsValidator {
}
let renderLineNumbers: RenderLineNumbersType = defaults.renderLineNumbers;
let renderCustomLineNumbers: (lineNumber: number) => string = defaults.renderCustomLineNumbers;
let renderCustomLineNumbers: ((lineNumber: number) => string) | null = defaults.renderCustomLineNumbers;
if (typeof opts.lineNumbers !== 'undefined') {
let lineNumbers = opts.lineNumbers;
@@ -1846,6 +1983,7 @@ export class EditorOptionsValidator {
overviewRulerBorder: _boolean(opts.overviewRulerBorder, defaults.overviewRulerBorder),
cursorBlinking: _cursorBlinkingStyleFromString(opts.cursorBlinking, defaults.cursorBlinking),
mouseWheelZoom: _boolean(opts.mouseWheelZoom, defaults.mouseWheelZoom),
cursorSmoothCaretAnimation: _boolean(opts.cursorSmoothCaretAnimation, defaults.cursorSmoothCaretAnimation),
cursorStyle: _cursorStyleFromString(opts.cursorStyle, defaults.cursorStyle),
cursorWidth: _clampedInt(opts.cursorWidth, defaults.cursorWidth, 0, Number.MAX_VALUE),
hideCursorInOverviewRuler: _boolean(opts.hideCursorInOverviewRuler, defaults.hideCursorInOverviewRuler),
@@ -1884,7 +2022,7 @@ export class EditorOptionsValidator {
contextmenu: _boolean(opts.contextmenu, defaults.contextmenu),
quickSuggestions: quickSuggestions,
quickSuggestionsDelay: _clampedInt(opts.quickSuggestionsDelay, defaults.quickSuggestionsDelay, Constants.MIN_SAFE_SMALL_INTEGER, Constants.MAX_SAFE_SMALL_INTEGER),
parameterHints: _boolean(opts.parameterHints, defaults.parameterHints),
parameterHints: this._sanitizeParameterHintOpts(opts.parameterHints, defaults.parameterHints),
iconsInSuggestions: _boolean(opts.iconsInSuggestions, defaults.iconsInSuggestions),
formatOnType: _boolean(opts.formatOnType, defaults.formatOnType),
formatOnPaste: _boolean(opts.formatOnPaste, defaults.formatOnPaste),
@@ -1895,6 +2033,7 @@ export class EditorOptionsValidator {
suggestSelection: _stringSet<'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'>(opts.suggestSelection, defaults.suggestSelection, ['first', 'recentlyUsed', 'recentlyUsedByPrefix']),
suggestFontSize: _clampedInt(opts.suggestFontSize, defaults.suggestFontSize, 0, 1000),
suggestLineHeight: _clampedInt(opts.suggestLineHeight, defaults.suggestLineHeight, 0, 1000),
tabCompletion: this._sanitizeTabCompletionOpts(opts.tabCompletion, defaults.tabCompletion),
suggest: this._sanitizeSuggestOpts(opts, defaults.suggest),
selectionHighlight: _boolean(opts.selectionHighlight, defaults.selectionHighlight),
occurrencesHighlight: _boolean(opts.occurrencesHighlight, defaults.occurrencesHighlight),
@@ -1937,9 +2076,12 @@ export class InternalEditorOptionsFactory {
wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
autoClosingBrackets: opts.autoClosingBrackets,
autoClosingQuotes: opts.autoClosingQuotes,
autoSurround: opts.autoSurround,
autoIndent: opts.autoIndent,
dragAndDrop: opts.dragAndDrop,
emptySelectionClipboard: opts.emptySelectionClipboard,
copyWithSyntaxHighlighting: opts.copyWithSyntaxHighlighting,
useTabStops: opts.useTabStops,
multiCursorModifier: opts.multiCursorModifier,
multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping,
@@ -1961,6 +2103,7 @@ export class InternalEditorOptionsFactory {
overviewRulerBorder: opts.viewInfo.overviewRulerBorder,
cursorBlinking: opts.viewInfo.cursorBlinking,
mouseWheelZoom: opts.viewInfo.mouseWheelZoom,
cursorSmoothCaretAnimation: opts.viewInfo.cursorSmoothCaretAnimation,
cursorStyle: opts.viewInfo.cursorStyle,
cursorWidth: opts.viewInfo.cursorWidth,
hideCursorInOverviewRuler: opts.viewInfo.hideCursorInOverviewRuler,
@@ -2003,6 +2146,7 @@ export class InternalEditorOptionsFactory {
suggestSelection: opts.contribInfo.suggestSelection,
suggestFontSize: opts.contribInfo.suggestFontSize,
suggestLineHeight: opts.contribInfo.suggestLineHeight,
tabCompletion: opts.contribInfo.tabCompletion,
suggest: opts.contribInfo.suggest,
selectionHighlight: (accessibilityIsOn ? false : opts.contribInfo.selectionHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
occurrencesHighlight: (accessibilityIsOn ? false : opts.contribInfo.occurrencesHighlight), // DISABLED WHEN SCREEN READER IS ATTACHED
@@ -2069,7 +2213,7 @@ export class InternalEditorOptionsFactory {
pixelRatio: env.pixelRatio
});
let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } = null;
let bareWrappingInfo: { isWordWrapMinified: boolean; isViewportWrapping: boolean; wrappingColumn: number; } | null = null;
{
const wordWrap = opts.wordWrap;
const wordWrapColumn = opts.wordWrapColumn;
@@ -2158,11 +2302,14 @@ export class InternalEditorOptionsFactory {
multiCursorMergeOverlapping: opts.multiCursorMergeOverlapping,
wordSeparators: opts.wordSeparators,
autoClosingBrackets: opts.autoClosingBrackets,
autoClosingQuotes: opts.autoClosingQuotes,
autoSurround: opts.autoSurround,
autoIndent: opts.autoIndent,
useTabStops: opts.useTabStops,
tabFocusMode: opts.readOnly ? true : env.tabFocusMode,
dragAndDrop: opts.dragAndDrop,
emptySelectionClipboard: opts.emptySelectionClipboard && env.emptySelectionClipboard,
copyWithSyntaxHighlighting: opts.copyWithSyntaxHighlighting,
layoutInfo: layoutInfo,
fontInfo: env.fontInfo,
viewInfo: opts.viewInfo,
@@ -2390,10 +2537,13 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
wordWrapBreakBeforeCharacters: '([{‘“〈《「『【〔([{「£¥$£¥+',
wordWrapBreakAfterCharacters: ' \t})]?|&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
wordWrapBreakObtrusiveCharacters: '.',
autoClosingBrackets: true,
autoClosingBrackets: 'languageDefined',
autoClosingQuotes: 'languageDefined',
autoSurround: 'languageDefined',
autoIndent: true,
dragAndDrop: true,
emptySelectionClipboard: true,
copyWithSyntaxHighlighting: true,
useTabStops: true,
multiCursorModifier: 'altKey',
multiCursorMergeOverlapping: true,
@@ -2415,6 +2565,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
overviewRulerBorder: true,
cursorBlinking: TextEditorCursorBlinkingStyle.Blink,
mouseWheelZoom: false,
cursorSmoothCaretAnimation: false,
cursorStyle: TextEditorCursorStyle.Line,
cursorWidth: 0,
hideCursorInOverviewRuler: false,
@@ -2464,7 +2615,10 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
contextmenu: true,
quickSuggestions: { other: true, comments: false, strings: false },
quickSuggestionsDelay: 10,
parameterHints: true,
parameterHints: {
enabled: true,
cycle: false
},
iconsInSuggestions: true,
formatOnType: false,
formatOnPaste: false,
@@ -2475,10 +2629,13 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
suggestSelection: 'recentlyUsed',
suggestFontSize: 0,
suggestLineHeight: 0,
tabCompletion: 'off',
suggest: {
filterGraceful: true,
snippets: 'inline',
snippetsPreventQuickSuggestions: true
snippetsPreventQuickSuggestions: true,
localityBonus: false,
shareSuggestSelections: false
},
selectionHighlight: true,
occurrencesHighlight: true,

View File

@@ -2,9 +2,8 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { Event, Emitter } from 'vs/base/common/event';
import { Emitter, Event } from 'vs/base/common/event';
export interface IEditorZoom {
onDidChangeZoomLevel: Event<number>;

View File

@@ -2,11 +2,10 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as platform from 'vs/base/common/platform';
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
/**
* Determined from empirical observations.
@@ -24,10 +23,13 @@ const MAXIMUM_LINE_HEIGHT = 150;
const MINIMUM_LETTER_SPACING = -5;
const MAXIMUM_LETTER_SPACING = 20;
function safeParseFloat(n: number | string, defaultValue: number): number {
function safeParseFloat(n: number | string | undefined, defaultValue: number): number {
if (typeof n === 'number') {
return n;
}
if (typeof n === 'undefined') {
return defaultValue;
}
let r = parseFloat(n);
if (isNaN(r)) {
return defaultValue;
@@ -35,10 +37,13 @@ function safeParseFloat(n: number | string, defaultValue: number): number {
return r;
}
function safeParseInt(n: number | string, defaultValue: number): number {
function safeParseInt(n: number | string | undefined, defaultValue: number): number {
if (typeof n === 'number') {
return Math.round(n);
}
if (typeof n === 'undefined') {
return defaultValue;
}
let r = parseInt(n);
if (isNaN(r)) {
return defaultValue;
@@ -146,6 +151,22 @@ export class BareFontInfo {
public getId(): string {
return this.zoomLevel + '-' + this.fontFamily + '-' + this.fontWeight + '-' + this.fontSize + '-' + this.lineHeight + '-' + this.letterSpacing;
}
/**
* @internal
*/
public getMassagedFontFamily(): string {
if (/[,"']/.test(this.fontFamily)) {
// Looks like the font family might be already escaped
return this.fontFamily;
}
if (/[+ ]/.test(this.fontFamily)) {
// Wrap a font family using + or <space> with quotes
return `"${this.fontFamily}"`;
}
return this.fontFamily;
}
}
export class FontInfo extends BareFontInfo {
@@ -155,6 +176,7 @@ export class FontInfo extends BareFontInfo {
readonly isMonospace: boolean;
readonly typicalHalfwidthCharacterWidth: number;
readonly typicalFullwidthCharacterWidth: number;
readonly canUseHalfwidthRightwardsArrow: boolean;
readonly spaceWidth: number;
readonly maxDigitWidth: number;
@@ -171,6 +193,7 @@ export class FontInfo extends BareFontInfo {
isMonospace: boolean;
typicalHalfwidthCharacterWidth: number;
typicalFullwidthCharacterWidth: number;
canUseHalfwidthRightwardsArrow: boolean;
spaceWidth: number;
maxDigitWidth: number;
}, isTrusted: boolean) {
@@ -179,6 +202,7 @@ export class FontInfo extends BareFontInfo {
this.isMonospace = opts.isMonospace;
this.typicalHalfwidthCharacterWidth = opts.typicalHalfwidthCharacterWidth;
this.typicalFullwidthCharacterWidth = opts.typicalFullwidthCharacterWidth;
this.canUseHalfwidthRightwardsArrow = opts.canUseHalfwidthRightwardsArrow;
this.spaceWidth = opts.spaceWidth;
this.maxDigitWidth = opts.maxDigitWidth;
}
@@ -195,6 +219,7 @@ export class FontInfo extends BareFontInfo {
&& this.letterSpacing === other.letterSpacing
&& this.typicalHalfwidthCharacterWidth === other.typicalHalfwidthCharacterWidth
&& this.typicalFullwidthCharacterWidth === other.typicalFullwidthCharacterWidth
&& this.canUseHalfwidthRightwardsArrow === other.canUseHalfwidthRightwardsArrow
&& this.spaceWidth === other.spaceWidth
&& this.maxDigitWidth === other.maxDigitWidth
);