Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)

* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
This commit is contained in:
Anthony Dresser
2019-09-15 22:38:26 -07:00
committed by GitHub
parent fa6c52699e
commit ea0f9e6ce9
1226 changed files with 21541 additions and 17633 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as platform from 'vs/base/common/platform';
import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
import { EditorOptions, ValidatedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions';
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
/**
@@ -14,59 +14,9 @@ import { EditorZoom } from 'vs/editor/common/config/editorZoom';
const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
/**
* Font settings maximum and minimum limits
* @internal
*/
const MINIMUM_FONT_SIZE = 8;
const MAXIMUM_FONT_SIZE = 100;
const MINIMUM_LINE_HEIGHT = 8;
const MAXIMUM_LINE_HEIGHT = 150;
const MINIMUM_LETTER_SPACING = -5;
const MAXIMUM_LETTER_SPACING = 20;
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;
}
return r;
}
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;
}
return r;
}
function clamp(n: number, min: number, max: number): number {
if (n < min) {
return min;
}
if (n > max) {
return max;
}
return n;
}
function _string(value: any, defaultValue: string): string {
if (typeof value !== 'string') {
return defaultValue;
}
return value;
}
export class BareFontInfo {
readonly _bareFontInfoBrand: void;
@@ -74,38 +24,38 @@ export class BareFontInfo {
/**
* @internal
*/
public static createFromRawSettings(opts: {
fontFamily?: string;
fontWeight?: string;
fontSize?: number | string;
lineHeight?: number | string;
letterSpacing?: number | string;
}, zoomLevel: number, ignoreEditorZoom: boolean = false): BareFontInfo {
public static createFromValidatedSettings(options: ValidatedEditorOptions, zoomLevel: number, ignoreEditorZoom: boolean): BareFontInfo {
const fontFamily = options.get(EditorOption.fontFamily);
const fontWeight = options.get(EditorOption.fontWeight);
const fontSize = options.get(EditorOption.fontSize);
const lineHeight = options.get(EditorOption.lineHeight);
const letterSpacing = options.get(EditorOption.letterSpacing);
return BareFontInfo._create(fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, zoomLevel, ignoreEditorZoom);
}
let fontFamily = _string(opts.fontFamily, EDITOR_FONT_DEFAULTS.fontFamily);
let fontWeight = _string(opts.fontWeight, EDITOR_FONT_DEFAULTS.fontWeight);
/**
* @internal
*/
public static createFromRawSettings(opts: { fontFamily?: string; fontWeight?: string; fontSize?: number; lineHeight?: number; letterSpacing?: number; }, zoomLevel: number, ignoreEditorZoom: boolean = false): BareFontInfo {
const fontFamily = EditorOptions.fontFamily.validate(opts.fontFamily);
const fontWeight = EditorOptions.fontWeight.validate(opts.fontWeight);
const fontSize = EditorOptions.fontSize.validate(opts.fontSize);
const lineHeight = EditorOptions.lineHeight.validate(opts.lineHeight);
const letterSpacing = EditorOptions.letterSpacing.validate(opts.letterSpacing);
return BareFontInfo._create(fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, zoomLevel, ignoreEditorZoom);
}
let fontSize = safeParseFloat(opts.fontSize, EDITOR_FONT_DEFAULTS.fontSize);
fontSize = clamp(fontSize, 0, MAXIMUM_FONT_SIZE);
if (fontSize === 0) {
fontSize = EDITOR_FONT_DEFAULTS.fontSize;
} else if (fontSize < MINIMUM_FONT_SIZE) {
fontSize = MINIMUM_FONT_SIZE;
}
let lineHeight = safeParseInt(opts.lineHeight, 0);
lineHeight = clamp(lineHeight, 0, MAXIMUM_LINE_HEIGHT);
/**
* @internal
*/
private static _create(fontFamily: string, fontWeight: string, fontSize: number, lineHeight: number, letterSpacing: number, zoomLevel: number, ignoreEditorZoom: boolean): BareFontInfo {
if (lineHeight === 0) {
lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize);
} else if (lineHeight < MINIMUM_LINE_HEIGHT) {
lineHeight = MINIMUM_LINE_HEIGHT;
}
let letterSpacing = safeParseFloat(opts.letterSpacing, 0);
letterSpacing = clamp(letterSpacing, MINIMUM_LETTER_SPACING, MAXIMUM_LETTER_SPACING);
let editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1);
const editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1);
fontSize *= editorZoomLevelMultiplier;
lineHeight *= editorZoomLevelMultiplier;

View File

@@ -20,6 +20,7 @@ import { RawContentChangedType } from 'vs/editor/common/model/textModelEvents';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
import { dispose } from 'vs/base/common/lifecycle';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
function containsLineMappingChanged(events: viewEvents.ViewEvent[]): boolean {
for (let i = 0, len = events.length; i < len; i++) {
@@ -295,12 +296,12 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this._columnSelectData = columnSelectData;
}
public reveal(horizontal: boolean, target: RevealTarget, scrollType: editorCommon.ScrollType): void {
this._revealRange(target, viewEvents.VerticalRevealType.Simple, horizontal, scrollType);
public reveal(source: string, horizontal: boolean, target: RevealTarget, scrollType: editorCommon.ScrollType): void {
this._revealRange(source, target, viewEvents.VerticalRevealType.Simple, horizontal, scrollType);
}
public revealRange(revealHorizontal: boolean, viewRange: Range, verticalType: viewEvents.VerticalRevealType, scrollType: editorCommon.ScrollType) {
this.emitCursorRevealRange(viewRange, verticalType, revealHorizontal, scrollType);
public revealRange(source: string, revealHorizontal: boolean, viewRange: Range, verticalType: viewEvents.VerticalRevealType, scrollType: editorCommon.ScrollType) {
this.emitCursorRevealRange(source, viewRange, verticalType, revealHorizontal, scrollType);
}
public scrollTo(desiredScrollTop: number): void {
@@ -371,7 +372,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
}
this.setStates('restoreState', CursorChangeReason.NotSet, CursorState.fromModelSelections(desiredSelections));
this.reveal(true, RevealTarget.Primary, editorCommon.ScrollType.Immediate);
this.reveal('restoreState', true, RevealTarget.Primary, editorCommon.ScrollType.Immediate);
}
private _onModelContentChanged(hadFlushEvent: boolean): void {
@@ -399,7 +400,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return this._columnSelectData;
}
const primaryCursor = this._cursors.getPrimaryCursor();
const primaryPos = primaryCursor.viewState.position;
const primaryPos = primaryCursor.viewState.selectionStart.getStartPosition();
const viewLineNumber = primaryPos.lineNumber;
const viewVisualColumn = CursorColumns.visibleColumnFromColumn2(this.context.config, this.context.viewModel, primaryPos);
return {
@@ -543,7 +544,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return true;
}
private _revealRange(revealTarget: RevealTarget, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void {
private _revealRange(source: string, revealTarget: RevealTarget, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void {
const viewPositions = this._cursors.getViewPositions();
let viewPosition = viewPositions[0];
@@ -568,13 +569,13 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
}
const viewRange = new Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column);
this.emitCursorRevealRange(viewRange, verticalType, revealHorizontal, scrollType);
this.emitCursorRevealRange(source, viewRange, verticalType, revealHorizontal, scrollType);
}
public emitCursorRevealRange(viewRange: Range, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType) {
public emitCursorRevealRange(source: string, viewRange: Range, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType) {
try {
const eventsCollector = this._beginEmit();
eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(viewRange, verticalType, revealHorizontal, scrollType));
eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(source, viewRange, verticalType, revealHorizontal, scrollType));
} finally {
this._endEmit();
}
@@ -643,9 +644,17 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
autoClosedEnclosingRanges.push(new Range(lineNumber, openCharIndex + 1, lineNumber, closeCharIndex + 2));
}
}
return cursorStateComputer(undoEdits);
const selections = cursorStateComputer(undoEdits);
if (selections) {
// Don't recover the selection from markers because
// we know what it should be.
this._isHandling = true;
}
return selections;
});
if (selections) {
this._isHandling = false;
this.setSelections(source, selections);
}
if (autoClosedCharactersRanges.length > 0) {
@@ -665,7 +674,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this._isDoingComposition = false;
}
if (this._configuration.editor.readOnly) {
if (this._configuration.options.get(EditorOption.readOnly)) {
// All the remaining handlers will try to edit the model,
// but we cannot edit when read only...
this._onDidAttemptReadOnlyEdit.fire(undefined);
@@ -740,7 +749,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this._validateAutoClosedActions();
if (this._emitStateChangedIfNecessary(source, cursorChangeReason, oldState)) {
this._revealRange(RevealTarget.Primary, viewEvents.VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth);
this._revealRange(source, RevealTarget.Primary, viewEvents.VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth);
}
}

View File

@@ -6,7 +6,7 @@
import { CharCode } from 'vs/base/common/charCode';
import { onUnexpectedError } from 'vs/base/common/errors';
import * as strings from 'vs/base/common/strings';
import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy } from 'vs/editor/common/config/editorOptions';
import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, ConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOption } from 'vs/editor/common/config/editorOptions';
import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
@@ -55,8 +55,8 @@ export interface ICursors {
setColumnSelectData(columnSelectData: IColumnSelectData): void;
setStates(source: string, reason: CursorChangeReason, states: PartialCursorState[] | null): void;
reveal(horizontal: boolean, target: RevealTarget, scrollType: ScrollType): void;
revealRange(revealHorizontal: boolean, viewRange: Range, verticalType: VerticalRevealType, scrollType: ScrollType): void;
reveal(source: string, horizontal: boolean, target: RevealTarget, scrollType: ScrollType): void;
revealRange(source: string, revealHorizontal: boolean, viewRange: Range, verticalType: VerticalRevealType, scrollType: ScrollType): void;
scrollTo(desiredScrollTop: number): void;
@@ -97,6 +97,7 @@ export class CursorConfiguration {
public readonly emptySelectionClipboard: boolean;
public readonly copyWithSyntaxHighlighting: boolean;
public readonly multiCursorMergeOverlapping: boolean;
public readonly multiCursorPaste: 'spread' | 'full';
public readonly autoClosingBrackets: EditorAutoClosingStrategy;
public readonly autoClosingQuotes: EditorAutoClosingStrategy;
public readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy;
@@ -110,19 +111,20 @@ export class CursorConfiguration {
private readonly _languageIdentifier: LanguageIdentifier;
private _electricChars: { [key: string]: boolean; } | null;
public static shouldRecreate(e: IConfigurationChangedEvent): boolean {
public static shouldRecreate(e: ConfigurationChangedEvent): boolean {
return (
e.layoutInfo
|| e.wordSeparators
|| e.emptySelectionClipboard
|| e.multiCursorMergeOverlapping
|| e.autoClosingBrackets
|| e.autoClosingQuotes
|| e.autoClosingOvertype
|| e.autoSurround
|| e.useTabStops
|| e.lineHeight
|| e.readOnly
e.hasChanged(EditorOption.layoutInfo)
|| e.hasChanged(EditorOption.wordSeparators)
|| e.hasChanged(EditorOption.emptySelectionClipboard)
|| e.hasChanged(EditorOption.multiCursorMergeOverlapping)
|| e.hasChanged(EditorOption.multiCursorPaste)
|| e.hasChanged(EditorOption.autoClosingBrackets)
|| e.hasChanged(EditorOption.autoClosingQuotes)
|| e.hasChanged(EditorOption.autoClosingOvertype)
|| e.hasChanged(EditorOption.autoSurround)
|| e.hasChanged(EditorOption.useTabStops)
|| e.hasChanged(EditorOption.lineHeight)
|| e.hasChanged(EditorOption.readOnly)
);
}
@@ -133,24 +135,26 @@ export class CursorConfiguration {
) {
this._languageIdentifier = languageIdentifier;
let c = configuration.editor;
const options = configuration.options;
const layoutInfo = options.get(EditorOption.layoutInfo);
this.readOnly = c.readOnly;
this.readOnly = options.get(EditorOption.readOnly);
this.tabSize = modelOptions.tabSize;
this.indentSize = modelOptions.indentSize;
this.insertSpaces = modelOptions.insertSpaces;
this.pageSize = Math.max(1, Math.floor(c.layoutInfo.height / c.fontInfo.lineHeight) - 2);
this.lineHeight = c.lineHeight;
this.useTabStops = c.useTabStops;
this.wordSeparators = c.wordSeparators;
this.emptySelectionClipboard = c.emptySelectionClipboard;
this.copyWithSyntaxHighlighting = c.copyWithSyntaxHighlighting;
this.multiCursorMergeOverlapping = c.multiCursorMergeOverlapping;
this.autoClosingBrackets = c.autoClosingBrackets;
this.autoClosingQuotes = c.autoClosingQuotes;
this.autoClosingOvertype = c.autoClosingOvertype;
this.autoSurround = c.autoSurround;
this.autoIndent = c.autoIndent;
this.lineHeight = options.get(EditorOption.lineHeight);
this.pageSize = Math.max(1, Math.floor(layoutInfo.height / this.lineHeight) - 2);
this.useTabStops = options.get(EditorOption.useTabStops);
this.wordSeparators = options.get(EditorOption.wordSeparators);
this.emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard);
this.copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting);
this.multiCursorMergeOverlapping = options.get(EditorOption.multiCursorMergeOverlapping);
this.multiCursorPaste = options.get(EditorOption.multiCursorPaste);
this.autoClosingBrackets = options.get(EditorOption.autoClosingBrackets);
this.autoClosingQuotes = options.get(EditorOption.autoClosingQuotes);
this.autoClosingOvertype = options.get(EditorOption.autoClosingOvertype);
this.autoSurround = options.get(EditorOption.autoSurround);
this.autoIndent = options.get(EditorOption.autoIndent);
this.autoClosingPairsOpen2 = new Map<string, StandardAutoClosingPairConditional[]>();
this.autoClosingPairsClose2 = new Map<string, StandardAutoClosingPairConditional[]>();

View File

@@ -105,7 +105,7 @@ export class TypeOperations {
});
}
private static _distributePasteToCursors(selections: Selection[], text: string, pasteOnNewLine: boolean, multicursorText: string[]): string[] | null {
private static _distributePasteToCursors(config: CursorConfiguration, selections: Selection[], text: string, pasteOnNewLine: boolean, multicursorText: string[]): string[] | null {
if (pasteOnNewLine) {
return null;
}
@@ -118,20 +118,27 @@ export class TypeOperations {
return multicursorText;
}
// Remove trailing \n if present
if (text.charCodeAt(text.length - 1) === CharCode.LineFeed) {
text = text.substr(0, text.length - 1);
}
let lines = text.split(/\r\n|\r|\n/);
if (lines.length === selections.length) {
return lines;
if (config.multiCursorPaste === 'spread') {
// Try to spread the pasted text in case the line count matches the cursor count
// Remove trailing \n if present
if (text.charCodeAt(text.length - 1) === CharCode.LineFeed) {
text = text.substr(0, text.length - 1);
}
// Remove trailing \r if present
if (text.charCodeAt(text.length - 1) === CharCode.CarriageReturn) {
text = text.substr(0, text.length - 1);
}
let lines = text.split(/\r\n|\r|\n/);
if (lines.length === selections.length) {
return lines;
}
}
return null;
}
public static paste(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[], text: string, pasteOnNewLine: boolean, multicursorText: string[]): EditOperationResult {
const distributedPaste = this._distributePasteToCursors(selections, text, pasteOnNewLine, multicursorText);
const distributedPaste = this._distributePasteToCursors(config, selections, text, pasteOnNewLine, multicursorText);
if (distributedPaste) {
selections = selections.sort(Range.compareRangesUsingStarts);

View File

@@ -6,7 +6,7 @@
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { IDisposable } from 'vs/base/common/lifecycle';
import { URI, UriComponents } from 'vs/base/common/uri';
import * as editorOptions from 'vs/editor/common/config/editorOptions';
import { ConfigurationChangedEvent, IComputedEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IPosition, Position } from 'vs/editor/common/core/position';
import { IRange, Range } from 'vs/editor/common/core/range';
import { ISelection, Selection } from 'vs/editor/common/core/selection';
@@ -149,13 +149,13 @@ export interface ILineChange extends IChange {
* @internal
*/
export interface IConfiguration extends IDisposable {
onDidChange(listener: (e: editorOptions.IConfigurationChangedEvent) => void): IDisposable;
onDidChange(listener: (e: ConfigurationChangedEvent) => void): IDisposable;
readonly editor: editorOptions.InternalEditorOptions;
readonly options: IComputedEditorOptions;
setMaxLineNumber(maxLineNumber: number): void;
updateOptions(newOptions: editorOptions.IEditorOptions): void;
getRawOptions(): editorOptions.IEditorOptions;
updateOptions(newOptions: IEditorOptions): void;
getRawOptions(): IEditorOptions;
observeReferenceElement(dimension?: IDimension): void;
setIsDominatedByLongLines(isDominatedByLongLines: boolean): void;
}
@@ -263,7 +263,7 @@ export interface IEditor {
/**
* Update the editor's options after the editor has been created.
*/
updateOptions(newOptions: editorOptions.IEditorOptions): void;
updateOptions(newOptions: IEditorOptions): void;
/**
* Indicates that the editor becomes visible.

View File

@@ -2621,8 +2621,8 @@ class DecorationOptions implements model.IDecorationOptions {
readonly darkColor: string | ThemeColor;
constructor(options: model.IDecorationOptions) {
this.color = options.color || strings.empty;
this.darkColor = options.darkColor || strings.empty;
this.color = options.color || '';
this.darkColor = options.darkColor || '';
}
}
@@ -2658,7 +2658,7 @@ export class ModelDecorationOverviewRulerOptions extends DecorationOptions {
}
let c = color ? theme.getColor(color.id) : null;
if (!c) {
return strings.empty;
return '';
}
return c.toString();
}

View File

@@ -45,7 +45,8 @@ export class SearchParams {
matchCase: this.matchCase,
wholeWord: false,
multiline: multiline,
global: true
global: true,
unicode: true
});
} catch (err) {
return null;

View File

@@ -1402,6 +1402,15 @@ export interface IWebviewPanelOptions {
readonly retainContextWhenHidden?: boolean;
}
/**
* @internal
*/
export const enum WebviewEditorState {
Readonly = 1,
Unchanged = 2,
Dirty = 3,
}
export interface CodeLens {
range: IRange;
id?: string;

View File

@@ -18,7 +18,7 @@ export interface IDiffComputationResult {
}
export interface IEditorWorkerService {
_serviceBrand: any;
_serviceBrand: undefined;
canComputeDiff(original: URI, modified: URI): boolean;
computeDiff(original: URI, modified: URI, ignoreTrimWhitespace: boolean): Promise<IDiffComputationResult | null>;

View File

@@ -8,7 +8,6 @@ import { Disposable, IDisposable, dispose, toDisposable, DisposableStore } from
import { URI } from 'vs/base/common/uri';
import { SimpleWorkerClient, logOnceWebWorkerWarning, IWorkerClient } from 'vs/base/common/worker/simpleWorker';
import { DefaultWorkerFactory } from 'vs/base/worker/defaultWorkerFactory';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IPosition, Position } from 'vs/editor/common/core/position';
import { IRange } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
@@ -46,7 +45,7 @@ function canSyncModel(modelService: IModelService, resource: URI): boolean {
}
export class EditorWorkerServiceImpl extends Disposable implements IEditorWorkerService {
public _serviceBrand: any;
public _serviceBrand: undefined;
private readonly _modelService: IModelService;
private readonly _workerManager: WorkerManager;
@@ -146,7 +145,7 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider {
}
provideCompletionItems(model: ITextModel, position: Position): Promise<modes.CompletionList | null> | undefined {
const { wordBasedSuggestions } = this._configurationService.getValue<IEditorOptions>(model.uri, position, 'editor');
const { wordBasedSuggestions } = this._configurationService.getValue<{ wordBasedSuggestions?: boolean }>(model.uri, position, 'editor');
if (!wordBasedSuggestions) {
return undefined;
}

View File

@@ -61,7 +61,7 @@ class MarkerDecorations extends Disposable {
export class MarkerDecorationsService extends Disposable implements IMarkerDecorationsService {
_serviceBrand: any;
_serviceBrand: undefined;
private readonly _onDidChangeMarker = this._register(new Emitter<ITextModel>());
readonly onDidChangeMarker: Event<ITextModel> = this._onDidChangeMarker.event;

View File

@@ -12,7 +12,7 @@ import { Range } from 'vs/editor/common/core/range';
export const IMarkerDecorationsService = createDecorator<IMarkerDecorationsService>('markerDecorationsService');
export interface IMarkerDecorationsService {
_serviceBrand: any;
_serviceBrand: undefined;
onDidChangeMarker: Event<ITextModel>;

View File

@@ -28,7 +28,7 @@ export interface ILanguageSelection extends IDisposable {
}
export interface IModeService {
_serviceBrand: any;
_serviceBrand: undefined;
onDidCreateMode: Event<IMode>;

View File

@@ -40,7 +40,7 @@ class LanguageSelection extends Disposable implements ILanguageSelection {
}
export class ModeServiceImpl implements IModeService {
public _serviceBrand: any;
public _serviceBrand: undefined;
private readonly _instantiatedModes: { [modeId: string]: IMode; };
private readonly _registry: LanguagesRegistry;

View File

@@ -12,7 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
export const IModelService = createDecorator<IModelService>('modelService');
export interface IModelService {
_serviceBrand: any;
_serviceBrand: undefined;
createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget?: boolean): ITextModel;

View File

@@ -88,7 +88,7 @@ interface IRawConfig {
const DEFAULT_EOL = (platform.isLinux || platform.isMacintosh) ? DefaultEndOfLine.LF : DefaultEndOfLine.CRLF;
export class ModelServiceImpl extends Disposable implements IModelService {
public _serviceBrand: any;
public _serviceBrand: undefined;
private readonly _configurationService: IConfigurationService;
private readonly _configurationServiceSubscription: IDisposable;

View File

@@ -12,7 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
export const ITextModelService = createDecorator<ITextModelService>('textModelService');
export interface ITextModelService {
_serviceBrand: any;
_serviceBrand: undefined;
/**
* Provided a resource URI, it will return a model reference

View File

@@ -13,7 +13,7 @@ export const ITextResourceConfigurationService = createDecorator<ITextResourceCo
export interface ITextResourceConfigurationService {
_serviceBrand: any;
_serviceBrand: undefined;
/**
* Event that fires when the configuration changes.
@@ -38,7 +38,7 @@ export const ITextResourcePropertiesService = createDecorator<ITextResourcePrope
export interface ITextResourcePropertiesService {
_serviceBrand: any;
_serviceBrand: undefined;
/**
* Returns the End of Line characters for the given resource

View File

@@ -14,7 +14,7 @@ import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/co
export class TextResourceConfigurationService extends Disposable implements ITextResourceConfigurationService {
public _serviceBrand: any;
public _serviceBrand: undefined;
private readonly _onDidChangeConfiguration: Emitter<IConfigurationChangeEvent> = this._register(new Emitter<IConfigurationChangeEvent>());
public readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent> = this._onDidChangeConfiguration.event;

View File

@@ -332,34 +332,13 @@ export enum CursorChangeReason {
Redo = 6
}
export enum RenderMinimap {
None = 0,
Small = 1,
Large = 2,
SmallBlocks = 3,
LargeBlocks = 4
}
/**
* Describes how to indent wrapped lines.
*/
export enum WrappingIndent {
export enum AccessibilitySupport {
/**
* No indentation => wrapped lines begin at column 1.
* This should be the browser case where it is not known if a screen reader is attached or no.
*/
None = 0,
/**
* Same => wrapped lines get the same indentation as the parent.
*/
Same = 1,
/**
* Indent => wrapped lines get +1 indentation toward the parent.
*/
Indent = 2,
/**
* DeepIndent => wrapped lines get +2 indentation toward the parent.
*/
DeepIndent = 3
Unknown = 0,
Disabled = 1,
Enabled = 2
}
/**
@@ -422,6 +401,14 @@ export enum TextEditorCursorStyle {
UnderlineThin = 6
}
export enum RenderMinimap {
None = 0,
Small = 1,
Large = 2,
SmallBlocks = 3,
LargeBlocks = 4
}
export enum RenderLineNumbersType {
Off = 0,
On = 1,
@@ -430,6 +417,28 @@ export enum RenderLineNumbersType {
Custom = 4
}
/**
* Describes how to indent wrapped lines.
*/
export enum WrappingIndent {
/**
* No indentation => wrapped lines begin at column 1.
*/
None = 0,
/**
* Same => wrapped lines get the same indentation as the parent.
*/
Same = 1,
/**
* Indent => wrapped lines get +1 indentation toward the parent.
*/
Indent = 2,
/**
* DeepIndent => wrapped lines get +2 indentation toward the parent.
*/
DeepIndent = 3
}
/**
* A positioning preference for rendering content widgets.
*/

View File

@@ -6,7 +6,7 @@
import * as errors from 'vs/base/common/errors';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { ScrollEvent } from 'vs/base/common/scrollable';
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { ScrollType } from 'vs/editor/common/editorCommon';
@@ -34,32 +34,14 @@ export class ViewConfigurationChangedEvent {
public readonly type = ViewEventType.ViewConfigurationChanged;
public readonly canUseLayerHinting: boolean;
public readonly pixelRatio: boolean;
public readonly editorClassName: boolean;
public readonly lineHeight: boolean;
public readonly readOnly: boolean;
public readonly accessibilitySupport: boolean;
public readonly emptySelectionClipboard: boolean;
public readonly copyWithSyntaxHighlighting: boolean;
public readonly layoutInfo: boolean;
public readonly fontInfo: boolean;
public readonly viewInfo: boolean;
public readonly wrappingInfo: boolean;
public readonly _source: ConfigurationChangedEvent;
constructor(source: IConfigurationChangedEvent) {
this.canUseLayerHinting = source.canUseLayerHinting;
this.pixelRatio = source.pixelRatio;
this.editorClassName = source.editorClassName;
this.lineHeight = source.lineHeight;
this.readOnly = source.readOnly;
this.accessibilitySupport = source.accessibilitySupport;
this.emptySelectionClipboard = source.emptySelectionClipboard;
this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting;
this.layoutInfo = source.layoutInfo;
this.fontInfo = source.fontInfo;
this.viewInfo = source.viewInfo;
this.wrappingInfo = source.wrappingInfo;
constructor(source: ConfigurationChangedEvent) {
this._source = source;
}
public hasChanged(id: EditorOption): boolean {
return this._source.hasChanged(id);
}
}
@@ -198,7 +180,13 @@ export class ViewRevealRangeRequestEvent {
public readonly scrollType: ScrollType;
constructor(range: Range, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: ScrollType) {
/**
* Source of the call that caused the event.
*/
readonly source: string;
constructor(source: string, range: Range, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: ScrollType) {
this.source = source;
this.range = range;
this.verticalType = verticalType;
this.revealHorizontal = revealHorizontal;

View File

@@ -6,7 +6,7 @@
import { Event } from 'vs/base/common/event';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { IScrollDimensions, IScrollPosition, ScrollEvent, Scrollable, ScrollbarVisibility } from 'vs/base/common/scrollable';
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { LinesLayout } from 'vs/editor/common/viewLayout/linesLayout';
import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
@@ -27,14 +27,17 @@ export class ViewLayout extends Disposable implements IViewLayout {
super();
this._configuration = configuration;
this._linesLayout = new LinesLayout(lineCount, this._configuration.editor.lineHeight);
const options = this._configuration.options;
const layoutInfo = options.get(EditorOption.layoutInfo);
this._linesLayout = new LinesLayout(lineCount, options.get(EditorOption.lineHeight));
this.scrollable = this._register(new Scrollable(0, scheduleAtNextAnimationFrame));
this._configureSmoothScrollDuration();
this.scrollable.setScrollDimensions({
width: configuration.editor.layoutInfo.contentWidth,
height: configuration.editor.layoutInfo.contentHeight
width: layoutInfo.contentWidth,
height: layoutInfo.contentHeight
});
this.onDidScroll = this.scrollable.onScroll;
@@ -50,22 +53,24 @@ export class ViewLayout extends Disposable implements IViewLayout {
}
private _configureSmoothScrollDuration(): void {
this.scrollable.setSmoothScrollDuration(this._configuration.editor.viewInfo.smoothScrolling ? SMOOTH_SCROLLING_TIME : 0);
this.scrollable.setSmoothScrollDuration(this._configuration.options.get(EditorOption.smoothScrolling) ? SMOOTH_SCROLLING_TIME : 0);
}
// ---- begin view event handlers
public onConfigurationChanged(e: IConfigurationChangedEvent): void {
if (e.lineHeight) {
this._linesLayout.setLineHeight(this._configuration.editor.lineHeight);
public onConfigurationChanged(e: ConfigurationChangedEvent): void {
const options = this._configuration.options;
if (e.hasChanged(EditorOption.lineHeight)) {
this._linesLayout.setLineHeight(options.get(EditorOption.lineHeight));
}
if (e.layoutInfo) {
if (e.hasChanged(EditorOption.layoutInfo)) {
const layoutInfo = options.get(EditorOption.layoutInfo);
this.scrollable.setScrollDimensions({
width: this._configuration.editor.layoutInfo.contentWidth,
height: this._configuration.editor.layoutInfo.contentHeight
width: layoutInfo.contentWidth,
height: layoutInfo.contentHeight
});
}
if (e.viewInfo) {
if (e.hasChanged(EditorOption.smoothScrolling)) {
this._configureSmoothScrollDuration();
}
this._updateHeight();
@@ -83,7 +88,9 @@ export class ViewLayout extends Disposable implements IViewLayout {
// ---- end view event handlers
private _getHorizontalScrollbarHeight(scrollDimensions: IScrollDimensions): number {
if (this._configuration.editor.viewInfo.scrollbar.horizontal === ScrollbarVisibility.Hidden) {
const options = this._configuration.options;
const scrollbar = options.get(EditorOption.scrollbar);
if (scrollbar.horizontal === ScrollbarVisibility.Hidden) {
// horizontal scrollbar not visible
return 0;
}
@@ -91,15 +98,16 @@ export class ViewLayout extends Disposable implements IViewLayout {
// horizontal scrollbar not visible
return 0;
}
return this._configuration.editor.viewInfo.scrollbar.horizontalScrollbarSize;
return scrollbar.horizontalScrollbarSize;
}
private _getTotalHeight(): number {
const options = this._configuration.options;
const scrollDimensions = this.scrollable.getScrollDimensions();
let result = this._linesLayout.getLinesTotalHeight();
if (this._configuration.editor.viewInfo.scrollBeyondLastLine) {
result += scrollDimensions.height - this._configuration.editor.lineHeight;
if (options.get(EditorOption.scrollBeyondLastLine)) {
result += scrollDimensions.height - options.get(EditorOption.lineHeight);
} else {
result += this._getHorizontalScrollbarHeight(scrollDimensions);
}
@@ -138,9 +146,11 @@ export class ViewLayout extends Disposable implements IViewLayout {
}
private _computeScrollWidth(maxLineWidth: number, viewportWidth: number): number {
let isViewportWrapping = this._configuration.editor.wrappingInfo.isViewportWrapping;
const options = this._configuration.options;
const wrappingInfo = options.get(EditorOption.wrappingInfo);
let isViewportWrapping = wrappingInfo.isViewportWrapping;
if (!isViewportWrapping) {
const extraHorizontalSpace = this._configuration.editor.viewInfo.scrollBeyondLastColumn * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
const extraHorizontalSpace = options.get(EditorOption.scrollBeyondLastColumn) * options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
const whitespaceMinWidth = this._linesLayout.getWhitespaceMinWidth();
return Math.max(maxLineWidth + extraHorizontalSpace, viewportWidth, whitespaceMinWidth);
}

View File

@@ -10,6 +10,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import { IModelDecoration, ITextModel } from 'vs/editor/common/model';
import { IViewModelLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection';
import { ICoordinatesConverter, InlineDecoration, InlineDecorationType, ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
export interface IDecorationsViewportData {
/**
@@ -103,7 +104,7 @@ export class ViewModelDecorations implements IDisposable {
}
private _getDecorationsViewportData(viewportRange: Range): IDecorationsViewportData {
const modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, this.configuration.editor.readOnly);
const modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, this.configuration.options.get(EditorOption.readOnly));
const startLineNumber = viewportRange.startLineNumber;
const endLineNumber = viewportRange.endLineNumber;

View File

@@ -6,7 +6,7 @@
import { Color } from 'vs/base/common/color';
import { IDisposable } from 'vs/base/common/lifecycle';
import * as strings from 'vs/base/common/strings';
import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
import { ConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions';
import { IPosition, Position } from 'vs/editor/common/core/position';
import { IRange, Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
@@ -59,21 +59,27 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this.lines = new IdentityLinesCollection(this.model);
} else {
const conf = this.configuration.editor;
const options = this.configuration.options;
const wrappingInfo = options.get(EditorOption.wrappingInfo);
const fontInfo = options.get(EditorOption.fontInfo);
const wordWrapBreakAfterCharacters = options.get(EditorOption.wordWrapBreakAfterCharacters);
const wordWrapBreakBeforeCharacters = options.get(EditorOption.wordWrapBreakBeforeCharacters);
const wordWrapBreakObtrusiveCharacters = options.get(EditorOption.wordWrapBreakObtrusiveCharacters);
const wrappingIndent = options.get(EditorOption.wrappingIndent);
let hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory(
conf.wrappingInfo.wordWrapBreakBeforeCharacters,
conf.wrappingInfo.wordWrapBreakAfterCharacters,
conf.wrappingInfo.wordWrapBreakObtrusiveCharacters
wordWrapBreakBeforeCharacters,
wordWrapBreakAfterCharacters,
wordWrapBreakObtrusiveCharacters
);
this.lines = new SplitLinesCollection(
this.model,
hardWrappingLineMapperFactory,
this.model.getOptions().tabSize,
conf.wrappingInfo.wrappingColumn,
conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth,
conf.wrappingInfo.wrappingIndent
wrappingInfo.wrappingColumn,
fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth,
wrappingIndent
);
}
@@ -136,7 +142,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this.hasFocus = hasFocus;
}
private _onConfigurationChanged(eventsCollector: viewEvents.ViewEventsCollector, e: IConfigurationChangedEvent): void {
private _onConfigurationChanged(eventsCollector: viewEvents.ViewEventsCollector, e: ConfigurationChangedEvent): void {
// We might need to restore the current centered view range, so save it (if available)
let previousViewportStartModelPosition: Position | null = null;
@@ -146,9 +152,12 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
}
let restorePreviousViewportStart = false;
const conf = this.configuration.editor;
const options = this.configuration.options;
const wrappingInfo = options.get(EditorOption.wrappingInfo);
const fontInfo = options.get(EditorOption.fontInfo);
const wrappingIndent = options.get(EditorOption.wrappingIndent);
if (this.lines.setWrappingSettings(conf.wrappingInfo.wrappingIndent, conf.wrappingInfo.wrappingColumn, conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth)) {
if (this.lines.setWrappingSettings(wrappingIndent, wrappingInfo.wrappingColumn, fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth)) {
eventsCollector.emit(new viewEvents.ViewFlushedEvent());
eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
@@ -161,7 +170,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
}
}
if (e.readOnly) {
if (e.hasChanged(EditorOption.readOnly)) {
// Must read again all decorations due to readOnly filtering
this.decorations.reset();
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
@@ -552,7 +561,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
}
public getAllOverviewRulerDecorations(theme: ITheme): IOverviewRulerDecorations {
return this.lines.getAllOverviewRulerDecorations(this.editorId, this.configuration.editor.readOnly, theme);
return this.lines.getAllOverviewRulerDecorations(this.editorId, this.configuration.options.get(EditorOption.readOnly), theme);
}
public invalidateOverviewRulerColorCache(): void {
@@ -666,7 +675,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
range = new Range(lineNumber, this.model.getLineMinColumn(lineNumber), lineNumber, this.model.getLineMaxColumn(lineNumber));
}
const fontInfo = this.configuration.editor.fontInfo;
const fontInfo = this.configuration.options.get(EditorOption.fontInfo);
const colorMap = this._getColorMap();
const fontFamily = fontInfo.fontFamily === EDITOR_FONT_DEFAULTS.fontFamily ? fontInfo.fontFamily : `'${fontInfo.fontFamily}', ${EDITOR_FONT_DEFAULTS.fontFamily}`;