diff --git a/build/monaco/monaco.d.ts.recipe b/build/monaco/monaco.d.ts.recipe index 4f560d82d55..c5418a92237 100644 --- a/build/monaco/monaco.d.ts.recipe +++ b/build/monaco/monaco.d.ts.recipe @@ -67,6 +67,7 @@ export interface ICommandHandler { #include(vs/base/common/scrollable): ScrollbarVisibility #includeAll(vs/editor/common/editorCommon;IMode=>languages.IMode;LanguageIdentifier=>languages.LanguageIdentifier;editorOptions.=>): ISelection, IScrollEvent #includeAll(vs/editor/common/model/textModelEvents): +#includeAll(vs/editor/common/controller/cursorEvents): #includeAll(vs/editor/common/config/editorOptions): #includeAll(vs/editor/browser/editorBrowser;editorCommon.=>;editorOptions.=>): #include(vs/editor/common/config/fontInfo): FontInfo, BareFontInfo diff --git a/src/vs/editor/browser/controller/keyboardHandler.ts b/src/vs/editor/browser/controller/keyboardHandler.ts index 00258d23cb5..432470e26c6 100644 --- a/src/vs/editor/browser/controller/keyboardHandler.ts +++ b/src/vs/editor/browser/controller/keyboardHandler.ts @@ -12,7 +12,6 @@ import { GlobalScreenReaderNVDA } from 'vs/editor/common/config/commonEditorConf import { TextAreaHandler } from 'vs/editor/common/controller/textAreaHandler'; import { TextAreaStrategy } from 'vs/editor/common/controller/textAreaState'; import { Range } from 'vs/editor/common/core/range'; -import * as editorCommon from 'vs/editor/common/editorCommon'; import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler'; import { IViewController } from 'vs/editor/browser/editorBrowser'; import { Configuration } from 'vs/editor/browser/config/configuration'; @@ -21,6 +20,7 @@ import { HorizontalRange } from 'vs/editor/common/view/renderingContext'; import { TextAreaWrapper } from 'vs/editor/browser/controller/input/textAreaWrapper'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { FastDomNode } from 'vs/base/browser/fastDomNode'; +import { VerticalRevealType } from "vs/editor/common/controller/cursorEvents"; export interface IKeyboardHandlerHelper { viewDomNode: FastDomNode; @@ -92,7 +92,7 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable { this._context.privateViewEventBus.emit(new viewEvents.ViewRevealRangeRequestEvent( new Range(lineNumber, column, lineNumber, column), - editorCommon.VerticalRevealType.Simple, + VerticalRevealType.Simple, true, false )); diff --git a/src/vs/editor/browser/standalone/standaloneEditor.ts b/src/vs/editor/browser/standalone/standaloneEditor.ts index 4d3756aaacd..48625b7304a 100644 --- a/src/vs/editor/browser/standalone/standaloneEditor.ts +++ b/src/vs/editor/browser/standalone/standaloneEditor.ts @@ -35,6 +35,7 @@ import { IStandaloneThemeData, IStandaloneThemeService } from 'vs/editor/common/ import { Token } from 'vs/editor/common/core/token'; import { FontInfo, BareFontInfo } from 'vs/editor/common/config/fontInfo'; import * as editorOptions from "vs/editor/common/config/editorOptions"; +import { CursorChangeReason } from "vs/editor/common/controller/cursorEvents"; /** * @internal @@ -344,7 +345,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor { DefaultEndOfLine: editorCommon.DefaultEndOfLine, EndOfLineSequence: editorCommon.EndOfLineSequence, TrackedRangeStickiness: editorCommon.TrackedRangeStickiness, - CursorChangeReason: editorCommon.CursorChangeReason, + CursorChangeReason: CursorChangeReason, MouseTargetType: MouseTargetType, TextEditorCursorStyle: editorOptions.TextEditorCursorStyle, TextEditorCursorBlinkingStyle: editorOptions.TextEditorCursorBlinkingStyle, diff --git a/src/vs/editor/browser/viewParts/lines/viewLines.ts b/src/vs/editor/browser/viewParts/lines/viewLines.ts index e530edebc37..8b216c86773 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLines.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLines.ts @@ -20,6 +20,7 @@ import { IViewLines, HorizontalRange, LineVisibleRanges } from 'vs/editor/common import { IViewLayout } from 'vs/editor/common/viewModel/viewModel'; import { ViewPart, PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPart'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; +import { VerticalRevealType } from "vs/editor/common/controller/cursorEvents"; class LastRenderedData { @@ -471,7 +472,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, } } - private _computeScrollTopToRevealRange(viewport: editorCommon.Viewport, range: Range, verticalType: editorCommon.VerticalRevealType): number { + private _computeScrollTopToRevealRange(viewport: editorCommon.Viewport, range: Range, verticalType: VerticalRevealType): number { let viewportStartY = viewport.top; let viewportHeight = viewport.height; let viewportEndY = viewportStartY + viewportHeight; @@ -481,15 +482,15 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, // Have a box that includes one extra line height (for the horizontal scrollbar) boxStartY = this._viewLayout.getVerticalOffsetForLineNumber(range.startLineNumber); boxEndY = this._viewLayout.getVerticalOffsetForLineNumber(range.endLineNumber) + this._lineHeight; - if (verticalType === editorCommon.VerticalRevealType.Simple || verticalType === editorCommon.VerticalRevealType.Bottom) { + if (verticalType === VerticalRevealType.Simple || verticalType === VerticalRevealType.Bottom) { // Reveal one line more when the last line would be covered by the scrollbar - arrow down case or revealing a line explicitly at bottom boxEndY += this._lineHeight; } let newScrollTop: number; - if (verticalType === editorCommon.VerticalRevealType.Center || verticalType === editorCommon.VerticalRevealType.CenterIfOutsideViewport) { - if (verticalType === editorCommon.VerticalRevealType.CenterIfOutsideViewport && viewportStartY <= boxStartY && boxEndY <= viewportEndY) { + if (verticalType === VerticalRevealType.Center || verticalType === VerticalRevealType.CenterIfOutsideViewport) { + if (verticalType === VerticalRevealType.CenterIfOutsideViewport && viewportStartY <= boxStartY && boxEndY <= viewportEndY) { // Box is already in the viewport... do nothing newScrollTop = viewportStartY; } else { @@ -498,7 +499,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost, newScrollTop = Math.max(0, boxMiddleY - viewportHeight / 2); } } else { - newScrollTop = this._computeMinimumScrolling(viewportStartY, viewportEndY, boxStartY, boxEndY, verticalType === editorCommon.VerticalRevealType.Top, verticalType === editorCommon.VerticalRevealType.Bottom); + newScrollTop = this._computeMinimumScrolling(viewportStartY, viewportEndY, boxStartY, boxEndY, verticalType === VerticalRevealType.Top, verticalType === VerticalRevealType.Bottom); } return newScrollTop; diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 6198ecfaec8..fdcd516c4f7 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -26,6 +26,7 @@ import { RGBA } from 'vs/base/common/color'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; import { GlobalMouseMoveMonitor, IStandardMouseMoveEventData, standardMouseMoveMerger } from 'vs/base/browser/globalMouseMoveMonitor'; import * as platform from 'vs/base/common/platform'; +import { VerticalRevealType } from "vs/editor/common/controller/cursorEvents"; const enum RenderMinimap { None = 0, @@ -484,7 +485,7 @@ export class Minimap extends ViewPart { this._context.privateViewEventBus.emit(new viewEvents.ViewRevealRangeRequestEvent( new Range(lineNumber, 1, lineNumber, 1), - editorCommon.VerticalRevealType.Center, + VerticalRevealType.Center, false, false )); diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index 1e4ace2c55e..74bd87bb288 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -13,7 +13,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { IContextKey, IContextKeyServiceTarget, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { CommonEditorConfiguration } from 'vs/editor/common/config/commonEditorConfig'; import { DefaultConfig } from 'vs/editor/common/config/defaultConfig'; -import { Cursor, CursorEventType } from 'vs/editor/common/controller/cursor'; +import { Cursor } from 'vs/editor/common/controller/cursor'; import { CursorColumns } from 'vs/editor/common/controller/cursorCommon'; import { IViewModelHelper } from 'vs/editor/common/controller/oneCursor'; import { EditorState } from 'vs/editor/common/core/editorState'; @@ -31,6 +31,7 @@ import { IModelLanguageChangedEvent, IModelOptionsChangedEvent, TextModelEventType } from 'vs/editor/common/model/textModelEvents'; import * as editorOptions from "vs/editor/common/config/editorOptions"; +import { CursorEventType, ICursorPositionChangedEvent, VerticalRevealType, ICursorSelectionChangedEvent, ICursorRevealRangeEvent } from "vs/editor/common/controller/cursorEvents"; import EditorContextKeys = editorCommon.EditorContextKeys; @@ -59,11 +60,11 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo protected readonly _onDidChangeModel: Emitter = this._register(new Emitter()); public readonly onDidChangeModel: Event = this._onDidChangeModel.event; - private readonly _onDidChangeCursorPosition: Emitter = this._register(new Emitter()); - public readonly onDidChangeCursorPosition: Event = this._onDidChangeCursorPosition.event; + private readonly _onDidChangeCursorPosition: Emitter = this._register(new Emitter()); + public readonly onDidChangeCursorPosition: Event = this._onDidChangeCursorPosition.event; - private readonly _onDidChangeCursorSelection: Emitter = this._register(new Emitter()); - public readonly onDidChangeCursorSelection: Event = this._onDidChangeCursorSelection.event; + private readonly _onDidChangeCursorSelection: Emitter = this._register(new Emitter()); + public readonly onDidChangeCursorSelection: Event = this._onDidChangeCursorSelection.event; private readonly _onDidLayoutChange: Emitter = this._register(new Emitter()); public readonly onDidLayoutChange: Event = this._onDidLayoutChange.event; @@ -299,7 +300,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo } } - private _sendRevealRange(range: Range, verticalType: editorCommon.VerticalRevealType, revealHorizontal: boolean): void { + private _sendRevealRange(range: Range, verticalType: VerticalRevealType, revealHorizontal: boolean): void { if (!this.model || !this.cursor) { return; } @@ -308,7 +309,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo } let validatedRange = this.model.validateRange(range); - let revealRangeEvent: editorCommon.ICursorRevealRangeEvent = { + let revealRangeEvent: ICursorRevealRangeEvent = { range: validatedRange, viewRange: null, verticalType: verticalType, @@ -319,18 +320,18 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo } public revealLine(lineNumber: number): void { - this._revealLine(lineNumber, editorCommon.VerticalRevealType.Simple); + this._revealLine(lineNumber, VerticalRevealType.Simple); } public revealLineInCenter(lineNumber: number): void { - this._revealLine(lineNumber, editorCommon.VerticalRevealType.Center); + this._revealLine(lineNumber, VerticalRevealType.Center); } public revealLineInCenterIfOutsideViewport(lineNumber: number): void { - this._revealLine(lineNumber, editorCommon.VerticalRevealType.CenterIfOutsideViewport); + this._revealLine(lineNumber, VerticalRevealType.CenterIfOutsideViewport); } - private _revealLine(lineNumber: number, revealType: editorCommon.VerticalRevealType): void { + private _revealLine(lineNumber: number, revealType: VerticalRevealType): void { if (typeof lineNumber !== 'number') { throw new Error('Invalid arguments'); } @@ -345,7 +346,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo public revealPosition(position: IPosition, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = false): void { this._revealPosition( position, - revealVerticalInCenter ? editorCommon.VerticalRevealType.Center : editorCommon.VerticalRevealType.Simple, + revealVerticalInCenter ? VerticalRevealType.Center : VerticalRevealType.Simple, revealHorizontal ); } @@ -353,7 +354,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo public revealPositionInCenter(position: IPosition): void { this._revealPosition( position, - editorCommon.VerticalRevealType.Center, + VerticalRevealType.Center, true ); } @@ -361,12 +362,12 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo public revealPositionInCenterIfOutsideViewport(position: IPosition): void { this._revealPosition( position, - editorCommon.VerticalRevealType.CenterIfOutsideViewport, + VerticalRevealType.CenterIfOutsideViewport, true ); } - private _revealPosition(position: IPosition, verticalType: editorCommon.VerticalRevealType, revealHorizontal: boolean): void { + private _revealPosition(position: IPosition, verticalType: VerticalRevealType, revealHorizontal: boolean): void { if (!Position.isIPosition(position)) { throw new Error('Invalid arguments'); } @@ -438,7 +439,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo this._revealLines( startLineNumber, endLineNumber, - editorCommon.VerticalRevealType.Simple + VerticalRevealType.Simple ); } @@ -446,7 +447,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo this._revealLines( startLineNumber, endLineNumber, - editorCommon.VerticalRevealType.Center + VerticalRevealType.Center ); } @@ -454,11 +455,11 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo this._revealLines( startLineNumber, endLineNumber, - editorCommon.VerticalRevealType.CenterIfOutsideViewport + VerticalRevealType.CenterIfOutsideViewport ); } - private _revealLines(startLineNumber: number, endLineNumber: number, verticalType: editorCommon.VerticalRevealType): void { + private _revealLines(startLineNumber: number, endLineNumber: number, verticalType: VerticalRevealType): void { if (typeof startLineNumber !== 'number' || typeof endLineNumber !== 'number') { throw new Error('Invalid arguments'); } @@ -473,7 +474,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo public revealRange(range: IRange, revealVerticalInCenter: boolean = false, revealHorizontal: boolean = true): void { this._revealRange( range, - revealVerticalInCenter ? editorCommon.VerticalRevealType.Center : editorCommon.VerticalRevealType.Simple, + revealVerticalInCenter ? VerticalRevealType.Center : VerticalRevealType.Simple, revealHorizontal ); } @@ -481,7 +482,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo public revealRangeInCenter(range: IRange): void { this._revealRange( range, - editorCommon.VerticalRevealType.Center, + VerticalRevealType.Center, true ); } @@ -489,7 +490,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo public revealRangeInCenterIfOutsideViewport(range: IRange): void { this._revealRange( range, - editorCommon.VerticalRevealType.CenterIfOutsideViewport, + VerticalRevealType.CenterIfOutsideViewport, true ); } @@ -497,12 +498,12 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo public revealRangeAtTop(range: IRange): void { this._revealRange( range, - editorCommon.VerticalRevealType.Top, + VerticalRevealType.Top, true ); } - private _revealRange(range: IRange, verticalType: editorCommon.VerticalRevealType, revealHorizontal: boolean): void { + private _revealRange(range: IRange, verticalType: VerticalRevealType, revealHorizontal: boolean): void { if (!Range.isIRange(range)) { throw new Error('Invalid arguments'); } diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index 66da3ac45ea..7e41206d386 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -26,13 +26,7 @@ import { ColumnSelection, IColumnSelectResult } from 'vs/editor/common/controlle import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations'; import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations'; import { TextModelEventType, ModelRawContentChangedEvent, RawContentChangedType } from 'vs/editor/common/model/textModelEvents'; - -export const CursorEventType = { - CursorPositionChanged: 'positionChanged', - CursorSelectionChanged: 'selectionChanged', - CursorRevealRange: 'revealRange', - CursorScrollRequest: 'scrollRequest', -}; +import { CursorEventType, CursorChangeReason, ICursorPositionChangedEvent, VerticalRevealType, ICursorSelectionChangedEvent, ICursorRevealRangeEvent, ICursorScrollRequestEvent } from "vs/editor/common/controller/cursorEvents"; const enum RevealTarget { Primary = 0, @@ -50,7 +44,7 @@ interface IOneCursorOperationContext { } interface IMultipleCursorOperationContext { - cursorPositionChangeReason: editorCommon.CursorChangeReason; + cursorPositionChangeReason: CursorChangeReason; shouldReveal: boolean; shouldRevealVerticalInCenter: boolean; shouldRevealHorizontal: boolean; @@ -277,8 +271,8 @@ export class Cursor extends EventEmitter { this.cursors = new CursorCollection(this.context); - this.emitCursorPositionChanged('model', editorCommon.CursorChangeReason.ContentFlush); - this.emitCursorSelectionChanged('model', editorCommon.CursorChangeReason.ContentFlush); + this.emitCursorPositionChanged('model', CursorChangeReason.ContentFlush); + this.emitCursorSelectionChanged('model', CursorChangeReason.ContentFlush); } else { if (!this._isHandling) { // Read the markers before entering `_onHandler`, since that would validate @@ -290,7 +284,7 @@ export class Cursor extends EventEmitter { ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; var result = this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.RecoverFromMarkers; + ctx.cursorPositionChangeReason = CursorChangeReason.RecoverFromMarkers; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; ctx.shouldReveal = false; @@ -333,7 +327,7 @@ export class Cursor extends EventEmitter { private _createAndInterpretHandlerCtx(eventSource: string, eventData: any, callback: (currentHandlerCtx: IMultipleCursorOperationContext) => void): boolean { var currentHandlerCtx: IMultipleCursorOperationContext = { - cursorPositionChangeReason: editorCommon.CursorChangeReason.NotSet, + cursorPositionChangeReason: CursorChangeReason.NotSet, shouldReveal: true, shouldRevealVerticalInCenter: false, shouldRevealHorizontal: true, @@ -374,7 +368,7 @@ export class Cursor extends EventEmitter { var prevCursorsState = this.cursors.saveState(); var eventSource = source; - var cursorPositionChangeReason: editorCommon.CursorChangeReason; + var cursorPositionChangeReason: CursorChangeReason; var shouldReveal: boolean; var shouldRevealVerticalInCenter: boolean; var shouldRevealHorizontal: boolean; @@ -426,7 +420,7 @@ export class Cursor extends EventEmitter { this.emitCursorPositionChanged(eventSource, cursorPositionChangeReason); if (shouldReveal) { - this.revealRange(shouldRevealTarget, shouldRevealVerticalInCenter ? editorCommon.VerticalRevealType.Center : editorCommon.VerticalRevealType.Simple, shouldRevealHorizontal); + this.revealRange(shouldRevealTarget, shouldRevealVerticalInCenter ? VerticalRevealType.Center : VerticalRevealType.Simple, shouldRevealHorizontal); } this.emitCursorSelectionChanged(eventSource, cursorPositionChangeReason); } @@ -817,7 +811,7 @@ export class Cursor extends EventEmitter { // ----------------------------------------------------------------------------------------------------------- // ----- emitting events - private emitCursorPositionChanged(source: string, reason: editorCommon.CursorChangeReason): void { + private emitCursorPositionChanged(source: string, reason: CursorChangeReason): void { var positions = this.cursors.getPositions(); var primaryPosition = positions[0]; var secondaryPositions = positions.slice(1); @@ -833,7 +827,7 @@ export class Cursor extends EventEmitter { isInEditableRange = false; } } - var e: editorCommon.ICursorPositionChangedEvent = { + var e: ICursorPositionChangedEvent = { position: primaryPosition, viewPosition: primaryViewPosition, secondaryPositions: secondaryPositions, @@ -845,7 +839,7 @@ export class Cursor extends EventEmitter { this.emit(CursorEventType.CursorPositionChanged, e); } - private emitCursorSelectionChanged(source: string, reason: editorCommon.CursorChangeReason): void { + private emitCursorSelectionChanged(source: string, reason: CursorChangeReason): void { let selections = this.cursors.getSelections(); let primarySelection = selections[0]; let secondarySelections = selections.slice(1); @@ -854,7 +848,7 @@ export class Cursor extends EventEmitter { let primaryViewSelection = viewSelections[0]; let secondaryViewSelections = viewSelections.slice(1); - let e: editorCommon.ICursorSelectionChangedEvent = { + let e: ICursorSelectionChangedEvent = { selection: primarySelection, viewSelection: primaryViewSelection, secondarySelections: secondarySelections, @@ -866,14 +860,14 @@ export class Cursor extends EventEmitter { } private emitCursorScrollRequest(deltaLines: number, revealCursor: boolean): void { - var e: editorCommon.ICursorScrollRequestEvent = { + var e: ICursorScrollRequestEvent = { deltaLines, revealCursor }; this.emit(CursorEventType.CursorScrollRequest, e); } - private revealRange(revealTarget: RevealTarget, verticalType: editorCommon.VerticalRevealType, revealHorizontal: boolean): void { + private revealRange(revealTarget: RevealTarget, verticalType: VerticalRevealType, revealHorizontal: boolean): void { var positions = this.cursors.getPositions(); var viewPositions = this.cursors.getViewPositions(); @@ -906,8 +900,8 @@ export class Cursor extends EventEmitter { this.emitCursorRevealRange(range, viewRange, verticalType, revealHorizontal, false); } - private emitCursorRevealRange(range: Range, viewRange: Range, verticalType: editorCommon.VerticalRevealType, revealHorizontal: boolean, revealCursor: boolean) { - var e: editorCommon.ICursorRevealRangeEvent = { + private emitCursorRevealRange(range: Range, viewRange: Range, verticalType: VerticalRevealType, revealHorizontal: boolean, revealCursor: boolean) { + var e: ICursorRevealRangeEvent = { range: range, viewRange: viewRange, verticalType: verticalType, @@ -1079,7 +1073,7 @@ export class Cursor extends EventEmitter { ctx.shouldRevealVerticalInCenter = true; } if (ctx.eventSource === 'mouse') { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; } const result = OneCursorOp.moveTo(this.context, this.cursors.getPrimaryCursor(), inSelectionMode, ctx.eventData.position, ctx.eventData.viewPosition); this.cursors.setStates([result], false); @@ -1087,7 +1081,7 @@ export class Cursor extends EventEmitter { } private _cursorMove(ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; ctx.shouldReveal = true; @@ -1193,7 +1187,7 @@ export class Cursor extends EventEmitter { ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldReveal = false; ctx.shouldRevealHorizontal = false; @@ -1208,7 +1202,7 @@ export class Cursor extends EventEmitter { ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; if (ctx.eventSource === 'mouse') { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; } ctx.shouldReveal = false; ctx.shouldRevealHorizontal = false; @@ -1224,7 +1218,7 @@ export class Cursor extends EventEmitter { if (this.configuration.editor.readOnly) { return false; } - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldRevealTarget = RevealTarget.TopMost; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; @@ -1237,7 +1231,7 @@ export class Cursor extends EventEmitter { if (this.configuration.editor.readOnly) { return false; } - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldRevealTarget = RevealTarget.BottomMost; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; @@ -1283,7 +1277,7 @@ export class Cursor extends EventEmitter { } private _moveToBeginningOfLine(inSelectionMode: boolean, ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; this.cursors.setStates(OneCursorOp.moveToBeginningOfLine(this.context, this.cursors.getAll(), inSelectionMode), true); @@ -1291,7 +1285,7 @@ export class Cursor extends EventEmitter { } private _moveToEndOfLine(inSelectionMode: boolean, ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; this.cursors.setStates(OneCursorOp.moveToEndOfLine(this.context, this.cursors.getAll(), inSelectionMode), true); @@ -1299,7 +1293,7 @@ export class Cursor extends EventEmitter { } private _moveToBeginningOfBuffer(inSelectionMode: boolean, ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; this.cursors.setStates(OneCursorOp.moveToBeginningOfBuffer(this.context, this.cursors.getAll(), inSelectionMode), true); @@ -1307,7 +1301,7 @@ export class Cursor extends EventEmitter { } private _moveToEndOfBuffer(inSelectionMode: boolean, ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; this.cursors.setStates(OneCursorOp.moveToEndOfBuffer(this.context, this.cursors.getAll(), inSelectionMode), true); @@ -1327,7 +1321,7 @@ export class Cursor extends EventEmitter { private _line(inSelectionMode: boolean, ctx: IMultipleCursorOperationContext): boolean { ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldRevealHorizontal = false; const r = OneCursorOp.line(this.context, this.cursors.getPrimaryCursor(), inSelectionMode, ctx.eventData.position, ctx.eventData.viewPosition); @@ -1342,7 +1336,7 @@ export class Cursor extends EventEmitter { ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldReveal = false; ctx.shouldRevealHorizontal = false; @@ -1353,7 +1347,7 @@ export class Cursor extends EventEmitter { } private _expandLineSelection(ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; this.cursors.setStates(OneCursorOp.expandLineSelection(this.context, this.cursors.getAll()), true); @@ -1361,7 +1355,7 @@ export class Cursor extends EventEmitter { } private _word(inSelectionMode: boolean, ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; @@ -1377,7 +1371,7 @@ export class Cursor extends EventEmitter { return false; } - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Explicit; + ctx.cursorPositionChangeReason = CursorChangeReason.Explicit; ctx.shouldPushStackElementBefore = true; ctx.shouldPushStackElementAfter = true; ctx.shouldReveal = false; @@ -1537,7 +1531,7 @@ export class Cursor extends EventEmitter { private _paste(ctx: IMultipleCursorOperationContext): boolean { var distributedPaste = this._distributePasteToCursors(ctx); - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Paste; + ctx.cursorPositionChangeReason = CursorChangeReason.Paste; if (distributedPaste) { return this._applyEditForAllSorted(ctx, (cursor, cursorIndex) => TypeOperations.paste(this.context.config, this.context.model, cursor.modelState, distributedPaste[cursorIndex], false)); } else { @@ -1571,17 +1565,17 @@ export class Cursor extends EventEmitter { }); range = new Range(range.startLineNumber, range.startColumn, range.endLineNumber, this.model.getLineMaxColumn(range.endLineNumber)); - let revealAt = editorCommon.VerticalRevealType.Simple; + let revealAt = VerticalRevealType.Simple; if (revealLineArg.at) { switch (revealLineArg.at) { case RevealLineAtArgument.Top: - revealAt = editorCommon.VerticalRevealType.Top; + revealAt = VerticalRevealType.Top; break; case RevealLineAtArgument.Center: - revealAt = editorCommon.VerticalRevealType.Center; + revealAt = VerticalRevealType.Center; break; case RevealLineAtArgument.Bottom: - revealAt = editorCommon.VerticalRevealType.Bottom; + revealAt = VerticalRevealType.Bottom; break; default: break; @@ -1632,7 +1626,7 @@ export class Cursor extends EventEmitter { return false; } let range = up ? this.context.getRangeToRevealModelLinesBeforeViewPortTop(editorScrollArg.value) : this.context.getRangeToRevealModelLinesAfterViewPortBottom(editorScrollArg.value); - this.emitCursorRevealRange(range, null, up ? editorCommon.VerticalRevealType.Top : editorCommon.VerticalRevealType.Bottom, false, true); + this.emitCursorRevealRange(range, null, up ? VerticalRevealType.Top : VerticalRevealType.Bottom, false, true); return true; } @@ -1649,7 +1643,7 @@ export class Cursor extends EventEmitter { } private _undo(ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Undo; + ctx.cursorPositionChangeReason = CursorChangeReason.Undo; ctx.hasExecutedCommands = true; this._interpretCommandResult(this.model.undo()); return true; @@ -1659,14 +1653,14 @@ export class Cursor extends EventEmitter { if (this.cursorUndoStack.length === 0) { return false; } - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Undo; + ctx.cursorPositionChangeReason = CursorChangeReason.Undo; ctx.isCursorUndo = true; this.cursors.restoreState(this.cursorUndoStack.pop()); return true; } private _redo(ctx: IMultipleCursorOperationContext): boolean { - ctx.cursorPositionChangeReason = editorCommon.CursorChangeReason.Redo; + ctx.cursorPositionChangeReason = CursorChangeReason.Redo; ctx.hasExecutedCommands = true; this._interpretCommandResult(this.model.redo()); return true; diff --git a/src/vs/editor/common/controller/cursorEvents.ts b/src/vs/editor/common/controller/cursorEvents.ts new file mode 100644 index 00000000000..ae2beb7094d --- /dev/null +++ b/src/vs/editor/common/controller/cursorEvents.ts @@ -0,0 +1,159 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import { Position } from 'vs/editor/common/core/position'; +import { Range } from 'vs/editor/common/core/range'; +import { Selection } from 'vs/editor/common/core/selection'; + +/** + * @internal + */ +export const CursorEventType = { + CursorPositionChanged: 'positionChanged', + CursorSelectionChanged: 'selectionChanged', + CursorRevealRange: 'revealRange', + CursorScrollRequest: 'scrollRequest', +}; + +/** + * Describes the reason the cursor has changed its position. + */ +export enum CursorChangeReason { + /** + * Unknown or not set. + */ + NotSet = 0, + /** + * A `model.setValue()` was called. + */ + ContentFlush = 1, + /** + * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. + */ + RecoverFromMarkers = 2, + /** + * There was an explicit user gesture. + */ + Explicit = 3, + /** + * There was a Paste. + */ + Paste = 4, + /** + * There was an Undo. + */ + Undo = 5, + /** + * There was a Redo. + */ + Redo = 6, +} +/** + * An event describing that the cursor position has changed. + */ +export interface ICursorPositionChangedEvent { + /** + * Primary cursor's position. + */ + readonly position: Position; + /** + * Primary cursor's view position + */ + readonly viewPosition: Position; + /** + * Secondary cursors' position. + */ + readonly secondaryPositions: Position[]; + /** + * Secondary cursors' view position. + */ + readonly secondaryViewPositions: Position[]; + /** + * Reason. + */ + readonly reason: CursorChangeReason; + /** + * Source of the call that caused the event. + */ + readonly source: string; + /** + * Is the primary cursor in the editable range? + */ + readonly isInEditableRange: boolean; +} +/** + * An event describing that the cursor selection has changed. + */ +export interface ICursorSelectionChangedEvent { + /** + * The primary selection. + */ + readonly selection: Selection; + /** + * The primary selection in view coordinates. + */ + readonly viewSelection: Selection; + /** + * The secondary selections. + */ + readonly secondarySelections: Selection[]; + /** + * The secondary selections in view coordinates. + */ + readonly secondaryViewSelections: Selection[]; + /** + * Source of the call that caused the event. + */ + readonly source: string; + /** + * Reason. + */ + readonly reason: CursorChangeReason; +} +/** + * @internal + */ +export const enum VerticalRevealType { + Simple = 0, + Center = 1, + CenterIfOutsideViewport = 2, + Top = 3, + Bottom = 4 +} +/** + * An event describing a request to reveal a specific range in the view of the editor. + * @internal + */ +export interface ICursorRevealRangeEvent { + /** + * Range to be reavealed. + */ + readonly range: Range; + /** + * View range to be reavealed. + */ + readonly viewRange: Range; + + readonly verticalType: VerticalRevealType; + /** + * If true: there should be a horizontal & vertical revealing + * If false: there should be just a vertical revealing + */ + readonly revealHorizontal: boolean; + /** + * If true: cursor is revealed if outside viewport + */ + readonly revealCursor: boolean; +} + +/** + * @internal + */ +export interface ICursorScrollRequestEvent { + readonly deltaLines: number; + readonly revealCursor: boolean; +} diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index fc5c9654356..3ac34209245 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -23,6 +23,7 @@ import { IModelLanguageChangedEvent, IModelOptionsChangedEvent } from 'vs/editor/common/model/textModelEvents'; import * as editorOptions from "vs/editor/common/config/editorOptions"; +import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from "vs/editor/common/controller/cursorEvents"; /** * Vertical Lane in the overview ruler of the editor. @@ -1169,150 +1170,6 @@ export interface IDiffEditorModel { modified: IModel; } -/** - * Describes the reason the cursor has changed its position. - * TODO@editorCommon: MOVE - */ -export enum CursorChangeReason { - /** - * Unknown or not set. - */ - NotSet = 0, - /** - * A `model.setValue()` was called. - */ - ContentFlush = 1, - /** - * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. - */ - RecoverFromMarkers = 2, - /** - * There was an explicit user gesture. - */ - Explicit = 3, - /** - * There was a Paste. - */ - Paste = 4, - /** - * There was an Undo. - */ - Undo = 5, - /** - * There was a Redo. - */ - Redo = 6, -} -/** - * An event describing that the cursor position has changed. - * TODO@editorCommon: MOVE - */ -export interface ICursorPositionChangedEvent { - /** - * Primary cursor's position. - */ - readonly position: Position; - /** - * Primary cursor's view position - */ - readonly viewPosition: Position; - /** - * Secondary cursors' position. - */ - readonly secondaryPositions: Position[]; - /** - * Secondary cursors' view position. - */ - readonly secondaryViewPositions: Position[]; - /** - * Reason. - */ - readonly reason: CursorChangeReason; - /** - * Source of the call that caused the event. - */ - readonly source: string; - /** - * Is the primary cursor in the editable range? - */ - readonly isInEditableRange: boolean; -} -/** - * An event describing that the cursor selection has changed. - * TODO@editorCommon: MOVE - */ -export interface ICursorSelectionChangedEvent { - /** - * The primary selection. - */ - readonly selection: Selection; - /** - * The primary selection in view coordinates. - */ - readonly viewSelection: Selection; - /** - * The secondary selections. - */ - readonly secondarySelections: Selection[]; - /** - * The secondary selections in view coordinates. - */ - readonly secondaryViewSelections: Selection[]; - /** - * Source of the call that caused the event. - */ - readonly source: string; - /** - * Reason. - */ - readonly reason: CursorChangeReason; -} -/** - * @internal - * TODO@editorCommon: MOVE - */ -export const enum VerticalRevealType { - Simple = 0, - Center = 1, - CenterIfOutsideViewport = 2, - Top = 3, - Bottom = 4 -} -/** - * An event describing a request to reveal a specific range in the view of the editor. - * @internal - * TODO@editorCommon: MOVE - */ -export interface ICursorRevealRangeEvent { - /** - * Range to be reavealed. - */ - readonly range: Range; - /** - * View range to be reavealed. - */ - readonly viewRange: Range; - - readonly verticalType: VerticalRevealType; - /** - * If true: there should be a horizontal & vertical revealing - * If false: there should be just a vertical revealing - */ - readonly revealHorizontal: boolean; - /** - * If true: cursor is revealed if outside viewport - */ - readonly revealCursor: boolean; -} - -/** - * @internal - * TODO@editorCommon: MOVE - */ -export interface ICursorScrollRequestEvent { - readonly deltaLines: number; - readonly revealCursor: boolean; -} /** * An event describing that an editor has had its model reset (i.e. `editor.setModel()`). diff --git a/src/vs/editor/common/view/viewEvents.ts b/src/vs/editor/common/view/viewEvents.ts index 25be320de43..bb25bc9a375 100644 --- a/src/vs/editor/common/view/viewEvents.ts +++ b/src/vs/editor/common/view/viewEvents.ts @@ -4,12 +4,12 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { VerticalRevealType } from 'vs/editor/common/editorCommon'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; import { ScrollEvent } from 'vs/base/common/scrollable'; import { IViewConfigurationChangedEvent, IConfigurationChangedEvent } from "vs/editor/common/config/editorOptions"; +import { VerticalRevealType } from "vs/editor/common/controller/cursorEvents"; export const enum ViewEventType { ViewConfigurationChanged = 1, diff --git a/src/vs/editor/common/viewModel/viewModelCursors.ts b/src/vs/editor/common/viewModel/viewModelCursors.ts index 19e5e9697e2..37b724d9f73 100644 --- a/src/vs/editor/common/viewModel/viewModelCursors.ts +++ b/src/vs/editor/common/viewModel/viewModelCursors.ts @@ -9,6 +9,7 @@ import { Position } from 'vs/editor/common/core/position'; import { ICoordinatesConverter, ViewEventsCollector } from 'vs/editor/common/viewModel/viewModel'; import { Selection } from 'vs/editor/common/core/selection'; import * as viewEvents from 'vs/editor/common/view/viewEvents'; +import { ICursorRevealRangeEvent, ICursorScrollRequestEvent } from "vs/editor/common/controller/cursorEvents"; export interface ICursorPositionChangedEvent { readonly position: Position; @@ -71,7 +72,7 @@ export class ViewModelCursors { eventsCollector.emit(new viewEvents.ViewCursorSelectionChangedEvent(e.viewSelection, e.secondaryViewSelections)); } - public onCursorRevealRange(eventsCollector: ViewEventsCollector, e: editorCommon.ICursorRevealRangeEvent): void { + public onCursorRevealRange(eventsCollector: ViewEventsCollector, e: ICursorRevealRangeEvent): void { // Ensure event has viewRange const viewRange = ( e.viewRange @@ -111,7 +112,7 @@ export class ViewModelCursors { } } - public onCursorScrollRequest(eventsCollector: ViewEventsCollector, e: editorCommon.ICursorScrollRequestEvent): void { + public onCursorScrollRequest(eventsCollector: ViewEventsCollector, e: ICursorScrollRequestEvent): void { eventsCollector.emit(new viewEvents.ViewScrollRequestEvent(e.deltaLines, e.revealCursor)); } } diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 6757205bec3..2224b9ea846 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -21,8 +21,8 @@ import * as viewEvents from 'vs/editor/common/view/viewEvents'; import * as errors from 'vs/base/common/errors'; import { MinimapTokensColorTracker } from 'vs/editor/common/view/minimapCharRenderer'; import * as textModelEvents from 'vs/editor/common/model/textModelEvents'; -import { CursorEventType } from 'vs/editor/common/controller/cursor'; import { WrappingIndent, IConfigurationChangedEvent } from "vs/editor/common/config/editorOptions"; +import { CursorEventType, ICursorPositionChangedEvent, VerticalRevealType, ICursorSelectionChangedEvent, ICursorRevealRangeEvent, ICursorScrollRequestEvent } from "vs/editor/common/controller/cursorEvents"; const ConfigurationChanged = 'configurationChanged'; @@ -213,7 +213,7 @@ export class ViewModel implements IViewModel { // Send a reveal event to restore the centered content eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent( newCenteredViewRange, - editorCommon.VerticalRevealType.Center, + VerticalRevealType.Center, false, false )); @@ -386,23 +386,23 @@ export class ViewModel implements IViewModel { break; } case CursorEventType.CursorPositionChanged: { - const e = data; + const e = data; this.cursors.onCursorPositionChanged(eventsCollector, e); this._lastCursorPosition = e.position; break; } case CursorEventType.CursorSelectionChanged: { - const e = data; + const e = data; this.cursors.onCursorSelectionChanged(eventsCollector, e); break; } case CursorEventType.CursorRevealRange: { - const e = data; + const e = data; this.cursors.onCursorRevealRange(eventsCollector, e); break; } case CursorEventType.CursorScrollRequest: { - const e = data; + const e = data; this.cursors.onCursorScrollRequest(eventsCollector, e); break; } diff --git a/src/vs/editor/contrib/diffNavigator/common/diffNavigator.ts b/src/vs/editor/contrib/diffNavigator/common/diffNavigator.ts index 6327fbdae6f..7b71b23dc11 100644 --- a/src/vs/editor/contrib/diffNavigator/common/diffNavigator.ts +++ b/src/vs/editor/contrib/diffNavigator/common/diffNavigator.ts @@ -8,8 +8,9 @@ import * as assert from 'vs/base/common/assert'; import { EventEmitter } from 'vs/base/common/eventEmitter'; import * as objects from 'vs/base/common/objects'; import { Range } from 'vs/editor/common/core/range'; -import { ICommonDiffEditor, ICursorPositionChangedEvent, ILineChange } from 'vs/editor/common/editorCommon'; +import { ICommonDiffEditor, ILineChange } from 'vs/editor/common/editorCommon'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; interface IDiffRange { rhs: boolean; diff --git a/src/vs/editor/contrib/find/common/findController.ts b/src/vs/editor/contrib/find/common/findController.ts index 078f30d647a..0d8cf710563 100644 --- a/src/vs/editor/contrib/find/common/findController.ts +++ b/src/vs/editor/contrib/find/common/findController.ts @@ -18,6 +18,7 @@ import { FIND_IDS, FindModelBoundToEditorModel, ToggleCaseSensitiveKeybinding, T import { FindReplaceState, FindReplaceStateChangedEvent, INewFindReplaceState } from 'vs/editor/contrib/find/common/findState'; import { DocumentHighlightProviderRegistry } from 'vs/editor/common/modes'; import { RunOnceScheduler, Delayer } from 'vs/base/common/async'; +import { CursorChangeReason, ICursorSelectionChangedEvent } from "vs/editor/common/controller/cursorEvents"; import EditorContextKeys = editorCommon.EditorContextKeys; @@ -840,9 +841,9 @@ export class SelectionHighlighter extends Disposable implements editorCommon.IEd this.updateSoon = this._register(new RunOnceScheduler(() => this._update(), 300)); this.lastWordUnderCursor = null; - this._register(editor.onDidChangeCursorSelection((e: editorCommon.ICursorSelectionChangedEvent) => { + this._register(editor.onDidChangeCursorSelection((e: ICursorSelectionChangedEvent) => { if (e.selection.isEmpty()) { - if (e.reason === editorCommon.CursorChangeReason.Explicit) { + if (e.reason === CursorChangeReason.Explicit) { if (!this.lastWordUnderCursor || !this.lastWordUnderCursor.containsPosition(e.selection.getStartPosition())) { // no longer valid this.removeDecorations(); diff --git a/src/vs/editor/contrib/find/common/findModel.ts b/src/vs/editor/contrib/find/common/findModel.ts index b4c335d2719..3bf487f0c8b 100644 --- a/src/vs/editor/contrib/find/common/findModel.ts +++ b/src/vs/editor/contrib/find/common/findModel.ts @@ -19,6 +19,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { Constants } from 'vs/editor/common/core/uint'; import { SearchParams } from 'vs/editor/common/model/textModelSearch'; import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry'; +import { CursorChangeReason, ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; export const ToggleCaseSensitiveKeybinding: IKeybindings = { primary: KeyMod.Alt | KeyCode.KEY_C, @@ -86,11 +87,11 @@ export class FindModelBoundToEditorModel { this._updateDecorationsScheduler = new RunOnceScheduler(() => this.research(false), 100); this._toDispose.push(this._updateDecorationsScheduler); - this._toDispose.push(this._editor.onDidChangeCursorPosition((e: editorCommon.ICursorPositionChangedEvent) => { + this._toDispose.push(this._editor.onDidChangeCursorPosition((e: ICursorPositionChangedEvent) => { if ( - e.reason === editorCommon.CursorChangeReason.Explicit - || e.reason === editorCommon.CursorChangeReason.Undo - || e.reason === editorCommon.CursorChangeReason.Redo + e.reason === CursorChangeReason.Explicit + || e.reason === CursorChangeReason.Undo + || e.reason === CursorChangeReason.Redo ) { this._decorations.setStartPosition(this._editor.getPosition()); } diff --git a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts index ed08f3f56d1..cb45d3433e0 100644 --- a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts +++ b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts @@ -37,7 +37,7 @@ import { MessageController } from './messageController'; import * as corePosition from 'vs/editor/common/core/position'; import ModeContextKeys = editorCommon.ModeContextKeys; import EditorContextKeys = editorCommon.EditorContextKeys; - +import { ICursorSelectionChangedEvent } from "vs/editor/common/controller/cursorEvents"; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { editorActiveLinkForeground } from 'vs/platform/theme/common/colorRegistry'; @@ -411,7 +411,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC })); } - private onDidChangeCursorSelection(e: editorCommon.ICursorSelectionChangedEvent): void { + private onDidChangeCursorSelection(e: ICursorSelectionChangedEvent): void { if (e.selection && e.selection.startColumn !== e.selection.endColumn) { this.resetHandler(); // immediately stop this feature if the user starts to select (https://github.com/Microsoft/vscode/issues/7827) } diff --git a/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts b/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts index 8969cabc4bf..fd2a7268670 100644 --- a/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts +++ b/src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts @@ -17,12 +17,13 @@ import { RunOnceScheduler } from 'vs/base/common/async'; import { onUnexpectedError } from 'vs/base/common/errors'; import Event, { Emitter, chain } from 'vs/base/common/event'; import { domEvent, stop } from 'vs/base/browser/event'; -import { ICommonCodeEditor, ICursorSelectionChangedEvent } from 'vs/editor/common/editorCommon'; +import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { Context, provideSignatureHelp } from '../common/parameterHints'; import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement'; import { CharacterSet } from 'vs/editor/common/core/characterClassifier'; import { IConfigurationChangedEvent } from "vs/editor/common/config/editorOptions"; +import { ICursorSelectionChangedEvent } from "vs/editor/common/controller/cursorEvents"; const $ = dom.$; diff --git a/src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts b/src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts index 28f309c9f90..d38a8ac3e7f 100644 --- a/src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts +++ b/src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts @@ -9,12 +9,13 @@ import { clipboard } from 'electron'; import * as platform from 'vs/base/common/platform'; import { ICodeEditor, IEditorMouseEvent } from 'vs/editor/browser/editorBrowser'; import { Disposable } from 'vs/base/common/lifecycle'; -import { EndOfLinePreference, IEditorContribution, ICursorSelectionChangedEvent } from 'vs/editor/common/editorCommon'; +import { EndOfLinePreference, IEditorContribution } from 'vs/editor/common/editorCommon'; import { editorContribution } from 'vs/editor/browser/editorBrowserExtensions'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { RunOnceScheduler } from 'vs/base/common/async'; import { Range } from 'vs/editor/common/core/range'; import { IConfigurationChangedEvent } from "vs/editor/common/config/editorOptions"; +import { ICursorSelectionChangedEvent } from "vs/editor/common/controller/cursorEvents"; @editorContribution export class SelectionClipboard extends Disposable implements IEditorContribution { diff --git a/src/vs/editor/contrib/smartSelect/common/smartSelect.ts b/src/vs/editor/contrib/smartSelect/common/smartSelect.ts index fb14eaa4ff0..86f616403aa 100644 --- a/src/vs/editor/contrib/smartSelect/common/smartSelect.ts +++ b/src/vs/editor/contrib/smartSelect/common/smartSelect.ts @@ -10,9 +10,10 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { TPromise } from 'vs/base/common/winjs.base'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { Range } from 'vs/editor/common/core/range'; -import { ICommonCodeEditor, ICursorPositionChangedEvent, EditorContextKeys, IEditorContribution } from 'vs/editor/common/editorCommon'; +import { ICommonCodeEditor, EditorContextKeys, IEditorContribution } from 'vs/editor/common/editorCommon'; import { editorAction, ServicesAccessor, IActionOptions, EditorAction, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions'; import { TokenSelectionSupport, ILogicalSelectionEntry } from './tokenSelectionSupport'; +import { ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; // --- selection state machine diff --git a/src/vs/editor/contrib/snippet/common/snippetController.ts b/src/vs/editor/contrib/snippet/common/snippetController.ts index 943cc7de62c..d0b74551e54 100644 --- a/src/vs/editor/contrib/snippet/common/snippetController.ts +++ b/src/vs/editor/contrib/snippet/common/snippetController.ts @@ -18,6 +18,7 @@ import { ISnippetVariableResolver, ICodeSnippet, CodeSnippet } from './snippet'; import { SnippetVariablesResolver } from './snippetVariables'; import EditorContextKeys = editorCommon.EditorContextKeys; import { Position } from "vs/editor/common/core/position"; +import { ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; export class InsertSnippetController { @@ -177,7 +178,7 @@ export class InsertSnippetController { _highlightRange = this.model.getDecorationRange(this.highlightDecorationId); })); - this.listenersToRemove.push(this.editor.onDidChangeCursorPosition((e: editorCommon.ICursorPositionChangedEvent) => { + this.listenersToRemove.push(this.editor.onDidChangeCursorPosition((e: ICursorPositionChangedEvent) => { if (this.isFinished) { return; } diff --git a/src/vs/editor/contrib/suggest/browser/suggestModel.ts b/src/vs/editor/contrib/suggest/browser/suggestModel.ts index 36d279d017b..7b7a7e488b5 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestModel.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestModel.ts @@ -10,11 +10,12 @@ import { TimeoutTimer } from 'vs/base/common/async'; import Event, { Emitter } from 'vs/base/common/event'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { TPromise } from 'vs/base/common/winjs.base'; -import { ICommonCodeEditor, ICursorSelectionChangedEvent, CursorChangeReason, IModel, IWordAtPosition } from 'vs/editor/common/editorCommon'; +import { ICommonCodeEditor, IModel, IWordAtPosition } from 'vs/editor/common/editorCommon'; import { ISuggestSupport, SuggestRegistry, StandardTokenType } from 'vs/editor/common/modes'; import { Position } from 'vs/editor/common/core/position'; import { provideSuggestionItems, getSuggestionComparator, ISuggestionItem } from './suggest'; import { CompletionModel } from './completionModel'; +import { CursorChangeReason, ICursorSelectionChangedEvent } from "vs/editor/common/controller/cursorEvents"; export interface ICancelEvent { retrigger: boolean; diff --git a/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts index ac25f5fa657..d8550270b11 100644 --- a/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts @@ -15,9 +15,9 @@ import { CommonEditorRegistry, commonEditorContribution } from 'vs/editor/common import { DocumentHighlight, DocumentHighlightKind, DocumentHighlightProviderRegistry } from 'vs/editor/common/modes'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { Position } from 'vs/editor/common/core/position'; - import { registerColor, editorSelectionHighlight, highContrastOutline } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; +import { CursorChangeReason, ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; export const editorWordHighlight = registerColor('editorWordHighlight', { dark: '#575757B8', light: '#57575740', hc: null }, nls.localize('wordHighlight', 'Background color of a symbol during read-access, like reading a variable.')); export const editorWordHighlightStrong = registerColor('editorWordHighlightStrong', { dark: '#004972B8', light: '#0e639c40', hc: null }, nls.localize('wordHighlightStrong', 'Background color of a symbol during write-access, like writing to a variable.')); @@ -76,7 +76,7 @@ class WordHighlighter { this.occurrencesHighlight = this.editor.getConfiguration().contribInfo.occurrencesHighlight; this.model = this.editor.getModel(); this.toUnhook = []; - this.toUnhook.push(editor.onDidChangeCursorPosition((e: editorCommon.ICursorPositionChangedEvent) => { + this.toUnhook.push(editor.onDidChangeCursorPosition((e: ICursorPositionChangedEvent) => { this._onPositionChanged(e); })); this.toUnhook.push(editor.onDidChangeModel((e) => { @@ -136,7 +136,7 @@ class WordHighlighter { } } - private _onPositionChanged(e: editorCommon.ICursorPositionChangedEvent): void { + private _onPositionChanged(e: ICursorPositionChangedEvent): void { // disabled if (!this.occurrencesHighlight) { @@ -145,7 +145,7 @@ class WordHighlighter { } // ignore typing & other - if (e.reason !== editorCommon.CursorChangeReason.Explicit) { + if (e.reason !== CursorChangeReason.Explicit) { this._stopAll(); return; } diff --git a/src/vs/editor/test/common/controller/cursor.test.ts b/src/vs/editor/test/common/controller/cursor.test.ts index e58754a64b1..80def9dce8e 100644 --- a/src/vs/editor/test/common/controller/cursor.test.ts +++ b/src/vs/editor/test/common/controller/cursor.test.ts @@ -5,7 +5,7 @@ 'use strict'; import * as assert from 'assert'; -import { Cursor, CursorEventType } from 'vs/editor/common/controller/cursor'; +import { Cursor } from 'vs/editor/common/controller/cursor'; import { EditOperation } from 'vs/editor/common/core/editOperation'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; @@ -13,8 +13,7 @@ import { Selection } from 'vs/editor/common/core/selection'; import { EndOfLinePreference, Handler, DefaultEndOfLine, ITextModelCreationOptions, ICommand, - ITokenizedModel, IEditOperationBuilder, ICursorStateComputerData, - ICursorPositionChangedEvent, ICursorSelectionChangedEvent + ITokenizedModel, IEditOperationBuilder, ICursorStateComputerData } from 'vs/editor/common/editorCommon'; import { Model } from 'vs/editor/common/model/model'; import { IndentAction, IndentationRule } from 'vs/editor/common/modes/languageConfiguration'; @@ -24,6 +23,7 @@ import { MockMode } from 'vs/editor/test/common/mocks/mockMode'; import { LanguageIdentifier } from 'vs/editor/common/modes'; import { viewModelHelper } from 'vs/editor/test/common/editorTestUtils'; import { IEditorOptions } from "vs/editor/common/config/editorOptions"; +import { CursorEventType, ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from "vs/editor/common/controller/cursorEvents"; let H = Handler; diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 2ece1d4d7dd..5f4e52b44b7 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1764,107 +1764,6 @@ declare module monaco.editor { modified: IModel; } - /** - * Describes the reason the cursor has changed its position. - * TODO@editorCommon: MOVE - */ - export enum CursorChangeReason { - /** - * Unknown or not set. - */ - NotSet = 0, - /** - * A `model.setValue()` was called. - */ - ContentFlush = 1, - /** - * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. - */ - RecoverFromMarkers = 2, - /** - * There was an explicit user gesture. - */ - Explicit = 3, - /** - * There was a Paste. - */ - Paste = 4, - /** - * There was an Undo. - */ - Undo = 5, - /** - * There was a Redo. - */ - Redo = 6, - } - - /** - * An event describing that the cursor position has changed. - * TODO@editorCommon: MOVE - */ - export interface ICursorPositionChangedEvent { - /** - * Primary cursor's position. - */ - readonly position: Position; - /** - * Primary cursor's view position - */ - readonly viewPosition: Position; - /** - * Secondary cursors' position. - */ - readonly secondaryPositions: Position[]; - /** - * Secondary cursors' view position. - */ - readonly secondaryViewPositions: Position[]; - /** - * Reason. - */ - readonly reason: CursorChangeReason; - /** - * Source of the call that caused the event. - */ - readonly source: string; - /** - * Is the primary cursor in the editable range? - */ - readonly isInEditableRange: boolean; - } - - /** - * An event describing that the cursor selection has changed. - * TODO@editorCommon: MOVE - */ - export interface ICursorSelectionChangedEvent { - /** - * The primary selection. - */ - readonly selection: Selection; - /** - * The primary selection in view coordinates. - */ - readonly viewSelection: Selection; - /** - * The secondary selections. - */ - readonly secondarySelections: Selection[]; - /** - * The secondary selections in view coordinates. - */ - readonly secondaryViewSelections: Selection[]; - /** - * Source of the call that caused the event. - */ - readonly source: string; - /** - * Reason. - */ - readonly reason: CursorChangeReason; - } - /** * An event describing that an editor has had its model reset (i.e. `editor.setModel()`). */ @@ -2619,6 +2518,104 @@ declare module monaco.editor { readonly trimAutoWhitespace: boolean; } + /** + * Describes the reason the cursor has changed its position. + */ + export enum CursorChangeReason { + /** + * Unknown or not set. + */ + NotSet = 0, + /** + * A `model.setValue()` was called. + */ + ContentFlush = 1, + /** + * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers. + */ + RecoverFromMarkers = 2, + /** + * There was an explicit user gesture. + */ + Explicit = 3, + /** + * There was a Paste. + */ + Paste = 4, + /** + * There was an Undo. + */ + Undo = 5, + /** + * There was a Redo. + */ + Redo = 6, + } + + /** + * An event describing that the cursor position has changed. + */ + export interface ICursorPositionChangedEvent { + /** + * Primary cursor's position. + */ + readonly position: Position; + /** + * Primary cursor's view position + */ + readonly viewPosition: Position; + /** + * Secondary cursors' position. + */ + readonly secondaryPositions: Position[]; + /** + * Secondary cursors' view position. + */ + readonly secondaryViewPositions: Position[]; + /** + * Reason. + */ + readonly reason: CursorChangeReason; + /** + * Source of the call that caused the event. + */ + readonly source: string; + /** + * Is the primary cursor in the editable range? + */ + readonly isInEditableRange: boolean; + } + + /** + * An event describing that the cursor selection has changed. + */ + export interface ICursorSelectionChangedEvent { + /** + * The primary selection. + */ + readonly selection: Selection; + /** + * The primary selection in view coordinates. + */ + readonly viewSelection: Selection; + /** + * The secondary selections. + */ + readonly secondarySelections: Selection[]; + /** + * The secondary selections in view coordinates. + */ + readonly secondaryViewSelections: Selection[]; + /** + * Source of the call that caused the event. + */ + readonly source: string; + /** + * Reason. + */ + readonly reason: CursorChangeReason; + } + /** * Configuration options for editor scrollbars */ diff --git a/src/vs/workbench/api/node/mainThreadEditor.ts b/src/vs/workbench/api/node/mainThreadEditor.ts index 620b2f0da7e..3a999991b35 100644 --- a/src/vs/workbench/api/node/mainThreadEditor.ts +++ b/src/vs/workbench/api/node/mainThreadEditor.ts @@ -14,6 +14,7 @@ import { Selection, ISelection } from 'vs/editor/common/core/selection'; import { SnippetController } from 'vs/editor/contrib/snippet/common/snippetController'; import { EndOfLine, TextEditorLineNumbersStyle } from 'vs/workbench/api/node/extHostTypes'; import { TextEditorCursorStyle, cursorStyleToString } from "vs/editor/common/config/editorOptions"; +import { ICursorSelectionChangedEvent } from "vs/editor/common/controller/cursorEvents"; export interface ITextEditorConfigurationUpdate { tabSize?: number | 'auto'; @@ -152,7 +153,7 @@ export class MainThreadTextEditor { this.setCodeEditor(null); })); - let forwardSelection = (event?: EditorCommon.ICursorSelectionChangedEvent) => { + let forwardSelection = (event?: ICursorSelectionChangedEvent) => { this._lastSelection = this._codeEditor.getSelections(); this._onSelectionChanged.fire({ selections: this._lastSelection, diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 05ce6105eea..42033406782 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -24,7 +24,7 @@ import { IDisposable, combinedDisposable, dispose } from 'vs/base/common/lifecyc import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing'; -import { IEditorAction, ICommonCodeEditor, ICursorPositionChangedEvent, EndOfLineSequence, IModel } from 'vs/editor/common/editorCommon'; +import { IEditorAction, ICommonCodeEditor, EndOfLineSequence, IModel } from 'vs/editor/common/editorCommon'; import { IModelLanguageChangedEvent, IModelOptionsChangedEvent } from 'vs/editor/common/model/textModelEvents'; import { TrimTrailingWhitespaceAction } from 'vs/editor/contrib/linesOperations/common/linesOperations'; import { IndentUsingSpaces, IndentUsingTabs, DetectIndentation, IndentationToSpacesAction, IndentationToTabsAction } from 'vs/editor/contrib/indentation/common/indentation'; @@ -46,6 +46,7 @@ import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { getCodeEditor as getEditorWidget } from 'vs/editor/common/services/codeEditorService'; import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences'; +import { ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; function toEditorWithEncodingSupport(input: IEditorInput): IEncodingSupport { if (input instanceof SideBySideEditorInput) { diff --git a/src/vs/workbench/common/editor/rangeDecorations.ts b/src/vs/workbench/common/editor/rangeDecorations.ts index 61e3a69b8ed..f4ac981f33c 100644 --- a/src/vs/workbench/common/editor/rangeDecorations.ts +++ b/src/vs/workbench/common/editor/rangeDecorations.ts @@ -11,6 +11,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { toResource } from 'vs/workbench/common/editor'; import { isEqual } from 'vs/platform/files/common/files'; import { IRange } from "vs/editor/common/core/range"; +import { CursorChangeReason, ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; export interface IRangeHighlightDecoration { resource: URI; @@ -67,12 +68,12 @@ export class RangeHighlightDecorations implements IDisposable { if (this.editor !== editor) { this.disposeEditorListeners(); this.editor = editor; - this.editorDisposables.push(this.editor.onDidChangeCursorPosition((e: editorCommon.ICursorPositionChangedEvent) => { + this.editorDisposables.push(this.editor.onDidChangeCursorPosition((e: ICursorPositionChangedEvent) => { if ( - e.reason === editorCommon.CursorChangeReason.NotSet - || e.reason === editorCommon.CursorChangeReason.Explicit - || e.reason === editorCommon.CursorChangeReason.Undo - || e.reason === editorCommon.CursorChangeReason.Redo + e.reason === CursorChangeReason.NotSet + || e.reason === CursorChangeReason.Explicit + || e.reason === CursorChangeReason.Undo + || e.reason === CursorChangeReason.Redo ) { this.removeHighlightRange(); } diff --git a/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts b/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts index 9a0a5285135..9eac268f0e3 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts @@ -31,6 +31,7 @@ import { IMarkerService, IMarkerData } from 'vs/platform/markers/common/markers' import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration'; import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; export interface IPreferencesRenderer extends IDisposable { preferencesModel: IPreferencesEditorModel; @@ -675,7 +676,7 @@ class EditSettingRenderer extends Disposable { } } - private onPositionChanged(positionChangeEvent: editorCommon.ICursorPositionChangedEvent) { + private onPositionChanged(positionChangeEvent: ICursorPositionChangedEvent) { this.editPreferenceWidgetForMouseMove.hide(); const settings = this.getSettings(positionChangeEvent.position.lineNumber); if (settings.length) { diff --git a/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts index ac1f9a3ef4f..74d0b857f8e 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts @@ -26,6 +26,7 @@ import { Action } from 'vs/base/common/actions'; import { attachInputBoxStyler } from 'vs/platform/theme/common/styler'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { Position } from "vs/editor/common/core/position"; +import { ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; export class SettingsGroupTitleWidget extends Widget implements IViewZone { @@ -154,7 +155,7 @@ export class SettingsGroupTitleWidget extends Widget implements IViewZone { } } - private onCursorChange(e: editorCommon.ICursorPositionChangedEvent): void { + private onCursorChange(e: ICursorPositionChangedEvent): void { if (e.source !== 'mouse' && this.focusTitle(e.position)) { this.titleContainer.focus(); } diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index 47074728c5d..422fc3faa8e 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import errors = require('vs/base/common/errors'); import objects = require('vs/base/common/objects'); import URI from 'vs/base/common/uri'; -import { ICursorPositionChangedEvent, IEditor } from 'vs/editor/common/editorCommon'; +import { IEditor } from 'vs/editor/common/editorCommon'; import { IEditor as IBaseEditor, IEditorInput, ITextEditorOptions, IResourceInput } from 'vs/platform/editor/common/editor'; import { EditorInput, IGroupEvent, IEditorRegistry, Extensions, toResource, IEditorGroup } from 'vs/workbench/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; @@ -28,6 +28,7 @@ import { IWindowService } from 'vs/platform/windows/common/windows'; import { getCodeEditor } from 'vs/editor/common/services/codeEditorService'; import { getExcludes, ISearchConfiguration } from 'vs/platform/search/common/search'; import { ParsedExpression, parse, IExpression } from 'vs/base/common/glob'; +import { ICursorPositionChangedEvent } from "vs/editor/common/controller/cursorEvents"; /** * Stores the selection & view state of an editor and allows to compare it to other selection states.