diff --git a/build/monaco/monaco.d.ts.recipe b/build/monaco/monaco.d.ts.recipe index e9785e6a0ea..ea1aa360a41 100644 --- a/build/monaco/monaco.d.ts.recipe +++ b/build/monaco/monaco.d.ts.recipe @@ -24,7 +24,7 @@ declare module monaco { */ export class Emitter { constructor(); - event: Event; + readonly event: Event; fire(event?: T): void; dispose(): void; } @@ -43,8 +43,7 @@ declare module monaco { #include(vs/base/common/htmlContent): MarkedString #include(vs/base/browser/keyboardEvent): IKeyboardEvent #include(vs/base/browser/mouseEvent): IMouseEvent -#include(vs/editor/common/editorCommon): IScrollEvent -#include(vs/editor/common/editorCommon): IPosition, IRange, ISelection +#include(vs/editor/common/editorCommon): IScrollEvent, IPosition, IRange, ISelection #include(vs/editor/common/core/position): Position #include(vs/editor/common/core/range): Range #include(vs/editor/common/core/selection): Selection, SelectionDirection @@ -63,7 +62,6 @@ export interface ICommandHandler { #include(vs/platform/markers/common/markers): IMarkerData #include(vs/editor/browser/standalone/colorizer): IColorizerOptions, IColorizerElementOptions #include(vs/base/common/scrollable): ScrollbarVisibility -#include(vs/base/common/actions): IAction #includeAll(vs/editor/common/editorCommon;IMode=>languages.IMode): IPosition, IRange, ISelection, SelectionDirection, IScrollEvent #includeAll(vs/editor/browser/editorBrowser;editorCommon.=>): } diff --git a/src/vs/base/browser/keyboardEvent.ts b/src/vs/base/browser/keyboardEvent.ts index 88a8b336552..1a8c4169e97 100644 --- a/src/vs/base/browser/keyboardEvent.ts +++ b/src/vs/base/browser/keyboardEvent.ts @@ -166,14 +166,14 @@ export function setExtractKeyCode(newExtractKeyCode: (e: KeyboardEvent) => KeyCo } export interface IKeyboardEvent { - browserEvent: KeyboardEvent; - target: HTMLElement; + readonly browserEvent: KeyboardEvent; + readonly target: HTMLElement; - ctrlKey: boolean; - shiftKey: boolean; - altKey: boolean; - metaKey: boolean; - keyCode: KeyCode; + readonly ctrlKey: boolean; + readonly shiftKey: boolean; + readonly altKey: boolean; + readonly metaKey: boolean; + readonly keyCode: KeyCode; asKeybinding(): number; equals(keybinding: number): boolean; @@ -189,14 +189,14 @@ const metaKeyMod = (platform.isMacintosh ? KeyMod.CtrlCmd : KeyMod.WinCtrl); export class StandardKeyboardEvent implements IKeyboardEvent { - public browserEvent: KeyboardEvent; - public target: HTMLElement; + public readonly browserEvent: KeyboardEvent; + public readonly target: HTMLElement; - public ctrlKey: boolean; - public shiftKey: boolean; - public altKey: boolean; - public metaKey: boolean; - public keyCode: KeyCode; + public readonly ctrlKey: boolean; + public readonly shiftKey: boolean; + public readonly altKey: boolean; + public readonly metaKey: boolean; + public readonly keyCode: KeyCode; private _asKeybinding: number; diff --git a/src/vs/base/browser/mouseEvent.ts b/src/vs/base/browser/mouseEvent.ts index 12c5a02b348..1495690531f 100644 --- a/src/vs/base/browser/mouseEvent.ts +++ b/src/vs/base/browser/mouseEvent.ts @@ -9,19 +9,19 @@ import * as browser from 'vs/base/browser/browser'; import { IframeUtils } from 'vs/base/browser/iframe'; export interface IMouseEvent { - browserEvent: MouseEvent; - leftButton: boolean; - middleButton: boolean; - rightButton: boolean; - target: HTMLElement; - detail: number; - posx: number; - posy: number; - ctrlKey: boolean; - shiftKey: boolean; - altKey: boolean; - metaKey: boolean; - timestamp: number; + readonly browserEvent: MouseEvent; + readonly leftButton: boolean; + readonly middleButton: boolean; + readonly rightButton: boolean; + readonly target: HTMLElement; + readonly detail: number; + readonly posx: number; + readonly posy: number; + readonly ctrlKey: boolean; + readonly shiftKey: boolean; + readonly altKey: boolean; + readonly metaKey: boolean; + readonly timestamp: number; preventDefault(): void; stopPropagation(): void; @@ -29,20 +29,20 @@ export interface IMouseEvent { export class StandardMouseEvent implements IMouseEvent { - public browserEvent: MouseEvent; + public readonly browserEvent: MouseEvent; - public leftButton: boolean; - public middleButton: boolean; - public rightButton: boolean; - public target: HTMLElement; + public readonly leftButton: boolean; + public readonly middleButton: boolean; + public readonly rightButton: boolean; + public readonly target: HTMLElement; public detail: number; - public posx: number; - public posy: number; - public ctrlKey: boolean; - public shiftKey: boolean; - public altKey: boolean; - public metaKey: boolean; - public timestamp: number; + public readonly posx: number; + public readonly posy: number; + public readonly ctrlKey: boolean; + public readonly shiftKey: boolean; + public readonly altKey: boolean; + public readonly metaKey: boolean; + public readonly timestamp: number; constructor(e: MouseEvent) { this.timestamp = Date.now(); @@ -105,7 +105,7 @@ export interface IDataTransfer { export class DragMouseEvent extends StandardMouseEvent { - public dataTransfer: IDataTransfer; + public readonly dataTransfer: IDataTransfer; constructor(e: MouseEvent) { super(e); @@ -136,10 +136,10 @@ interface IGeckoMouseWheelEvent { export class StandardMouseWheelEvent { - public browserEvent: MouseWheelEvent; - public deltaY: number; - public deltaX: number; - public target: Node; + public readonly browserEvent: MouseWheelEvent; + public readonly deltaY: number; + public readonly deltaX: number; + public readonly target: Node; constructor(e: MouseWheelEvent, deltaX: number = 0, deltaY: number = 0) { diff --git a/src/vs/base/common/cancellation.ts b/src/vs/base/common/cancellation.ts index 3afea4f3962..c1cace585a7 100644 --- a/src/vs/base/common/cancellation.ts +++ b/src/vs/base/common/cancellation.ts @@ -8,12 +8,12 @@ import Event, { Emitter } from 'vs/base/common/event'; export interface CancellationToken { - isCancellationRequested: boolean; + readonly isCancellationRequested: boolean; /** * An event emitted when cancellation is requested * @event */ - onCancellationRequested: Event; + readonly onCancellationRequested: Event; } const shortcutEvent: Event = Object.freeze(function (callback, context?) { diff --git a/src/vs/base/common/htmlContent.ts b/src/vs/base/common/htmlContent.ts index 05ac455a51c..57f8a8dc960 100644 --- a/src/vs/base/common/htmlContent.ts +++ b/src/vs/base/common/htmlContent.ts @@ -10,7 +10,7 @@ * or a code-block that provides a language and a code snippet. Note that * markdown strings will be sanitized - that means html will be escaped. */ -export type MarkedString = string | { language: string; value: string }; +export type MarkedString = string | { readonly language: string; readonly value: string }; export interface IHTMLContentElementCode { language: string; diff --git a/src/vs/base/test/common/cancellation.test.ts b/src/vs/base/test/common/cancellation.test.ts index 760079da5b7..8ad8f9df746 100644 --- a/src/vs/base/test/common/cancellation.test.ts +++ b/src/vs/base/test/common/cancellation.test.ts @@ -14,26 +14,6 @@ suite('CancellationToken', function () { assert.equal(typeof CancellationToken.None.onCancellationRequested, 'function'); }); - test('defaults cannot be messed with', function () { - - assert.throws(function () { - CancellationToken.Cancelled.isCancellationRequested = false; - }); - - assert.throws(function () { - CancellationToken.Cancelled.onCancellationRequested = null; - }); - - assert.throws(function () { - CancellationToken.None.isCancellationRequested = false; - }); - - assert.throws(function () { - CancellationToken.None.onCancellationRequested = null; - }); - }); - - test('cancel before token', function (done) { var source = new CancellationTokenSource(); diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts index bfafc275e52..f53b2df12f4 100644 --- a/src/vs/editor/browser/config/configuration.ts +++ b/src/vs/editor/browser/config/configuration.ts @@ -106,10 +106,16 @@ class CSSBasedConfiguration extends Disposable { if (readConfig.typicalHalfwidthCharacterWidth <= 2 || readConfig.typicalFullwidthCharacterWidth <= 2 || readConfig.spaceWidth <= 2 || readConfig.maxDigitWidth <= 2) { // Hey, it's Bug 14341 ... we couldn't read - readConfig.typicalHalfwidthCharacterWidth = Math.max(readConfig.typicalHalfwidthCharacterWidth, 5); - readConfig.typicalFullwidthCharacterWidth = Math.max(readConfig.typicalFullwidthCharacterWidth, 5); - readConfig.spaceWidth = Math.max(readConfig.spaceWidth, 5); - readConfig.maxDigitWidth = Math.max(readConfig.maxDigitWidth, 5); + readConfig = new FontInfo({ + fontFamily: readConfig.fontFamily, + fontWeight: readConfig.fontWeight, + fontSize: readConfig.fontSize, + lineHeight: readConfig.lineHeight, + typicalHalfwidthCharacterWidth: Math.max(readConfig.typicalHalfwidthCharacterWidth, 5), + typicalFullwidthCharacterWidth: Math.max(readConfig.typicalFullwidthCharacterWidth, 5), + spaceWidth: Math.max(readConfig.spaceWidth, 5), + maxDigitWidth: Math.max(readConfig.maxDigitWidth, 5), + }); this._installChangeMonitor(); } diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index 1131cbe8e36..4e6aaf9f7b8 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -352,34 +352,34 @@ export interface IMouseTarget { /** * The target element */ - element: Element; + readonly element: Element; /** * The target type */ - type: editorCommon.MouseTargetType; + readonly type: editorCommon.MouseTargetType; /** * The 'approximate' editor position */ - position: Position; + readonly position: Position; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ - mouseColumn: number; + readonly mouseColumn: number; /** * The 'approximate' editor range */ - range: Range; + readonly range: Range; /** * Some extra detail. */ - detail: any; + readonly detail: any; } /** * A mouse event originating from the editor. */ export interface IEditorMouseEvent { - event: IMouseEvent; - target: IMouseTarget; + readonly event: IMouseEvent; + readonly target: IMouseTarget; } /** diff --git a/src/vs/editor/browser/standalone/standaloneEditor.ts b/src/vs/editor/browser/standalone/standaloneEditor.ts index a0f19125309..6b2bb55b2f8 100644 --- a/src/vs/editor/browser/standalone/standaloneEditor.ts +++ b/src/vs/editor/browser/standalone/standaloneEditor.ts @@ -110,9 +110,9 @@ export interface IDiffNavigator { } export interface IDiffNavigatorOptions { - followsCaret?: boolean; - ignoreCharChanges?: boolean; - alwaysRevealFirst?: boolean; + readonly followsCaret?: boolean; + readonly ignoreCharChanges?: boolean; + readonly alwaysRevealFirst?: boolean; } export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: IDiffNavigatorOptions): IDiffNavigator { @@ -192,7 +192,7 @@ export function onWillDisposeModel(listener: (model: IModel) => void): IDisposab * Emitted when a different language is set to a model. * @event */ -export function onDidChangeModelLanguage(listener: (e: { model: IModel; oldLanguage: string; }) => void): IDisposable { +export function onDidChangeModelLanguage(listener: (e: { readonly model: IModel; readonly oldLanguage: string; }) => void): IDisposable { return StaticServices.modelService.get().onModelModeChanged((e) => { listener({ model: e.model, @@ -290,6 +290,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { EditorLayoutInfo: editorCommon.EditorLayoutInfo, BareFontInfo: editorCommon.BareFontInfo, FontInfo: editorCommon.FontInfo, + TextModelResolvedOptions: editorCommon.TextModelResolvedOptions, // vars EditorType: editorCommon.EditorType, diff --git a/src/vs/editor/browser/standalone/standaloneLanguages.ts b/src/vs/editor/browser/standalone/standaloneLanguages.ts index b70a348bb9f..01dad87890a 100644 --- a/src/vs/editor/browser/standalone/standaloneLanguages.ts +++ b/src/vs/editor/browser/standalone/standaloneLanguages.ts @@ -222,7 +222,7 @@ export interface CodeActionContext { * * @readonly */ - markers: IMarkerData[]; + readonly markers: IMarkerData[]; } /** diff --git a/src/vs/editor/browser/view/viewController.ts b/src/vs/editor/browser/view/viewController.ts index 3a9b95b0a1a..934c755d5f1 100644 --- a/src/vs/editor/browser/view/viewController.ts +++ b/src/vs/editor/browser/view/viewController.ts @@ -8,7 +8,7 @@ import { EventEmitter } from 'vs/base/common/eventEmitter'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { Position } from 'vs/editor/common/core/position'; import * as editorCommon from 'vs/editor/common/editorCommon'; -import { IEditorMouseEvent, IViewController, IMouseDispatchData } from 'vs/editor/browser/editorBrowser'; +import { IEditorMouseEvent, IMouseTarget, IViewController, IMouseDispatchData } from 'vs/editor/browser/editorBrowser'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { Range } from 'vs/editor/common/core/range'; @@ -251,15 +251,25 @@ export class ViewController implements IViewController { return this.viewModel.convertViewRangeToModelRange(viewRange); } - private convertViewToModelMouseEvent(e: IEditorMouseEvent): void { + private _convertViewToModelMouseTarget(target: IMouseTarget): IMouseTarget { + return { + element: target.element, + type: target.type, + position: target.position ? this.convertViewToModelPosition(target.position) : null, + mouseColumn: target.mouseColumn, + range: target.range ? this.convertViewToModelRange(target.range) : null, + detail: target.detail + }; + } + + private _convertViewToModelMouseEvent(e: IEditorMouseEvent): IEditorMouseEvent { if (e.target) { - if (e.target.position) { - e.target.position = this.convertViewToModelPosition(e.target.position); - } - if (e.target.range) { - e.target.range = this.convertViewToModelRange(e.target.range); - } + return { + event: e.event, + target: this._convertViewToModelMouseTarget(e.target) + }; } + return e; } public emitKeyDown(e: IKeyboardEvent): void { @@ -271,28 +281,23 @@ export class ViewController implements IViewController { } public emitContextMenu(e: IEditorMouseEvent): void { - this.convertViewToModelMouseEvent(e); - this.outgoingEventBus.emit(editorCommon.EventType.ContextMenu, e); + this.outgoingEventBus.emit(editorCommon.EventType.ContextMenu, this._convertViewToModelMouseEvent(e)); } public emitMouseMove(e: IEditorMouseEvent): void { - this.convertViewToModelMouseEvent(e); - this.outgoingEventBus.emit(editorCommon.EventType.MouseMove, e); + this.outgoingEventBus.emit(editorCommon.EventType.MouseMove, this._convertViewToModelMouseEvent(e)); } public emitMouseLeave(e: IEditorMouseEvent): void { - this.convertViewToModelMouseEvent(e); - this.outgoingEventBus.emit(editorCommon.EventType.MouseLeave, e); + this.outgoingEventBus.emit(editorCommon.EventType.MouseLeave, this._convertViewToModelMouseEvent(e)); } public emitMouseUp(e: IEditorMouseEvent): void { - this.convertViewToModelMouseEvent(e); - this.outgoingEventBus.emit(editorCommon.EventType.MouseUp, e); + this.outgoingEventBus.emit(editorCommon.EventType.MouseUp, this._convertViewToModelMouseEvent(e)); } public emitMouseDown(e: IEditorMouseEvent): void { - this.convertViewToModelMouseEvent(e); - this.outgoingEventBus.emit(editorCommon.EventType.MouseDown, e); + this.outgoingEventBus.emit(editorCommon.EventType.MouseDown, this._convertViewToModelMouseEvent(e)); } } \ No newline at end of file diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 26512c595c2..3b75519152f 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -9,7 +9,7 @@ import { MarkedString } from 'vs/base/common/htmlContent'; import * as types from 'vs/base/common/types'; import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; -import { ServicesAccessor, IConstructorSignature1, IConstructorSignature2 } from 'vs/platform/instantiation/common/instantiation'; +import { ServicesAccessor, IConstructorSignature1 } from 'vs/platform/instantiation/common/instantiation'; import { ILineContext, IMode } from 'vs/editor/common/modes'; import { LineTokens } from 'vs/editor/common/core/lineTokens'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; @@ -38,11 +38,11 @@ export interface IPosition { /** * line number (starts at 1) */ - lineNumber: number; + readonly lineNumber: number; /** * column (the first character in a line is between column 1 and column 2) */ - column: number; + readonly column: number; } /** @@ -52,19 +52,19 @@ export interface IRange { /** * Line number on which the range starts (starts at 1). */ - startLineNumber: number; + readonly startLineNumber: number; /** * Column on which the range starts in line `startLineNumber` (starts at 1). */ - startColumn: number; + readonly startColumn: number; /** * Line number on which the range ends. */ - endLineNumber: number; + readonly endLineNumber: number; /** * Column on which the range ends in line `endLineNumber`. */ - endColumn: number; + readonly endColumn: number; } /** @@ -75,19 +75,19 @@ export interface ISelection { /** * The line number on which the selection has started. */ - selectionStartLineNumber: number; + readonly selectionStartLineNumber: number; /** * The column on `selectionStartLineNumber` where the selection has started. */ - selectionStartColumn: number; + readonly selectionStartColumn: number; /** * The line number on which the selection has ended. */ - positionLineNumber: number; + readonly positionLineNumber: number; /** * The column on `positionLineNumber` where the selection has ended. */ - positionColumn: number; + readonly positionColumn: number; } /** @@ -509,20 +509,20 @@ export interface IDiffEditorOptions extends IEditorOptions { } export class InternalEditorScrollbarOptions { - _internalEditorScrollbarOptionsBrand: void; + readonly _internalEditorScrollbarOptionsBrand: void; - arrowSize: number; - vertical: ScrollbarVisibility; - horizontal: ScrollbarVisibility; - useShadows: boolean; - verticalHasArrows: boolean; - horizontalHasArrows: boolean; - handleMouseWheel: boolean; - horizontalScrollbarSize: number; - horizontalSliderSize: number; - verticalScrollbarSize: number; - verticalSliderSize: number; - mouseWheelScrollSensitivity: number; + readonly arrowSize: number; + readonly vertical: ScrollbarVisibility; + readonly horizontal: ScrollbarVisibility; + readonly useShadows: boolean; + readonly verticalHasArrows: boolean; + readonly horizontalHasArrows: boolean; + readonly handleMouseWheel: boolean; + readonly horizontalScrollbarSize: number; + readonly horizontalSliderSize: number; + readonly verticalScrollbarSize: number; + readonly verticalSliderSize: number; + readonly mouseWheelScrollSensitivity: number; /** * @internal @@ -584,14 +584,14 @@ export class InternalEditorScrollbarOptions { } export class EditorWrappingInfo { - _editorWrappingInfoBrand: void; + readonly _editorWrappingInfoBrand: void; - isViewportWrapping: boolean; - wrappingColumn: number; - wrappingIndent: WrappingIndent; - wordWrapBreakBeforeCharacters: string; - wordWrapBreakAfterCharacters: string; - wordWrapBreakObtrusiveCharacters: string; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; + readonly wrappingIndent: WrappingIndent; + readonly wordWrapBreakBeforeCharacters: string; + readonly wordWrapBreakAfterCharacters: string; + readonly wordWrapBreakObtrusiveCharacters: string; /** * @internal @@ -635,33 +635,33 @@ export class EditorWrappingInfo { } export class InternalEditorViewOptions { - _internalEditorViewOptionsBrand: void; + readonly _internalEditorViewOptionsBrand: void; - theme: string; - canUseTranslate3d: boolean; - experimentalScreenReader: boolean; - rulers: number[]; - ariaLabel: string; - renderLineNumbers: boolean; - renderCustomLineNumbers: (lineNumber: number) => string; - renderRelativeLineNumbers: boolean; - selectOnLineNumbers: boolean; - glyphMargin: boolean; - revealHorizontalRightPadding: number; - roundedSelection: boolean; - overviewRulerLanes: number; - cursorBlinking: TextEditorCursorBlinkingStyle; - mouseWheelZoom: boolean; - cursorStyle: TextEditorCursorStyle; - hideCursorInOverviewRuler: boolean; - scrollBeyondLastLine: boolean; - editorClassName: string; - stopRenderingLineAfter: number; - renderWhitespace: 'none' | 'boundary' | 'all'; - renderControlCharacters: boolean; - renderIndentGuides: boolean; - renderLineHighlight: boolean; - scrollbar: InternalEditorScrollbarOptions; + readonly theme: string; + readonly canUseTranslate3d: boolean; + readonly experimentalScreenReader: boolean; + readonly rulers: number[]; + readonly ariaLabel: string; + readonly renderLineNumbers: boolean; + readonly renderCustomLineNumbers: (lineNumber: number) => string; + readonly renderRelativeLineNumbers: boolean; + readonly selectOnLineNumbers: boolean; + readonly glyphMargin: boolean; + readonly revealHorizontalRightPadding: number; + readonly roundedSelection: boolean; + readonly overviewRulerLanes: number; + readonly cursorBlinking: TextEditorCursorBlinkingStyle; + readonly mouseWheelZoom: boolean; + readonly cursorStyle: TextEditorCursorStyle; + readonly hideCursorInOverviewRuler: boolean; + readonly scrollBeyondLastLine: boolean; + readonly editorClassName: string; + readonly stopRenderingLineAfter: number; + readonly renderWhitespace: 'none' | 'boundary' | 'all'; + readonly renderControlCharacters: boolean; + readonly renderIndentGuides: boolean; + readonly renderLineHighlight: boolean; + readonly scrollbar: InternalEditorScrollbarOptions; /** * @internal @@ -823,52 +823,52 @@ export class InternalEditorViewOptions { } export interface IViewConfigurationChangedEvent { - theme: boolean; - canUseTranslate3d: boolean; - experimentalScreenReader: boolean; - rulers: boolean; - ariaLabel: boolean; - renderLineNumbers: boolean; - renderCustomLineNumbers: boolean; - renderRelativeLineNumbers: boolean; - selectOnLineNumbers: boolean; - glyphMargin: boolean; - revealHorizontalRightPadding: boolean; - roundedSelection: boolean; - overviewRulerLanes: boolean; - cursorBlinking: boolean; - mouseWheelZoom: boolean; - cursorStyle: boolean; - hideCursorInOverviewRuler: boolean; - scrollBeyondLastLine: boolean; - editorClassName: boolean; - stopRenderingLineAfter: boolean; - renderWhitespace: boolean; - renderControlCharacters: boolean; - renderIndentGuides: boolean; - renderLineHighlight: boolean; - scrollbar: boolean; + readonly theme: boolean; + readonly canUseTranslate3d: boolean; + readonly experimentalScreenReader: boolean; + readonly rulers: boolean; + readonly ariaLabel: boolean; + readonly renderLineNumbers: boolean; + readonly renderCustomLineNumbers: boolean; + readonly renderRelativeLineNumbers: boolean; + readonly selectOnLineNumbers: boolean; + readonly glyphMargin: boolean; + readonly revealHorizontalRightPadding: boolean; + readonly roundedSelection: boolean; + readonly overviewRulerLanes: boolean; + readonly cursorBlinking: boolean; + readonly mouseWheelZoom: boolean; + readonly cursorStyle: boolean; + readonly hideCursorInOverviewRuler: boolean; + readonly scrollBeyondLastLine: boolean; + readonly editorClassName: boolean; + readonly stopRenderingLineAfter: boolean; + readonly renderWhitespace: boolean; + readonly renderControlCharacters: boolean; + readonly renderIndentGuides: boolean; + readonly renderLineHighlight: boolean; + readonly scrollbar: boolean; } export class EditorContribOptions { - selectionClipboard: boolean; - hover: boolean; - contextmenu: boolean; - quickSuggestions: boolean; - quickSuggestionsDelay: number; - parameterHints: boolean; - iconsInSuggestions: boolean; - formatOnType: boolean; - suggestOnTriggerCharacters: boolean; - acceptSuggestionOnEnter: boolean; - snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; - tabCompletion: boolean; - wordBasedSuggestions: boolean; - suggestFontSize: number; - suggestLineHeight: number; - selectionHighlight: boolean; - codeLens: boolean; - folding: boolean; + readonly selectionClipboard: boolean; + readonly hover: boolean; + readonly contextmenu: boolean; + readonly quickSuggestions: boolean; + readonly quickSuggestionsDelay: number; + readonly parameterHints: boolean; + readonly iconsInSuggestions: boolean; + readonly formatOnType: boolean; + readonly suggestOnTriggerCharacters: boolean; + readonly acceptSuggestionOnEnter: boolean; + readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; + readonly tabCompletion: boolean; + readonly wordBasedSuggestions: boolean; + readonly suggestFontSize: number; + readonly suggestLineHeight: number; + readonly selectionHighlight: boolean; + readonly codeLens: boolean; + readonly folding: boolean; /** * @internal @@ -951,22 +951,22 @@ export class EditorContribOptions { * Internal configuration options (transformed or computed) for the editor. */ export class InternalEditorOptions { - _internalEditorOptionsBrand: void; + readonly _internalEditorOptionsBrand: void; - lineHeight: number; // todo: move to fontInfo + readonly lineHeight: number; // todo: move to fontInfo - readOnly: boolean; + readonly readOnly: boolean; // ---- cursor options - wordSeparators: string; - autoClosingBrackets: boolean; - useTabStops: boolean; - tabFocusMode: boolean; + readonly wordSeparators: string; + readonly autoClosingBrackets: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; // ---- grouped options - layoutInfo: EditorLayoutInfo; - fontInfo: FontInfo; - viewInfo: InternalEditorViewOptions; - wrappingInfo: EditorWrappingInfo; - contribInfo: EditorContribOptions; + readonly layoutInfo: EditorLayoutInfo; + readonly fontInfo: FontInfo; + readonly viewInfo: InternalEditorViewOptions; + readonly wrappingInfo: EditorWrappingInfo; + readonly contribInfo: EditorContribOptions; /** * @internal @@ -1047,17 +1047,17 @@ export class InternalEditorOptions { * An event describing that the configuration of the editor has changed. */ export interface IConfigurationChangedEvent { - lineHeight: boolean; - readOnly: boolean; - wordSeparators: boolean; - autoClosingBrackets: boolean; - useTabStops: boolean; - tabFocusMode: boolean; - layoutInfo: boolean; - fontInfo: boolean; - viewInfo: IViewConfigurationChangedEvent; - wrappingInfo: boolean; - contribInfo: boolean; + readonly lineHeight: boolean; + readonly readOnly: boolean; + readonly wordSeparators: boolean; + readonly autoClosingBrackets: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; + readonly layoutInfo: boolean; + readonly fontInfo: boolean; + readonly viewInfo: IViewConfigurationChangedEvent; + readonly wrappingInfo: boolean; + readonly contribInfo: boolean; } /** @@ -1184,19 +1184,19 @@ export interface IModelDecoration { /** * Identifier for a decoration. */ - id: string; + readonly id: string; /** * Identifier for a decoration's owener. */ - ownerId: number; + readonly ownerId: number; /** * Range that this decoration covers. */ - range: Range; + readonly range: Range; /** * Options associated with this decoration. */ - options: IModelDecorationOptions; + readonly options: IModelDecorationOptions; } /** @@ -1247,15 +1247,15 @@ export interface IWordAtPosition { /** * The word. */ - word: string; + readonly word: string; /** * The column where the word starts. */ - startColumn: number; + readonly startColumn: number; /** * The column where the word ends. */ - endColumn: number; + readonly endColumn: number; } /** @@ -1266,21 +1266,21 @@ export interface IWordRange { /** * The index where the word starts. */ - start: number; + readonly start: number; /** * The index where the word ends. */ - end: number; + readonly end: number; } /** * @internal */ export interface ITokenInfo { - type: string; - lineNumber: number; - startColumn: number; - endColumn: number; + readonly type: string; + readonly lineNumber: number; + readonly startColumn: number; + readonly endColumn: number; } /** @@ -1344,8 +1344,8 @@ export enum EndOfLineSequence { * @internal */ export interface IReadOnlyLineMarker { - id: string; - column: number; + readonly id: string; + readonly column: number; } /** @@ -1478,11 +1478,51 @@ export interface ICursorStateComputer { (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[]; } -export interface ITextModelResolvedOptions { - tabSize: number; - insertSpaces: boolean; - defaultEOL: DefaultEndOfLine; - trimAutoWhitespace: boolean; +export class TextModelResolvedOptions { + _textModelResolvedOptionsBrand: void; + + readonly tabSize: number; + readonly insertSpaces: boolean; + readonly defaultEOL: DefaultEndOfLine; + readonly trimAutoWhitespace: boolean; + + /** + * @internal + */ + constructor(src: { + tabSize: number; + insertSpaces: boolean; + defaultEOL: DefaultEndOfLine; + trimAutoWhitespace: boolean; + }) { + this.tabSize = src.tabSize | 0; + this.insertSpaces = Boolean(src.insertSpaces); + this.defaultEOL = src.defaultEOL | 0; + this.trimAutoWhitespace = Boolean(src.trimAutoWhitespace); + } + + /** + * @internal + */ + public equals(other: TextModelResolvedOptions): boolean { + return ( + this.tabSize === other.tabSize + && this.insertSpaces === other.insertSpaces + && this.defaultEOL === other.defaultEOL + && this.trimAutoWhitespace === other.trimAutoWhitespace + ); + } + + /** + * @internal + */ + public createChangeEvent(newOpts: TextModelResolvedOptions): IModelOptionsChangedEvent { + return { + tabSize: this.tabSize !== newOpts.tabSize, + insertSpaces: this.insertSpaces !== newOpts.insertSpaces, + trimAutoWhitespace: this.trimAutoWhitespace !== newOpts.trimAutoWhitespace, + }; + } } /** @@ -1503,9 +1543,9 @@ export interface ITextModelUpdateOptions { } export interface IModelOptionsChangedEvent { - tabSize: boolean; - insertSpaces: boolean; - trimAutoWhitespace: boolean; + readonly tabSize: boolean; + readonly insertSpaces: boolean; + readonly trimAutoWhitespace: boolean; } /** @@ -1513,7 +1553,7 @@ export interface IModelOptionsChangedEvent { */ export interface ITextModel { - getOptions(): ITextModelResolvedOptions; + getOptions(): TextModelResolvedOptions; /** * Get the current version id of the model. @@ -1761,7 +1801,7 @@ export interface IReadOnlyModel extends ITextModel { /** * Gets the resource associated with this editor model. */ - uri: URI; + readonly uri: URI; /** * Get the language associated with this model. @@ -2222,7 +2262,7 @@ export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWi /** * A unique identifier associated with this model. */ - id: string; + readonly id: string; /** * Destroy this model. This will unbind the model from the mode @@ -2254,14 +2294,6 @@ export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWi isAttachedToEditor(): boolean; } -/** - * @internal - */ -export interface IRangeWithText { - text: string; - range: IRange; -} - /** * An event describing that the current mode associated with a model has changed. */ @@ -2269,11 +2301,11 @@ export interface IModelModeChangedEvent { /** * Previous mode */ - oldMode: IMode; + readonly oldMode: IMode; /** * New mode */ - newMode: IMode; + readonly newMode: IMode; } /** @@ -2283,19 +2315,19 @@ export interface IModelContentChangedEvent2 { /** * The range that got replaced. */ - range: IRange; + readonly range: IRange; /** * The length of the range that got replaced. */ - rangeLength: number; + readonly rangeLength: number; /** * The new text for the range. */ - text: string; + readonly text: string; /** * The (new) end-of-line character. */ - eol: string; + readonly eol: string; /** * The new version id the model has transitioned to. */ @@ -2303,11 +2335,11 @@ export interface IModelContentChangedEvent2 { /** * Flag that indicates that this event was generated while undoing. */ - isUndoing: boolean; + readonly isUndoing: boolean; /** * Flag that indicates that this event was generated while redoing. */ - isRedoing: boolean; + readonly isRedoing: boolean; } /** * An event describing a change in the text of a model. @@ -2321,7 +2353,7 @@ export interface IModelContentChangedEvent { * EditorCommon.EventType.ModelContentChangedLinesInserted => IModelContentChangedLinesDeletedEvent * EditorCommon.EventType.ModelContentChangedLineChanged => IModelContentChangedLinesInsertedEvent */ - changeType: string; + readonly changeType: string; /** * The new version id the model has transitioned to. */ @@ -2329,11 +2361,11 @@ export interface IModelContentChangedEvent { /** * Flag that indicates that this event was generated while undoing. */ - isUndoing: boolean; + readonly isUndoing: boolean; /** * Flag that indicates that this event was generated while redoing. */ - isRedoing: boolean; + readonly isRedoing: boolean; } /** @@ -2343,23 +2375,28 @@ export interface IRawText { /** * The entire text length. */ - length: number; + readonly length: number; /** * The text split into lines. */ - lines: string[]; + readonly lines: string[]; /** * The BOM (leading character sequence of the file). */ - BOM: string; + readonly BOM: string; /** * The end of line sequence. */ - EOL: string; + readonly EOL: string; /** * The options associated with this text. */ - options: ITextModelResolvedOptions; + readonly options: { + readonly tabSize: number; + readonly insertSpaces: boolean; + readonly defaultEOL: DefaultEndOfLine; + readonly trimAutoWhitespace: boolean; + }; } /** @@ -2370,7 +2407,7 @@ export interface IModelContentChangedFlushEvent extends IModelContentChangedEven /** * The new text content of the model. */ - detail: IRawText; + readonly detail: IRawText; } /** * An event describing that a line has changed in a model. @@ -2380,11 +2417,11 @@ export interface IModelContentChangedLineChangedEvent extends IModelContentChang /** * The line that has changed. */ - lineNumber: number; + readonly lineNumber: number; /** * The new value of the line. */ - detail: string; + readonly detail: string; } /** * An event describing that line(s) have been deleted in a model. @@ -2394,11 +2431,11 @@ export interface IModelContentChangedLinesDeletedEvent extends IModelContentChan /** * At what line the deletion began (inclusive). */ - fromLineNumber: number; + readonly fromLineNumber: number; /** * At what line the deletion stopped (inclusive). */ - toLineNumber: number; + readonly toLineNumber: number; } /** * An event describing that line(s) have been inserted in a model. @@ -2408,15 +2445,15 @@ export interface IModelContentChangedLinesInsertedEvent extends IModelContentCha /** * Before what line did the insertion begin */ - fromLineNumber: number; + readonly fromLineNumber: number; /** * `toLineNumber` - `fromLineNumber` + 1 denotes the number of lines that were inserted */ - toLineNumber: number; + readonly toLineNumber: number; /** * The text that was inserted */ - detail: string; + readonly detail: string; } /** * Decoration data associated with a model decorations changed event. @@ -2425,23 +2462,23 @@ export interface IModelDecorationsChangedEventDecorationData { /** * The id of the decoration. */ - id: string; + readonly id: string; /** * The owner id of the decoration. */ - ownerId: number; + readonly ownerId: number; /** * The range of the decoration. */ - range: IRange; + readonly range: IRange; /** * A flag describing if this is a problem decoration (e.g. warning/error). */ - isForValidation: boolean; + readonly isForValidation: boolean; /** * The options for this decoration. */ - options: IModelDecorationOptions; + readonly options: IModelDecorationOptions; } /** * An event describing that model decorations have changed. @@ -2450,23 +2487,23 @@ export interface IModelDecorationsChangedEvent { /** * A summary with ids of decorations that have changed. */ - ids: string[]; + readonly ids: string[]; /** * Lists of details for added or changed decorations. */ - addedOrChangedDecorations: IModelDecorationsChangedEventDecorationData[]; + readonly addedOrChangedDecorations: IModelDecorationsChangedEventDecorationData[]; /** * List of ids for removed decorations. */ - removedDecorations: string[]; + readonly removedDecorations: string[]; /** * Details regarding old options. */ - oldOptions: { [decorationId: string]: IModelDecorationOptions; }; + readonly oldOptions: { [decorationId: string]: IModelDecorationOptions; }; /** * Details regarding old ranges. */ - oldRanges: { [decorationId: string]: IRange; }; + readonly oldRanges: { [decorationId: string]: IRange; }; } /** * An event describing that a range of lines has been tokenized @@ -2475,11 +2512,11 @@ export interface IModelTokensChangedEvent { /** * The start of the range (inclusive) */ - fromLineNumber: number; + readonly fromLineNumber: number; /** * The end of the range (inclusive) */ - toLineNumber: number; + readonly toLineNumber: number; } /** @@ -2522,31 +2559,31 @@ export interface ICursorPositionChangedEvent { /** * Primary cursor's position. */ - position: Position; + readonly position: Position; /** * Primary cursor's view position */ - viewPosition: Position; + readonly viewPosition: Position; /** * Secondary cursors' position. */ - secondaryPositions: Position[]; + readonly secondaryPositions: Position[]; /** * Secondary cursors' view position. */ - secondaryViewPositions: Position[]; + readonly secondaryViewPositions: Position[]; /** * Reason. */ - reason: CursorChangeReason; + readonly reason: CursorChangeReason; /** * Source of the call that caused the event. */ - source: string; + readonly source: string; /** * Is the primary cursor in the editable range? */ - isInEditableRange: boolean; + readonly isInEditableRange: boolean; } /** * An event describing that the cursor selection has changed. @@ -2555,27 +2592,27 @@ export interface ICursorSelectionChangedEvent { /** * The primary selection. */ - selection: Selection; + readonly selection: Selection; /** * The primary selection in view coordinates. */ - viewSelection: Selection; + readonly viewSelection: Selection; /** * The secondary selections. */ - secondarySelections: Selection[]; + readonly secondarySelections: Selection[]; /** * The secondary selections in view coordinates. */ - secondaryViewSelections: Selection[]; + readonly secondaryViewSelections: Selection[]; /** * Source of the call that caused the event. */ - source: string; + readonly source: string; /** * Reason. */ - reason: CursorChangeReason; + readonly reason: CursorChangeReason; } /** * @internal @@ -2595,30 +2632,30 @@ export interface ICursorRevealRangeEvent { /** * Range to be reavealed. */ - range: Range; + readonly range: Range; /** * View range to be reavealed. */ - viewRange: Range; + readonly viewRange: Range; - verticalType: VerticalRevealType; + readonly verticalType: VerticalRevealType; /** * If true: there should be a horizontal & vertical revealing * If false: there should be just a vertical revealing */ - revealHorizontal: boolean; + readonly revealHorizontal: boolean; /** * If true: cursor is revealed if outside viewport */ - revealCursor: boolean; + readonly revealCursor: boolean; } /** * @internal */ export interface ICursorScrollRequestEvent { - deltaLines: number; - revealCursor: boolean; + readonly deltaLines: number; + readonly revealCursor: boolean; } /** @@ -2628,44 +2665,44 @@ export interface IModelChangedEvent { /** * The `uri` of the previous model or null. */ - oldModelUrl: URI; + readonly oldModelUrl: URI; /** * The `uri` of the new model or null. */ - newModelUrl: URI; + readonly newModelUrl: URI; } /** * @internal */ export interface IEditorWhitespace { - id: number; - afterLineNumber: number; - heightInLines: number; + readonly id: number; + readonly afterLineNumber: number; + readonly heightInLines: number; } /** * A description for the overview ruler position. */ export class OverviewRulerPosition { - _overviewRulerPositionBrand: void; + readonly _overviewRulerPositionBrand: void; /** * Width of the overview ruler */ - width: number; + readonly width: number; /** * Height of the overview ruler */ - height: number; + readonly height: number; /** * Top position for the overview ruler */ - top: number; + readonly top: number; /** * Right position for the overview ruler */ - right: number; + readonly right: number; /** * @internal @@ -2706,82 +2743,82 @@ export class OverviewRulerPosition { * The internal layout details of the editor. */ export class EditorLayoutInfo { - _editorLayoutInfoBrand: void; + readonly _editorLayoutInfoBrand: void; /** * Full editor width. */ - width: number; + readonly width: number; /** * Full editor height. */ - height: number; + readonly height: number; /** * Left position for the glyph margin. */ - glyphMarginLeft: number; + readonly glyphMarginLeft: number; /** * The width of the glyph margin. */ - glyphMarginWidth: number; + readonly glyphMarginWidth: number; /** * The height of the glyph margin. */ - glyphMarginHeight: number; + readonly glyphMarginHeight: number; /** * Left position for the line numbers. */ - lineNumbersLeft: number; + readonly lineNumbersLeft: number; /** * The width of the line numbers. */ - lineNumbersWidth: number; + readonly lineNumbersWidth: number; /** * The height of the line numbers. */ - lineNumbersHeight: number; + readonly lineNumbersHeight: number; /** * Left position for the line decorations. */ - decorationsLeft: number; + readonly decorationsLeft: number; /** * The width of the line decorations. */ - decorationsWidth: number; + readonly decorationsWidth: number; /** * The height of the line decorations. */ - decorationsHeight: number; + readonly decorationsHeight: number; /** * Left position for the content (actual text) */ - contentLeft: number; + readonly contentLeft: number; /** * The width of the content (actual text) */ - contentWidth: number; + readonly contentWidth: number; /** * The height of the content (actual height) */ - contentHeight: number; + readonly contentHeight: number; /** * The width of the vertical scrollbar. */ - verticalScrollbarWidth: number; + readonly verticalScrollbarWidth: number; /** * The height of the horizontal scrollbar. */ - horizontalScrollbarHeight: number; + readonly horizontalScrollbarHeight: number; /** * The position of the overview ruler. */ - overviewRuler: OverviewRulerPosition; + readonly overviewRuler: OverviewRulerPosition; /** * @internal @@ -2989,32 +3026,32 @@ export interface IDiffEditorViewState extends IEditorViewState { * A change */ export interface IChange { - originalStartLineNumber: number; - originalEndLineNumber: number; - modifiedStartLineNumber: number; - modifiedEndLineNumber: number; + readonly originalStartLineNumber: number; + readonly originalEndLineNumber: number; + readonly modifiedStartLineNumber: number; + readonly modifiedEndLineNumber: number; } /** * A character level change. */ export interface ICharChange extends IChange { - originalStartColumn: number; - originalEndColumn: number; - modifiedStartColumn: number; - modifiedEndColumn: number; + readonly originalStartColumn: number; + readonly originalEndColumn: number; + readonly modifiedStartColumn: number; + readonly modifiedEndColumn: number; } /** * A line change */ export interface ILineChange extends IChange { - charChanges: ICharChange[]; + readonly charChanges: ICharChange[]; } /** * Information about a line in the diff editor * @internal */ export interface IDiffLineInformation { - equivalentLineNumber: number; + readonly equivalentLineNumber: number; } /** @@ -3136,12 +3173,12 @@ export namespace ModeContextKeys { } export class BareFontInfo { - _bareFontInfoBrand: void; + readonly _bareFontInfoBrand: void; - fontFamily: string; - fontWeight: string; - fontSize: number; - lineHeight: number; + readonly fontFamily: string; + readonly fontWeight: string; + readonly fontSize: number; + readonly lineHeight: number; /** * @internal @@ -3167,12 +3204,12 @@ export class BareFontInfo { } export class FontInfo extends BareFontInfo { - _editorStylingBrand: void; + readonly _editorStylingBrand: void; - typicalHalfwidthCharacterWidth: number; - typicalFullwidthCharacterWidth: number; - spaceWidth: number; - maxDigitWidth: number; + readonly typicalHalfwidthCharacterWidth: number; + readonly typicalFullwidthCharacterWidth: number; + readonly spaceWidth: number; + readonly maxDigitWidth: number; /** * @internal @@ -3222,31 +3259,15 @@ export class FontInfo extends BareFontInfo { * @internal */ export interface IConfiguration { - onDidChange: Event; + readonly onDidChange: Event; - editor: InternalEditorOptions; + readonly editor: InternalEditorOptions; setMaxLineNumber(maxLineNumber: number): void; } // --- view -/** - * @internal - */ -export interface IViewEventNames { - ModelFlushedEvent: string; - LinesDeletedEvent: string; - LinesInsertedEvent: string; - LineChangedEvent: string; - TokensChangedEvent: string; - DecorationsChangedEvent: string; - CursorPositionChangedEvent: string; - CursorSelectionChangedEvent: string; - RevealRangeEvent: string; - LineMappingChangedEvent: string; -} - /** * @internal */ @@ -3265,15 +3286,15 @@ export var ViewEventNames = { }; export interface IScrollEvent { - scrollTop: number; - scrollLeft: number; - scrollWidth: number; - scrollHeight: number; + readonly scrollTop: number; + readonly scrollLeft: number; + readonly scrollWidth: number; + readonly scrollHeight: number; - scrollTopChanged: boolean; - scrollLeftChanged: boolean; - scrollWidthChanged: boolean; - scrollHeightChanged: boolean; + readonly scrollTopChanged: boolean; + readonly scrollLeftChanged: boolean; + readonly scrollWidthChanged: boolean; + readonly scrollHeightChanged: boolean; } export interface INewScrollPosition { @@ -3288,11 +3309,11 @@ export interface IViewLinesDeletedEvent { /** * At what line the deletion began (inclusive). */ - fromLineNumber: number; + readonly fromLineNumber: number; /** * At what line the deletion stopped (inclusive). */ - toLineNumber: number; + readonly toLineNumber: number; } /** @@ -3302,11 +3323,11 @@ export interface IViewLinesInsertedEvent { /** * Before what line did the insertion begin */ - fromLineNumber: number; + readonly fromLineNumber: number; /** * `toLineNumber` - `fromLineNumber` + 1 denotes the number of lines that were inserted */ - toLineNumber: number; + readonly toLineNumber: number; } /** @@ -3316,7 +3337,7 @@ export interface IViewLineChangedEvent { /** * The line that has changed. */ - lineNumber: number; + readonly lineNumber: number; } /** @@ -3326,11 +3347,11 @@ export interface IViewTokensChangedEvent { /** * Start line number of range */ - fromLineNumber: number; + readonly fromLineNumber: number; /** * End line number of range */ - toLineNumber: number; + readonly toLineNumber: number; } /** @@ -3340,7 +3361,7 @@ export interface IViewDecorationsChangedEvent { /** * signals that at least one inline decoration has changed */ - inlineDecorationsChanged: boolean; + readonly inlineDecorationsChanged: boolean; } /** @@ -3350,15 +3371,15 @@ export interface IViewCursorPositionChangedEvent { /** * Primary cursor's position. */ - position: Position; + readonly position: Position; /** * Secondary cursors' position. */ - secondaryPositions: Position[]; + readonly secondaryPositions: Position[]; /** * Is the primary cursor in the editable range? */ - isInEditableRange: boolean; + readonly isInEditableRange: boolean; } /** @@ -3368,11 +3389,11 @@ export interface IViewCursorSelectionChangedEvent { /** * The primary selection. */ - selection: Selection; + readonly selection: Selection; /** * The secondary selections. */ - secondarySelections: Selection[]; + readonly secondarySelections: Selection[]; } /** @@ -3382,48 +3403,48 @@ export interface IViewRevealRangeEvent { /** * Range to be reavealed. */ - range: Range; + readonly range: Range; - verticalType: VerticalRevealType; + readonly verticalType: VerticalRevealType; /** * If true: there should be a horizontal & vertical revealing * If false: there should be just a vertical revealing */ - revealHorizontal: boolean; + readonly revealHorizontal: boolean; /** * If true: cursor is revealed if outside viewport */ - revealCursor: boolean; + readonly revealCursor: boolean; } /** * @internal */ export interface IViewScrollRequestEvent { - deltaLines: number; - revealCursor: boolean; + readonly deltaLines: number; + readonly revealCursor: boolean; } /** * @internal */ export interface IViewWhitespaceViewportData { - id: number; - afterLineNumber: number; - verticalOffset: number; - height: number; + readonly id: number; + readonly afterLineNumber: number; + readonly verticalOffset: number; + readonly height: number; } /** * @internal */ export class Viewport { - _viewportBrand: void; + readonly _viewportBrand: void; - top: number; - left: number; - width: number; - height: number; + readonly top: number; + readonly left: number; + readonly width: number; + readonly height: number; constructor(top: number, left: number, width: number, height: number) { this.top = top | 0; @@ -3471,33 +3492,18 @@ export interface IActionDescriptor { * Method that will be executed when the action is triggered. * @param editor The editor instance is passed in as a convinience */ - run: (editor: ICommonCodeEditor) => TPromise; + run(editor: ICommonCodeEditor): void | TPromise; } -/** - * Data associated with an editor action contribution - * @internal - */ -export interface IEditorActionDescriptorData { - id: string; - label: string; - alias?: string; -} - -/** - * @internal - */ -export type IEditorActionContributionCtor = IConstructorSignature2; - /** * @internal */ export type ICommonEditorContributionCtor = IConstructorSignature1; export interface IEditorAction { - id: string; - label: string; - alias: string; + readonly id: string; + readonly label: string; + readonly alias: string; isSupported(): boolean; run(): TPromise; } @@ -4135,13 +4141,13 @@ export interface ICommonDiffEditor extends IEditor { * Returns whether the diff editor is ignoring trim whitespace or not. * @internal */ - ignoreTrimWhitespace: boolean; + readonly ignoreTrimWhitespace: boolean; /** * Returns whether the diff editor is rendering side by side or not. * @internal */ - renderSideBySide: boolean; + readonly renderSideBySide: boolean; } /** diff --git a/src/vs/editor/common/model/editableTextModel.ts b/src/vs/editor/common/model/editableTextModel.ts index 7f51e34d80d..43c3fcc01c0 100644 --- a/src/vs/editor/common/model/editableTextModel.ts +++ b/src/vs/editor/common/model/editableTextModel.ts @@ -68,8 +68,8 @@ export class EditableTextModel extends TextModelWithDecorations implements edito super.dispose(); } - protected _resetValue(e: editorCommon.IModelContentChangedFlushEvent, newValue: editorCommon.IRawText): void { - super._resetValue(e, newValue); + protected _resetValue(newValue: editorCommon.IRawText): void { + super._resetValue(newValue); // Destroy my edit history and settings this._commandManager = new EditStack(this); diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index fae5fb65207..b3583ff6521 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -35,7 +35,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo protected _EOL: string; protected _isDisposed: boolean; protected _isDisposing: boolean; - protected _options: editorCommon.ITextModelResolvedOptions; + protected _options: editorCommon.TextModelResolvedOptions; protected _lineStarts: PrefixSumComputer; private _indentRanges: IndentRange[]; @@ -56,7 +56,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo this._shouldSimplifyMode = (rawText.length > TextModel.MODEL_SYNC_LIMIT); this._shouldDenyMode = (rawText.length > TextModel.MODEL_TOKENIZATION_LIMIT); - this._options = rawText.options; + this._options = new editorCommon.TextModelResolvedOptions(rawText.options); this._constructLines(rawText); this._setVersionId(1); this._isDisposed = false; @@ -71,48 +71,37 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo return this._shouldSimplifyMode; } - public getOptions(): editorCommon.ITextModelResolvedOptions { + public getOptions(): editorCommon.TextModelResolvedOptions { return this._options; } - public updateOptions(newOpts: editorCommon.ITextModelUpdateOptions): void { - let somethingChanged = false; - let changed: editorCommon.IModelOptionsChangedEvent = { - tabSize: false, - insertSpaces: false, - trimAutoWhitespace: false - }; + public updateOptions(_newOpts: editorCommon.ITextModelUpdateOptions): void { + let tabSize = (typeof _newOpts.tabSize !== 'undefined') ? _newOpts.tabSize : this._options.tabSize; + let insertSpaces = (typeof _newOpts.insertSpaces !== 'undefined') ? _newOpts.insertSpaces : this._options.insertSpaces; + let trimAutoWhitespace = (typeof _newOpts.trimAutoWhitespace !== 'undefined') ? _newOpts.trimAutoWhitespace : this._options.trimAutoWhitespace; - if (typeof newOpts.insertSpaces !== 'undefined') { - if (this._options.insertSpaces !== newOpts.insertSpaces) { - somethingChanged = true; - changed.insertSpaces = true; - this._options.insertSpaces = newOpts.insertSpaces; - } - } - if (typeof newOpts.tabSize !== 'undefined') { - let newTabSize = newOpts.tabSize | 0; - if (this._options.tabSize !== newTabSize) { - somethingChanged = true; - changed.tabSize = true; - this._options.tabSize = newTabSize; + let newOpts = new editorCommon.TextModelResolvedOptions({ + tabSize: tabSize, + insertSpaces: insertSpaces, + defaultEOL: this._options.defaultEOL, + trimAutoWhitespace: trimAutoWhitespace + }); - for (let i = 0, len = this._lines.length; i < len; i++) { - this._lines[i].updateTabSize(newTabSize); - } - } + if (this._options.equals(newOpts)) { + return; } - if (typeof newOpts.trimAutoWhitespace !== 'undefined') { - if (this._options.trimAutoWhitespace !== newOpts.trimAutoWhitespace) { - somethingChanged = true; - changed.trimAutoWhitespace = true; - this._options.trimAutoWhitespace = newOpts.trimAutoWhitespace; + + let e = this._options.createChangeEvent(newOpts); + this._options = newOpts; + + if (e.tabSize) { + let newTabSize = this._options.tabSize; + for (let i = 0, len = this._lines.length; i < len; i++) { + this._lines[i].updateTabSize(newTabSize); } } - if (somethingChanged) { - this.emit(editorCommon.EventType.ModelOptionsChanged, changed); - } + this.emit(editorCommon.EventType.ModelOptionsChanged, e); } public detectIndentation(defaultInsertSpaces: boolean, defaultTabSize: number): void { @@ -244,9 +233,9 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo protected _createContentChangedFlushEvent(): editorCommon.IModelContentChangedFlushEvent { return { changeType: editorCommon.EventType.ModelRawContentChangedFlush, - detail: null, + detail: this.toRawText(), + versionId: this._versionId, // TODO@Alex -> remove these fields from here - versionId: -1, isUndoing: false, isRedoing: false }; @@ -267,13 +256,9 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo } } - protected _resetValue(e: editorCommon.IModelContentChangedFlushEvent, newValue: editorCommon.IRawText): void { + protected _resetValue(newValue: editorCommon.IRawText): void { this._constructLines(newValue); - this._increaseVersionId(); - - e.detail = this.toRawText(); - e.versionId = this._versionId; } public toRawText(): editorCommon.IRawText { @@ -329,10 +314,11 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo var oldModelValueLength = this.getValueLengthInRange(oldFullModelRange); var endLineNumber = this.getLineCount(); var endColumn = this.getLineMaxColumn(endLineNumber); - var e = this._createContentChangedFlushEvent(); - this._resetValue(e, newValue); - this._emitModelContentChangedFlushEvent(e); + this._resetValue(newValue); + + this._emitModelContentChangedFlushEvent(this._createContentChangedFlushEvent()); + this._emitContentChanged2(1, 1, endLineNumber, endColumn, oldModelValueLength, this.getValue(), false, false); } @@ -557,11 +543,8 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo this._lineStarts = null; this._increaseVersionId(); - var e = this._createContentChangedFlushEvent(); - e.detail = this.toRawText(); - e.versionId = this._versionId; + this._emitModelContentChangedFlushEvent(this._createContentChangedFlushEvent()); - this._emitModelContentChangedFlushEvent(e); this._emitContentChanged2(1, 1, endLineNumber, endColumn, oldModelValueLength, this.getValue(), false, false); } @@ -739,22 +722,22 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo EOL = '\n'; } - let resolvedOpts: editorCommon.ITextModelResolvedOptions; + let resolvedOpts: editorCommon.TextModelResolvedOptions; if (opts.detectIndentation) { let guessedIndentation = guessIndentation(lines, opts.tabSize, opts.insertSpaces); - resolvedOpts = { + resolvedOpts = new editorCommon.TextModelResolvedOptions({ tabSize: guessedIndentation.tabSize, insertSpaces: guessedIndentation.insertSpaces, trimAutoWhitespace: opts.trimAutoWhitespace, defaultEOL: opts.defaultEOL - }; + }); } else { - resolvedOpts = { + resolvedOpts = new editorCommon.TextModelResolvedOptions({ tabSize: opts.tabSize, insertSpaces: opts.insertSpaces, trimAutoWhitespace: opts.trimAutoWhitespace, defaultEOL: opts.defaultEOL - }; + }); } return { diff --git a/src/vs/editor/common/model/textModelWithDecorations.ts b/src/vs/editor/common/model/textModelWithDecorations.ts index 151c9b4fa66..da0be77c543 100644 --- a/src/vs/editor/common/model/textModelWithDecorations.ts +++ b/src/vs/editor/common/model/textModelWithDecorations.ts @@ -111,8 +111,8 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme super.dispose(); } - protected _resetValue(e: editorCommon.IModelContentChangedFlushEvent, newValue: editorCommon.IRawText): void { - super._resetValue(e, newValue); + protected _resetValue(newValue: editorCommon.IRawText): void { + super._resetValue(newValue); // Destroy all my decorations this.decorations = {}; @@ -354,14 +354,15 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme decorationIds.push(decorationId); decorationData = this._getDecorationData(decorationId); - decorationData.isForValidation = (decorationData.options.className === editorCommon.ClassName.EditorErrorDecoration || decorationData.options.className === editorCommon.ClassName.EditorWarningDecoration); addedOrChangedDecorations.push(decorationData); if (b.oldDecorationRange.hasOwnProperty(decorationId)) { oldRange = b.oldDecorationRange[decorationId]; - oldRange.startLineNumber = oldRange.startLineNumber || decorationData.range.startLineNumber; - oldRange.startColumn = oldRange.startColumn || decorationData.range.startColumn; - oldRange.endLineNumber = oldRange.endLineNumber || decorationData.range.endLineNumber; - oldRange.endColumn = oldRange.endColumn || decorationData.range.endColumn; + b.oldDecorationRange[decorationId] = { + startLineNumber: oldRange.startLineNumber || decorationData.range.startLineNumber, + startColumn: oldRange.startColumn || decorationData.range.startColumn, + endLineNumber: oldRange.endLineNumber || decorationData.range.endLineNumber, + endColumn: oldRange.endColumn || decorationData.range.endColumn + }; } } @@ -390,7 +391,7 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme id: decoration.id, ownerId: decoration.ownerId, range: this.getTrackedRange(decoration.rangeId), - isForValidation: false, + isForValidation: (decoration.options.className === editorCommon.ClassName.EditorErrorDecoration || decoration.options.className === editorCommon.ClassName.EditorWarningDecoration), options: decoration.options }; } diff --git a/src/vs/editor/common/model/textModelWithMarkers.ts b/src/vs/editor/common/model/textModelWithMarkers.ts index 653b589a9a4..46052dea41c 100644 --- a/src/vs/editor/common/model/textModelWithMarkers.ts +++ b/src/vs/editor/common/model/textModelWithMarkers.ts @@ -6,7 +6,7 @@ import { IdGenerator } from 'vs/base/common/idGenerator'; import { Position } from 'vs/editor/common/core/position'; -import { IModelContentChangedFlushEvent, IRawText, IReadOnlyLineMarker, ITextModelWithMarkers } from 'vs/editor/common/editorCommon'; +import { IRawText, IReadOnlyLineMarker, ITextModelWithMarkers } from 'vs/editor/common/editorCommon'; import { ILineMarker, ModelLine } from 'vs/editor/common/model/modelLine'; import { TextModelWithTokens } from 'vs/editor/common/model/textModelWithTokens'; @@ -60,8 +60,8 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo super.dispose(); } - protected _resetValue(e: IModelContentChangedFlushEvent, newValue: IRawText): void { - super._resetValue(e, newValue); + protected _resetValue(newValue: IRawText): void { + super._resetValue(newValue); // Destroy all my markers this._markerIdToMarker = {}; diff --git a/src/vs/editor/common/model/textModelWithTokens.ts b/src/vs/editor/common/model/textModelWithTokens.ts index 1d303de1d13..9826a7667ed 100644 --- a/src/vs/editor/common/model/textModelWithTokens.ts +++ b/src/vs/editor/common/model/textModelWithTokens.ts @@ -126,8 +126,8 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke return false; } - protected _resetValue(e: editorCommon.IModelContentChangedFlushEvent, newValue: editorCommon.IRawText): void { - super._resetValue(e, newValue); + protected _resetValue(newValue: editorCommon.IRawText): void { + super._resetValue(newValue); // Cancel tokenization, clear all tokens and begin tokenizing this._resetTokenizationState(); } diff --git a/src/vs/editor/common/model/textModelWithTrackedRanges.ts b/src/vs/editor/common/model/textModelWithTrackedRanges.ts index 85703fb8719..c01a3a19443 100644 --- a/src/vs/editor/common/model/textModelWithTrackedRanges.ts +++ b/src/vs/editor/common/model/textModelWithTrackedRanges.ts @@ -61,8 +61,8 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements super.dispose(); } - protected _resetValue(e: editorCommon.IModelContentChangedFlushEvent, newValue: editorCommon.IRawText): void { - super._resetValue(e, newValue); + protected _resetValue(newValue: editorCommon.IRawText): void { + super._resetValue(newValue); // Destroy all my tracked ranges this._ranges = {}; @@ -312,42 +312,43 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements } protected _onChangedMarkers(changedMarkers: ILineMarker[]): editorCommon.IChangedTrackedRanges { - var changedRanges: editorCommon.IChangedTrackedRanges = {}, - changedRange: editorCommon.IRange, - range: ITrackedRange, - rangeId: string, - marker: ILineMarker, - i: number, - len: number; + let changedRanges: editorCommon.IChangedTrackedRanges = {}; - for (i = 0, len = changedMarkers.length; i < len; i++) { - marker = changedMarkers[i]; + for (let i = 0, len = changedMarkers.length; i < len; i++) { + let marker = changedMarkers[i]; if (this._markerIdToRangeId.hasOwnProperty(marker.id)) { - rangeId = this._markerIdToRangeId[marker.id]; + let rangeId = this._markerIdToRangeId[marker.id]; + let range = this._ranges[rangeId]; - range = this._ranges[rangeId]; + let startLineNumber = 0; + let startColumn = 0; + let endLineNumber = 0; + let endColumn = 0; if (changedRanges.hasOwnProperty(range.id)) { - changedRange = changedRanges[range.id]; - } else { - changedRange = { - startLineNumber: 0, - startColumn: 0, - endLineNumber: 0, - endColumn: 0 - }; - changedRanges[range.id] = changedRange; + let changedRange = changedRanges[range.id]; + startLineNumber = changedRange.startLineNumber; + startColumn = changedRange.startColumn; + endLineNumber = changedRange.endLineNumber; + endColumn = changedRange.endColumn; } if (marker.id === range.startMarkerId) { - changedRange.startLineNumber = marker.oldLineNumber; - changedRange.startColumn = marker.oldColumn; + startLineNumber = marker.oldLineNumber; + startColumn = marker.oldColumn; } else { - changedRange.endLineNumber = marker.oldLineNumber; - changedRange.endColumn = marker.oldColumn; + endLineNumber = marker.oldLineNumber; + endColumn = marker.oldColumn; } + changedRanges[range.id] = { + startLineNumber: startLineNumber, + startColumn: startColumn, + endLineNumber: endLineNumber, + endColumn: endColumn + }; + this._setRangeIsMultiLine(range.id, (this._getMarker(range.startMarkerId).lineNumber !== this._getMarker(range.endMarkerId).lineNumber)); } } diff --git a/src/vs/editor/common/services/editorSimpleWorker.ts b/src/vs/editor/common/services/editorSimpleWorker.ts index 5ae95841846..131bdbd3e3d 100644 --- a/src/vs/editor/common/services/editorSimpleWorker.ts +++ b/src/vs/editor/common/services/editorSimpleWorker.ts @@ -22,8 +22,8 @@ import { getWordAtText, ensureValidWordDefinition } from 'vs/editor/common/model import { createMonacoBaseAPI } from 'vs/editor/common/standalone/standaloneBase'; export interface IMirrorModel { - uri: URI; - version: number; + readonly uri: URI; + readonly version: number; getValue(): string; } @@ -283,7 +283,12 @@ export abstract class BaseEditorSimpleWorker { let wordDefRegExp = new RegExp(wordDef, wordDefFlags); if (range.startColumn === range.endColumn) { - range.endColumn += 1; + range = { + startLineNumber: range.startLineNumber, + startColumn: range.startColumn, + endLineNumber: range.endLineNumber, + endColumn: range.endColumn + 1 + }; } let selectionText = model.getValueInRange(range); diff --git a/src/vs/editor/common/standalone/standaloneBase.ts b/src/vs/editor/common/standalone/standaloneBase.ts index 287c98baa18..a42691c6355 100644 --- a/src/vs/editor/common/standalone/standaloneBase.ts +++ b/src/vs/editor/common/standalone/standaloneBase.ts @@ -27,10 +27,10 @@ export enum Severity { // This is repeated here so it can be exported // -------------------------------------------- export class KeyMod { - public static CtrlCmd: number = ConstKeyMod.CtrlCmd; - public static Shift: number = ConstKeyMod.Shift; - public static Alt: number = ConstKeyMod.Alt; - public static WinCtrl: number = ConstKeyMod.WinCtrl; + public static readonly CtrlCmd: number = ConstKeyMod.CtrlCmd; + public static readonly Shift: number = ConstKeyMod.Shift; + public static readonly Alt: number = ConstKeyMod.Alt; + public static readonly WinCtrl: number = ConstKeyMod.WinCtrl; public static chord(firstPart: number, secondPart: number): number { return KeyChord(firstPart, secondPart); diff --git a/src/vs/editor/contrib/inPlaceReplace/common/inPlaceReplace.ts b/src/vs/editor/contrib/inPlaceReplace/common/inPlaceReplace.ts index b0b80e6863a..1415ee076d3 100644 --- a/src/vs/editor/contrib/inPlaceReplace/common/inPlaceReplace.ts +++ b/src/vs/editor/contrib/inPlaceReplace/common/inPlaceReplace.ts @@ -96,7 +96,12 @@ class InPlaceReplaceController implements IEditorContribution { diff = result.value.length - (selection.endColumn - selection.startColumn); // highlight - highlightRange.endColumn = highlightRange.startColumn + result.value.length; + highlightRange = { + startLineNumber: highlightRange.startLineNumber, + startColumn: highlightRange.startColumn, + endLineNumber: highlightRange.endLineNumber, + endColumn: highlightRange.startColumn + result.value.length + }; if (diff > 1) { selection = new Selection(selection.startLineNumber, selection.startColumn, selection.endLineNumber, selection.endColumn + diff - 1); } diff --git a/src/vs/editor/node/model/modelBuilder.ts b/src/vs/editor/node/model/modelBuilder.ts index 56516bc322b..a8557298aa8 100644 --- a/src/vs/editor/node/model/modelBuilder.ts +++ b/src/vs/editor/node/model/modelBuilder.ts @@ -6,7 +6,7 @@ import { IStringStream } from 'vs/platform/files/common/files'; import * as crypto from 'crypto'; -import { DefaultEndOfLine, ITextModelCreationOptions, ITextModelResolvedOptions, IRawText } from 'vs/editor/common/editorCommon'; +import { DefaultEndOfLine, ITextModelCreationOptions, TextModelResolvedOptions, IRawText } from 'vs/editor/common/editorCommon'; import * as strings from 'vs/base/common/strings'; import { guessIndentation } from 'vs/editor/common/model/indentationGuesser'; import { TPromise } from 'vs/base/common/winjs.base'; @@ -61,22 +61,22 @@ class ModelLineBasedBuilder { EOL = '\n'; } - let resolvedOpts: ITextModelResolvedOptions; + let resolvedOpts: TextModelResolvedOptions; if (opts.detectIndentation) { let guessedIndentation = guessIndentation(this.lines, opts.tabSize, opts.insertSpaces); - resolvedOpts = { + resolvedOpts = new TextModelResolvedOptions({ tabSize: guessedIndentation.tabSize, insertSpaces: guessedIndentation.insertSpaces, trimAutoWhitespace: opts.trimAutoWhitespace, defaultEOL: opts.defaultEOL - }; + }); } else { - resolvedOpts = { + resolvedOpts = new TextModelResolvedOptions({ tabSize: opts.tabSize, insertSpaces: opts.insertSpaces, trimAutoWhitespace: opts.trimAutoWhitespace, defaultEOL: opts.defaultEOL - }; + }); } return { diff --git a/src/vs/editor/test/common/diff/diffComputer.test.ts b/src/vs/editor/test/common/diff/diffComputer.test.ts index 507aedae299..49891c9495d 100644 --- a/src/vs/editor/test/common/diff/diffComputer.test.ts +++ b/src/vs/editor/test/common/diff/diffComputer.test.ts @@ -24,22 +24,31 @@ function extractCharChangeRepresentation(change, expectedChange): ICharChange { }; } -function extractLineChangeRepresentation(change, expectedChange): ILineChange { - var result: ILineChange = { +function extractLineChangeRepresentation(change, expectedChange): IChange|ILineChange { + if (change.charChanges) { + let charChanges: ICharChange[] = []; + for (let i = 0; i < change.charChanges.length; i++) { + charChanges.push( + extractCharChangeRepresentation( + change.charChanges[i], + expectedChange && expectedChange.charChanges && i < expectedChange.charChanges.length ? expectedChange.charChanges[i] : null + ) + ); + } + return { + originalStartLineNumber: change.originalStartLineNumber, + originalEndLineNumber: change.originalEndLineNumber, + modifiedStartLineNumber: change.modifiedStartLineNumber, + modifiedEndLineNumber: change.modifiedEndLineNumber, + charChanges: charChanges + }; + } + return { originalStartLineNumber: change.originalStartLineNumber, originalEndLineNumber: change.originalEndLineNumber, modifiedStartLineNumber: change.modifiedStartLineNumber, modifiedEndLineNumber: change.modifiedEndLineNumber }; - if (change.charChanges) { - var charChanges = []; - for (var i = 0; i < change.charChanges.length; i++) { - charChanges.push(extractCharChangeRepresentation(change.charChanges[i], - expectedChange && expectedChange.charChanges && i < expectedChange.charChanges.length ? expectedChange.charChanges[i] : null)); - } - result.charChanges = charChanges; - } - return result; } function assertDiff(originalLines: string[], modifiedLines: string[], expectedChanges: IChange[], shouldPostProcessCharChanges: boolean = false, shouldIgnoreTrimWhitespace: boolean = false) { diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 4e28ecd6bc2..2f7793222e6 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -24,7 +24,7 @@ declare module monaco { */ export class Emitter { constructor(); - event: IEvent; + readonly event: IEvent; fire(event?: T): void; dispose(): void; } @@ -95,12 +95,12 @@ declare module monaco { } export interface CancellationToken { - isCancellationRequested: boolean; + readonly isCancellationRequested: boolean; /** * An event emitted when cancellation is requested * @event */ - onCancellationRequested: IEvent; + readonly onCancellationRequested: IEvent; } /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. @@ -351,10 +351,10 @@ declare module monaco { } export class KeyMod { - static CtrlCmd: number; - static Shift: number; - static Alt: number; - static WinCtrl: number; + static readonly CtrlCmd: number; + static readonly Shift: number; + static readonly Alt: number; + static readonly WinCtrl: number; static chord(firstPart: number, secondPart: number): number; } /** @@ -363,50 +363,50 @@ declare module monaco { * markdown strings will be sanitized - that means html will be escaped. */ export type MarkedString = string | { - language: string; - value: string; + readonly language: string; + readonly value: string; }; export interface IKeyboardEvent { - browserEvent: KeyboardEvent; - target: HTMLElement; - ctrlKey: boolean; - shiftKey: boolean; - altKey: boolean; - metaKey: boolean; - keyCode: KeyCode; + readonly browserEvent: KeyboardEvent; + readonly target: HTMLElement; + readonly ctrlKey: boolean; + readonly shiftKey: boolean; + readonly altKey: boolean; + readonly metaKey: boolean; + readonly keyCode: KeyCode; asKeybinding(): number; equals(keybinding: number): boolean; preventDefault(): void; stopPropagation(): void; } export interface IMouseEvent { - browserEvent: MouseEvent; - leftButton: boolean; - middleButton: boolean; - rightButton: boolean; - target: HTMLElement; - detail: number; - posx: number; - posy: number; - ctrlKey: boolean; - shiftKey: boolean; - altKey: boolean; - metaKey: boolean; - timestamp: number; + readonly browserEvent: MouseEvent; + readonly leftButton: boolean; + readonly middleButton: boolean; + readonly rightButton: boolean; + readonly target: HTMLElement; + readonly detail: number; + readonly posx: number; + readonly posy: number; + readonly ctrlKey: boolean; + readonly shiftKey: boolean; + readonly altKey: boolean; + readonly metaKey: boolean; + readonly timestamp: number; preventDefault(): void; stopPropagation(): void; } export interface IScrollEvent { - scrollTop: number; - scrollLeft: number; - scrollWidth: number; - scrollHeight: number; - scrollTopChanged: boolean; - scrollLeftChanged: boolean; - scrollWidthChanged: boolean; - scrollHeightChanged: boolean; + readonly scrollTop: number; + readonly scrollLeft: number; + readonly scrollWidth: number; + readonly scrollHeight: number; + readonly scrollTopChanged: boolean; + readonly scrollLeftChanged: boolean; + readonly scrollWidthChanged: boolean; + readonly scrollHeightChanged: boolean; } /** @@ -416,11 +416,11 @@ declare module monaco { /** * line number (starts at 1) */ - lineNumber: number; + readonly lineNumber: number; /** * column (the first character in a line is between column 1 and column 2) */ - column: number; + readonly column: number; } /** @@ -430,19 +430,19 @@ declare module monaco { /** * Line number on which the range starts (starts at 1). */ - startLineNumber: number; + readonly startLineNumber: number; /** * Column on which the range starts in line `startLineNumber` (starts at 1). */ - startColumn: number; + readonly startColumn: number; /** * Line number on which the range ends. */ - endLineNumber: number; + readonly endLineNumber: number; /** * Column on which the range ends in line `endLineNumber`. */ - endColumn: number; + readonly endColumn: number; } /** @@ -453,19 +453,19 @@ declare module monaco { /** * The line number on which the selection has started. */ - selectionStartLineNumber: number; + readonly selectionStartLineNumber: number; /** * The column on `selectionStartLineNumber` where the selection has started. */ - selectionStartColumn: number; + readonly selectionStartColumn: number; /** * The line number on which the selection has ended. */ - positionLineNumber: number; + readonly positionLineNumber: number; /** * The column on `positionLineNumber` where the selection has ended. */ - positionColumn: number; + readonly positionColumn: number; } /** @@ -766,9 +766,9 @@ declare module monaco.editor { } export interface IDiffNavigatorOptions { - followsCaret?: boolean; - ignoreCharChanges?: boolean; - alwaysRevealFirst?: boolean; + readonly followsCaret?: boolean; + readonly ignoreCharChanges?: boolean; + readonly alwaysRevealFirst?: boolean; } export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: IDiffNavigatorOptions): IDiffNavigator; @@ -816,8 +816,8 @@ declare module monaco.editor { * @event */ export function onDidChangeModelLanguage(listener: (e: { - model: IModel; - oldLanguage: string; + readonly model: IModel; + readonly oldLanguage: string; }) => void): IDisposable; /** @@ -951,16 +951,6 @@ declare module monaco.editor { Visible = 3, } - export interface IAction extends IDisposable { - id: string; - label: string; - tooltip: string; - class: string; - enabled: boolean; - checked: boolean; - run(event?: any): Promise; - } - /** * Configuration options for editor scrollbars */ @@ -1374,142 +1364,142 @@ declare module monaco.editor { } export class InternalEditorScrollbarOptions { - _internalEditorScrollbarOptionsBrand: void; - arrowSize: number; - vertical: ScrollbarVisibility; - horizontal: ScrollbarVisibility; - useShadows: boolean; - verticalHasArrows: boolean; - horizontalHasArrows: boolean; - handleMouseWheel: boolean; - horizontalScrollbarSize: number; - horizontalSliderSize: number; - verticalScrollbarSize: number; - verticalSliderSize: number; - mouseWheelScrollSensitivity: number; + readonly _internalEditorScrollbarOptionsBrand: void; + readonly arrowSize: number; + readonly vertical: ScrollbarVisibility; + readonly horizontal: ScrollbarVisibility; + readonly useShadows: boolean; + readonly verticalHasArrows: boolean; + readonly horizontalHasArrows: boolean; + readonly handleMouseWheel: boolean; + readonly horizontalScrollbarSize: number; + readonly horizontalSliderSize: number; + readonly verticalScrollbarSize: number; + readonly verticalSliderSize: number; + readonly mouseWheelScrollSensitivity: number; } export class EditorWrappingInfo { - _editorWrappingInfoBrand: void; - isViewportWrapping: boolean; - wrappingColumn: number; - wrappingIndent: WrappingIndent; - wordWrapBreakBeforeCharacters: string; - wordWrapBreakAfterCharacters: string; - wordWrapBreakObtrusiveCharacters: string; + readonly _editorWrappingInfoBrand: void; + readonly isViewportWrapping: boolean; + readonly wrappingColumn: number; + readonly wrappingIndent: WrappingIndent; + readonly wordWrapBreakBeforeCharacters: string; + readonly wordWrapBreakAfterCharacters: string; + readonly wordWrapBreakObtrusiveCharacters: string; } export class InternalEditorViewOptions { - _internalEditorViewOptionsBrand: void; - theme: string; - canUseTranslate3d: boolean; - experimentalScreenReader: boolean; - rulers: number[]; - ariaLabel: string; - renderLineNumbers: boolean; - renderCustomLineNumbers: (lineNumber: number) => string; - renderRelativeLineNumbers: boolean; - selectOnLineNumbers: boolean; - glyphMargin: boolean; - revealHorizontalRightPadding: number; - roundedSelection: boolean; - overviewRulerLanes: number; - cursorBlinking: TextEditorCursorBlinkingStyle; - mouseWheelZoom: boolean; - cursorStyle: TextEditorCursorStyle; - hideCursorInOverviewRuler: boolean; - scrollBeyondLastLine: boolean; - editorClassName: string; - stopRenderingLineAfter: number; - renderWhitespace: 'none' | 'boundary' | 'all'; - renderControlCharacters: boolean; - renderIndentGuides: boolean; - renderLineHighlight: boolean; - scrollbar: InternalEditorScrollbarOptions; + readonly _internalEditorViewOptionsBrand: void; + readonly theme: string; + readonly canUseTranslate3d: boolean; + readonly experimentalScreenReader: boolean; + readonly rulers: number[]; + readonly ariaLabel: string; + readonly renderLineNumbers: boolean; + readonly renderCustomLineNumbers: (lineNumber: number) => string; + readonly renderRelativeLineNumbers: boolean; + readonly selectOnLineNumbers: boolean; + readonly glyphMargin: boolean; + readonly revealHorizontalRightPadding: number; + readonly roundedSelection: boolean; + readonly overviewRulerLanes: number; + readonly cursorBlinking: TextEditorCursorBlinkingStyle; + readonly mouseWheelZoom: boolean; + readonly cursorStyle: TextEditorCursorStyle; + readonly hideCursorInOverviewRuler: boolean; + readonly scrollBeyondLastLine: boolean; + readonly editorClassName: string; + readonly stopRenderingLineAfter: number; + readonly renderWhitespace: 'none' | 'boundary' | 'all'; + readonly renderControlCharacters: boolean; + readonly renderIndentGuides: boolean; + readonly renderLineHighlight: boolean; + readonly scrollbar: InternalEditorScrollbarOptions; } export interface IViewConfigurationChangedEvent { - theme: boolean; - canUseTranslate3d: boolean; - experimentalScreenReader: boolean; - rulers: boolean; - ariaLabel: boolean; - renderLineNumbers: boolean; - renderCustomLineNumbers: boolean; - renderRelativeLineNumbers: boolean; - selectOnLineNumbers: boolean; - glyphMargin: boolean; - revealHorizontalRightPadding: boolean; - roundedSelection: boolean; - overviewRulerLanes: boolean; - cursorBlinking: boolean; - mouseWheelZoom: boolean; - cursorStyle: boolean; - hideCursorInOverviewRuler: boolean; - scrollBeyondLastLine: boolean; - editorClassName: boolean; - stopRenderingLineAfter: boolean; - renderWhitespace: boolean; - renderControlCharacters: boolean; - renderIndentGuides: boolean; - renderLineHighlight: boolean; - scrollbar: boolean; + readonly theme: boolean; + readonly canUseTranslate3d: boolean; + readonly experimentalScreenReader: boolean; + readonly rulers: boolean; + readonly ariaLabel: boolean; + readonly renderLineNumbers: boolean; + readonly renderCustomLineNumbers: boolean; + readonly renderRelativeLineNumbers: boolean; + readonly selectOnLineNumbers: boolean; + readonly glyphMargin: boolean; + readonly revealHorizontalRightPadding: boolean; + readonly roundedSelection: boolean; + readonly overviewRulerLanes: boolean; + readonly cursorBlinking: boolean; + readonly mouseWheelZoom: boolean; + readonly cursorStyle: boolean; + readonly hideCursorInOverviewRuler: boolean; + readonly scrollBeyondLastLine: boolean; + readonly editorClassName: boolean; + readonly stopRenderingLineAfter: boolean; + readonly renderWhitespace: boolean; + readonly renderControlCharacters: boolean; + readonly renderIndentGuides: boolean; + readonly renderLineHighlight: boolean; + readonly scrollbar: boolean; } export class EditorContribOptions { - selectionClipboard: boolean; - hover: boolean; - contextmenu: boolean; - quickSuggestions: boolean; - quickSuggestionsDelay: number; - parameterHints: boolean; - iconsInSuggestions: boolean; - formatOnType: boolean; - suggestOnTriggerCharacters: boolean; - acceptSuggestionOnEnter: boolean; - snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; - tabCompletion: boolean; - wordBasedSuggestions: boolean; - suggestFontSize: number; - suggestLineHeight: number; - selectionHighlight: boolean; - codeLens: boolean; - folding: boolean; + readonly selectionClipboard: boolean; + readonly hover: boolean; + readonly contextmenu: boolean; + readonly quickSuggestions: boolean; + readonly quickSuggestionsDelay: number; + readonly parameterHints: boolean; + readonly iconsInSuggestions: boolean; + readonly formatOnType: boolean; + readonly suggestOnTriggerCharacters: boolean; + readonly acceptSuggestionOnEnter: boolean; + readonly snippetSuggestions: 'top' | 'bottom' | 'inline' | 'none'; + readonly tabCompletion: boolean; + readonly wordBasedSuggestions: boolean; + readonly suggestFontSize: number; + readonly suggestLineHeight: number; + readonly selectionHighlight: boolean; + readonly codeLens: boolean; + readonly folding: boolean; } /** * Internal configuration options (transformed or computed) for the editor. */ export class InternalEditorOptions { - _internalEditorOptionsBrand: void; - lineHeight: number; - readOnly: boolean; - wordSeparators: string; - autoClosingBrackets: boolean; - useTabStops: boolean; - tabFocusMode: boolean; - layoutInfo: EditorLayoutInfo; - fontInfo: FontInfo; - viewInfo: InternalEditorViewOptions; - wrappingInfo: EditorWrappingInfo; - contribInfo: EditorContribOptions; + readonly _internalEditorOptionsBrand: void; + readonly lineHeight: number; + readonly readOnly: boolean; + readonly wordSeparators: string; + readonly autoClosingBrackets: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; + readonly layoutInfo: EditorLayoutInfo; + readonly fontInfo: FontInfo; + readonly viewInfo: InternalEditorViewOptions; + readonly wrappingInfo: EditorWrappingInfo; + readonly contribInfo: EditorContribOptions; } /** * An event describing that the configuration of the editor has changed. */ export interface IConfigurationChangedEvent { - lineHeight: boolean; - readOnly: boolean; - wordSeparators: boolean; - autoClosingBrackets: boolean; - useTabStops: boolean; - tabFocusMode: boolean; - layoutInfo: boolean; - fontInfo: boolean; - viewInfo: IViewConfigurationChangedEvent; - wrappingInfo: boolean; - contribInfo: boolean; + readonly lineHeight: boolean; + readonly readOnly: boolean; + readonly wordSeparators: boolean; + readonly autoClosingBrackets: boolean; + readonly useTabStops: boolean; + readonly tabFocusMode: boolean; + readonly layoutInfo: boolean; + readonly fontInfo: boolean; + readonly viewInfo: IViewConfigurationChangedEvent; + readonly wrappingInfo: boolean; + readonly contribInfo: boolean; } /** @@ -1616,19 +1606,19 @@ declare module monaco.editor { /** * Identifier for a decoration. */ - id: string; + readonly id: string; /** * Identifier for a decoration's owener. */ - ownerId: number; + readonly ownerId: number; /** * Range that this decoration covers. */ - range: Range; + readonly range: Range; /** * Options associated with this decoration. */ - options: IModelDecorationOptions; + readonly options: IModelDecorationOptions; } /** @@ -1638,15 +1628,15 @@ declare module monaco.editor { /** * The word. */ - word: string; + readonly word: string; /** * The column where the word starts. */ - startColumn: number; + readonly startColumn: number; /** * The column where the word ends. */ - endColumn: number; + readonly endColumn: number; } /** @@ -1824,11 +1814,12 @@ declare module monaco.editor { (inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[]; } - export interface ITextModelResolvedOptions { - tabSize: number; - insertSpaces: boolean; - defaultEOL: DefaultEndOfLine; - trimAutoWhitespace: boolean; + export class TextModelResolvedOptions { + _textModelResolvedOptionsBrand: void; + readonly tabSize: number; + readonly insertSpaces: boolean; + readonly defaultEOL: DefaultEndOfLine; + readonly trimAutoWhitespace: boolean; } export interface ITextModelUpdateOptions { @@ -1838,16 +1829,16 @@ declare module monaco.editor { } export interface IModelOptionsChangedEvent { - tabSize: boolean; - insertSpaces: boolean; - trimAutoWhitespace: boolean; + readonly tabSize: boolean; + readonly insertSpaces: boolean; + readonly trimAutoWhitespace: boolean; } /** * A textual read-only model. */ export interface ITextModel { - getOptions(): ITextModelResolvedOptions; + getOptions(): TextModelResolvedOptions; /** * Get the current version id of the model. * Anytime a change happens to the model (even undo/redo), @@ -2030,7 +2021,7 @@ declare module monaco.editor { /** * Gets the resource associated with this editor model. */ - uri: Uri; + readonly uri: Uri; /** * Get the language associated with this model. */ @@ -2238,7 +2229,7 @@ declare module monaco.editor { /** * A unique identifier associated with this model. */ - id: string; + readonly id: string; /** * Destroy this model. This will unbind the model from the mode * and make all necessary clean-up to release this object to the GC. @@ -2253,11 +2244,11 @@ declare module monaco.editor { /** * Previous mode */ - oldMode: languages.IMode; + readonly oldMode: languages.IMode; /** * New mode */ - newMode: languages.IMode; + readonly newMode: languages.IMode; } /** @@ -2267,19 +2258,19 @@ declare module monaco.editor { /** * The range that got replaced. */ - range: IRange; + readonly range: IRange; /** * The length of the range that got replaced. */ - rangeLength: number; + readonly rangeLength: number; /** * The new text for the range. */ - text: string; + readonly text: string; /** * The (new) end-of-line character. */ - eol: string; + readonly eol: string; /** * The new version id the model has transitioned to. */ @@ -2287,11 +2278,11 @@ declare module monaco.editor { /** * Flag that indicates that this event was generated while undoing. */ - isUndoing: boolean; + readonly isUndoing: boolean; /** * Flag that indicates that this event was generated while redoing. */ - isRedoing: boolean; + readonly isRedoing: boolean; } /** @@ -2301,23 +2292,28 @@ declare module monaco.editor { /** * The entire text length. */ - length: number; + readonly length: number; /** * The text split into lines. */ - lines: string[]; + readonly lines: string[]; /** * The BOM (leading character sequence of the file). */ - BOM: string; + readonly BOM: string; /** * The end of line sequence. */ - EOL: string; + readonly EOL: string; /** * The options associated with this text. */ - options: ITextModelResolvedOptions; + readonly options: { + readonly tabSize: number; + readonly insertSpaces: boolean; + readonly defaultEOL: DefaultEndOfLine; + readonly trimAutoWhitespace: boolean; + }; } /** @@ -2327,23 +2323,23 @@ declare module monaco.editor { /** * The id of the decoration. */ - id: string; + readonly id: string; /** * The owner id of the decoration. */ - ownerId: number; + readonly ownerId: number; /** * The range of the decoration. */ - range: IRange; + readonly range: IRange; /** * A flag describing if this is a problem decoration (e.g. warning/error). */ - isForValidation: boolean; + readonly isForValidation: boolean; /** * The options for this decoration. */ - options: IModelDecorationOptions; + readonly options: IModelDecorationOptions; } /** @@ -2353,25 +2349,25 @@ declare module monaco.editor { /** * A summary with ids of decorations that have changed. */ - ids: string[]; + readonly ids: string[]; /** * Lists of details for added or changed decorations. */ - addedOrChangedDecorations: IModelDecorationsChangedEventDecorationData[]; + readonly addedOrChangedDecorations: IModelDecorationsChangedEventDecorationData[]; /** * List of ids for removed decorations. */ - removedDecorations: string[]; + readonly removedDecorations: string[]; /** * Details regarding old options. */ - oldOptions: { + readonly oldOptions: { [decorationId: string]: IModelDecorationOptions; }; /** * Details regarding old ranges. */ - oldRanges: { + readonly oldRanges: { [decorationId: string]: IRange; }; } @@ -2383,11 +2379,11 @@ declare module monaco.editor { /** * The start of the range (inclusive) */ - fromLineNumber: number; + readonly fromLineNumber: number; /** * The end of the range (inclusive) */ - toLineNumber: number; + readonly toLineNumber: number; } /** @@ -2431,31 +2427,31 @@ declare module monaco.editor { /** * Primary cursor's position. */ - position: Position; + readonly position: Position; /** * Primary cursor's view position */ - viewPosition: Position; + readonly viewPosition: Position; /** * Secondary cursors' position. */ - secondaryPositions: Position[]; + readonly secondaryPositions: Position[]; /** * Secondary cursors' view position. */ - secondaryViewPositions: Position[]; + readonly secondaryViewPositions: Position[]; /** * Reason. */ - reason: CursorChangeReason; + readonly reason: CursorChangeReason; /** * Source of the call that caused the event. */ - source: string; + readonly source: string; /** * Is the primary cursor in the editable range? */ - isInEditableRange: boolean; + readonly isInEditableRange: boolean; } /** @@ -2465,27 +2461,27 @@ declare module monaco.editor { /** * The primary selection. */ - selection: Selection; + readonly selection: Selection; /** * The primary selection in view coordinates. */ - viewSelection: Selection; + readonly viewSelection: Selection; /** * The secondary selections. */ - secondarySelections: Selection[]; + readonly secondarySelections: Selection[]; /** * The secondary selections in view coordinates. */ - secondaryViewSelections: Selection[]; + readonly secondaryViewSelections: Selection[]; /** * Source of the call that caused the event. */ - source: string; + readonly source: string; /** * Reason. */ - reason: CursorChangeReason; + readonly reason: CursorChangeReason; } /** @@ -2495,109 +2491,109 @@ declare module monaco.editor { /** * The `uri` of the previous model or null. */ - oldModelUrl: Uri; + readonly oldModelUrl: Uri; /** * The `uri` of the new model or null. */ - newModelUrl: Uri; + readonly newModelUrl: Uri; } /** * A description for the overview ruler position. */ export class OverviewRulerPosition { - _overviewRulerPositionBrand: void; + readonly _overviewRulerPositionBrand: void; /** * Width of the overview ruler */ - width: number; + readonly width: number; /** * Height of the overview ruler */ - height: number; + readonly height: number; /** * Top position for the overview ruler */ - top: number; + readonly top: number; /** * Right position for the overview ruler */ - right: number; + readonly right: number; } /** * The internal layout details of the editor. */ export class EditorLayoutInfo { - _editorLayoutInfoBrand: void; + readonly _editorLayoutInfoBrand: void; /** * Full editor width. */ - width: number; + readonly width: number; /** * Full editor height. */ - height: number; + readonly height: number; /** * Left position for the glyph margin. */ - glyphMarginLeft: number; + readonly glyphMarginLeft: number; /** * The width of the glyph margin. */ - glyphMarginWidth: number; + readonly glyphMarginWidth: number; /** * The height of the glyph margin. */ - glyphMarginHeight: number; + readonly glyphMarginHeight: number; /** * Left position for the line numbers. */ - lineNumbersLeft: number; + readonly lineNumbersLeft: number; /** * The width of the line numbers. */ - lineNumbersWidth: number; + readonly lineNumbersWidth: number; /** * The height of the line numbers. */ - lineNumbersHeight: number; + readonly lineNumbersHeight: number; /** * Left position for the line decorations. */ - decorationsLeft: number; + readonly decorationsLeft: number; /** * The width of the line decorations. */ - decorationsWidth: number; + readonly decorationsWidth: number; /** * The height of the line decorations. */ - decorationsHeight: number; + readonly decorationsHeight: number; /** * Left position for the content (actual text) */ - contentLeft: number; + readonly contentLeft: number; /** * The width of the content (actual text) */ - contentWidth: number; + readonly contentWidth: number; /** * The height of the content (actual height) */ - contentHeight: number; + readonly contentHeight: number; /** * The width of the vertical scrollbar. */ - verticalScrollbarWidth: number; + readonly verticalScrollbarWidth: number; /** * The height of the horizontal scrollbar. */ - horizontalScrollbarHeight: number; + readonly horizontalScrollbarHeight: number; /** * The position of the overview ruler. */ - overviewRuler: OverviewRulerPosition; + readonly overviewRuler: OverviewRulerPosition; } /** @@ -2740,43 +2736,43 @@ declare module monaco.editor { * A change */ export interface IChange { - originalStartLineNumber: number; - originalEndLineNumber: number; - modifiedStartLineNumber: number; - modifiedEndLineNumber: number; + readonly originalStartLineNumber: number; + readonly originalEndLineNumber: number; + readonly modifiedStartLineNumber: number; + readonly modifiedEndLineNumber: number; } /** * A character level change. */ export interface ICharChange extends IChange { - originalStartColumn: number; - originalEndColumn: number; - modifiedStartColumn: number; - modifiedEndColumn: number; + readonly originalStartColumn: number; + readonly originalEndColumn: number; + readonly modifiedStartColumn: number; + readonly modifiedEndColumn: number; } /** * A line change */ export interface ILineChange extends IChange { - charChanges: ICharChange[]; + readonly charChanges: ICharChange[]; } export class BareFontInfo { - _bareFontInfoBrand: void; - fontFamily: string; - fontWeight: string; - fontSize: number; - lineHeight: number; + readonly _bareFontInfoBrand: void; + readonly fontFamily: string; + readonly fontWeight: string; + readonly fontSize: number; + readonly lineHeight: number; } export class FontInfo extends BareFontInfo { - _editorStylingBrand: void; - typicalHalfwidthCharacterWidth: number; - typicalFullwidthCharacterWidth: number; - spaceWidth: number; - maxDigitWidth: number; + readonly _editorStylingBrand: void; + readonly typicalHalfwidthCharacterWidth: number; + readonly typicalFullwidthCharacterWidth: number; + readonly spaceWidth: number; + readonly maxDigitWidth: number; } export interface INewScrollPosition { @@ -2822,13 +2818,13 @@ declare module monaco.editor { * Method that will be executed when the action is triggered. * @param editor The editor instance is passed in as a convinience */ - run: (editor: ICommonCodeEditor) => Promise; + run(editor: ICommonCodeEditor): void | Promise; } export interface IEditorAction { - id: string; - label: string; - alias: string; + readonly id: string; + readonly label: string; + readonly alias: string; isSupported(): boolean; run(): Promise; } @@ -3641,35 +3637,35 @@ declare module monaco.editor { /** * The target element */ - element: Element; + readonly element: Element; /** * The target type */ - type: MouseTargetType; + readonly type: MouseTargetType; /** * The 'approximate' editor position */ - position: Position; + readonly position: Position; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ - mouseColumn: number; + readonly mouseColumn: number; /** * The 'approximate' editor range */ - range: Range; + readonly range: Range; /** * Some extra detail. */ - detail: any; + readonly detail: any; } /** * A mouse event originating from the editor. */ export interface IEditorMouseEvent { - event: IMouseEvent; - target: IMouseTarget; + readonly event: IMouseEvent; + readonly target: IMouseTarget; } /** @@ -3920,7 +3916,7 @@ declare module monaco.languages { * * @readonly */ - markers: editor.IMarkerData[]; + readonly markers: editor.IMarkerData[]; } /** @@ -4793,8 +4789,8 @@ declare module monaco.worker { export interface IMirrorModel { - uri: Uri; - version: number; + readonly uri: Uri; + readonly version: number; getValue(): string; } diff --git a/src/vs/workbench/parts/git/common/stageRanges.ts b/src/vs/workbench/parts/git/common/stageRanges.ts index 9106a124d97..98805a64341 100644 --- a/src/vs/workbench/parts/git/common/stageRanges.ts +++ b/src/vs/workbench/parts/git/common/stageRanges.ts @@ -43,8 +43,8 @@ function isDeletion(change: IChange): boolean { * Returns an intersection between a change and a selection. * Returns null if intersection does not exist. */ -export function intersectChangeAndSelection(change: IChange, selection: Selection): IChange { - var result: IChange = { +export function intersectChangeAndSelection(change: IChange, selection: Selection) { + var result = { modifiedStartLineNumber: Math.max(change.modifiedStartLineNumber, selection.startLineNumber), modifiedEndLineNumber: Math.min(change.modifiedEndLineNumber, selection.endLineNumber), originalStartLineNumber: change.originalStartLineNumber, diff --git a/src/vs/workbench/parts/search/browser/openAnythingHandler.ts b/src/vs/workbench/parts/search/browser/openAnythingHandler.ts index c511cad2b1f..2f54b603ac2 100644 --- a/src/vs/workbench/parts/search/browser/openAnythingHandler.ts +++ b/src/vs/workbench/parts/search/browser/openAnythingHandler.ts @@ -267,8 +267,12 @@ export class OpenAnythingHandler extends QuickOpenHandler { if (patternMatch.length > 3) { const startColumn = parseInt(patternMatch[3], 10); if (types.isNumber(startColumn)) { - range.startColumn = startColumn; - range.endColumn = startColumn; + range = { + startLineNumber: range.startLineNumber, + startColumn: startColumn, + endLineNumber: range.endLineNumber, + endColumn: startColumn + }; } } }