diff --git a/src/vs/editor/browser/controller/coreCommands.ts b/src/vs/editor/browser/controller/coreCommands.ts index 6b28b324b2fc5eff9c7e58d1229af5c4b4aae8f5..ab5cfc199a5465b25bc5c90845674f710adf4c82 100644 --- a/src/vs/editor/browser/controller/coreCommands.ts +++ b/src/vs/editor/browser/controller/coreCommands.ts @@ -10,7 +10,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { Command, EditorCommand, ICommandOptions, registerEditorCommand } from 'vs/editor/browser/editorExtensions'; import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; import { ColumnSelection, IColumnSelectResult } from 'vs/editor/common/controller/cursorColumnSelection'; -import { CursorContext, CursorState, EditOperationType, IColumnSelectData, ICursors, PartialCursorState, RevealTarget } from 'vs/editor/common/controller/cursorCommon'; +import { CursorContext, CursorState, EditOperationType, IColumnSelectData, ICursors, PartialCursorState } from 'vs/editor/common/controller/cursorCommon'; import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations'; import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { CursorMove as CursorMove_, CursorMoveCommands } from 'vs/editor/common/controller/cursorMoveCommands'; @@ -31,19 +31,6 @@ import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; const CORE_WEIGHT = KeybindingWeight.EditorCore; export abstract class CoreEditorCommand extends EditorCommand { - public runEditorCommand(accessor: ServicesAccessor | null, editor: ICodeEditor, args: any): void { - const cursors = editor._getCursors(); - if (!cursors) { - // the editor has no view => has no cursors - return; - } - this.runCoreEditorCommand(cursors, args || {}); - } - - public abstract runCoreEditorCommand(cursors: ICursors, args: any): void; -} - -export abstract class CoreEditorCommand2 extends EditorCommand { public runEditorCommand(accessor: ServicesAccessor | null, editor: ICodeEditor, args: any): void { const cursors = editor._getCursors(); const viewModel = editor._getViewModel(); @@ -301,16 +288,16 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, [ CursorMoveCommands.moveTo(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position, args.viewPosition) ] ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } } @@ -327,10 +314,10 @@ export namespace CoreNavigationCommands { })); abstract class ColumnSelectCommand extends CoreEditorCommand { - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); const result = this._getColumnSelectResult(cursors.context, cursors.getPrimaryCursor(), cursors.getColumnSelectData(), args); - cursors.setStates(args.source, CursorChangeReason.Explicit, result.viewStates.map((viewState) => CursorState.fromViewState(viewState))); + viewModel.setCursorStates(args.source, CursorChangeReason.Explicit, result.viewStates.map((viewState) => CursorState.fromViewState(viewState))); cursors.setColumnSelectData({ isReal: true, fromViewLineNumber: result.fromLineNumber, @@ -338,7 +325,11 @@ export namespace CoreNavigationCommands { toViewLineNumber: result.toLineNumber, toViewVisualColumn: result.toVisualColumn }); - cursors.reveal(args.source, true, (result.reversed ? RevealTarget.TopMost : RevealTarget.BottomMost), ScrollType.Smooth); + if (result.reversed) { + viewModel.revealTopMostCursor(args.source); + } else { + viewModel.revealBottomMostCursor(args.source); + } } protected abstract _getColumnSelectResult(context: CursorContext, primary: CursorState, prevColumnSelectData: IColumnSelectData, args: any): IColumnSelectResult; @@ -479,7 +470,7 @@ export namespace CoreNavigationCommands { } })); - export class CursorMoveImpl extends CoreEditorCommand2 { + export class CursorMoveImpl extends CoreEditorCommand { constructor() { super({ id: 'cursorMove', @@ -499,12 +490,12 @@ export namespace CoreNavigationCommands { private _runCursorMove(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, source: string | null | undefined, args: CursorMove_.ParsedArguments): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( source, CursorChangeReason.Explicit, CursorMoveImpl._move(editor, viewModel, cursors.context, cursors.getAll(), args) ); - cursors.reveal(source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(source, true); } private static _move(editor: ICodeEditor, viewModel: IViewModel, context: CursorContext, cursors: CursorState[], args: CursorMove_.ParsedArguments): PartialCursorState[] | null { @@ -549,7 +540,7 @@ export namespace CoreNavigationCommands { this._staticArgs = opts.args; } - public runCoreEditorCommand(cursors: ICursors, dynamicArgs: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, dynamicArgs: any): void { let args = this._staticArgs; if (this._staticArgs.value === Constants.PAGE_SIZE_MARKER) { // -1 is a marker for page size @@ -562,12 +553,12 @@ export namespace CoreNavigationCommands { } cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( dynamicArgs.source, CursorChangeReason.Explicit, CursorMoveCommands.simpleMove(cursors.context, cursors.getAll(), args.direction, args.select, args.value, args.unit) ); - cursors.reveal(dynamicArgs.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(dynamicArgs.source, true); } } @@ -781,7 +772,7 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { const context = cursors.context; let newState: PartialCursorState; @@ -813,7 +804,7 @@ export namespace CoreNavigationCommands { states.splice(i, 1); cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, states @@ -826,7 +817,7 @@ export namespace CoreNavigationCommands { states.push(newState); cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, states @@ -842,7 +833,7 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { const context = cursors.context; const lastAddedCursorIndex = cursors.getLastAddedCursorIndex(); @@ -852,7 +843,7 @@ export namespace CoreNavigationCommands { newStates[lastAddedCursorIndex] = CursorMoveCommands.moveTo(context, states[lastAddedCursorIndex], true, args.position, args.viewPosition); cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, newStates @@ -869,14 +860,14 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, CursorMoveCommands.moveToBeginningOfLine(cursors.context, cursors.getAll(), this._inSelectionMode) ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } } @@ -913,14 +904,14 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, this._exec(cursors.context, cursors.getAll()) ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } private _exec(context: CursorContext, cursors: CursorState[]): PartialCursorState[] { @@ -967,14 +958,14 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, CursorMoveCommands.moveToEndOfLine(cursors.context, cursors.getAll(), this._inSelectionMode) ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } } @@ -1011,14 +1002,14 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, this._exec(cursors.context, cursors.getAll()) ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } private _exec(context: CursorContext, cursors: CursorState[]): PartialCursorState[] { @@ -1066,14 +1057,14 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, CursorMoveCommands.moveToBeginningOfBuffer(cursors.context, cursors.getAll(), this._inSelectionMode) ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } } @@ -1110,14 +1101,14 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, CursorMoveCommands.moveToEndOfBuffer(cursors.context, cursors.getAll(), this._inSelectionMode) ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } } @@ -1145,7 +1136,7 @@ export namespace CoreNavigationCommands { } })); - export class EditorScrollImpl extends CoreEditorCommand2 { + export class EditorScrollImpl extends CoreEditorCommand { constructor() { super({ id: 'editorScroll', @@ -1170,7 +1161,7 @@ export namespace CoreNavigationCommands { if (args.revealCursor) { // must ensure cursor is in new visible range const desiredVisibleViewRange = viewModel.getCompletelyVisibleViewRangeAtScrollTop(desiredScrollTop); - cursors.setStates( + viewModel.setCursorStates( source, CursorChangeReason.Explicit, [ @@ -1216,7 +1207,7 @@ export namespace CoreNavigationCommands { export const EditorScroll: EditorScrollImpl = registerEditorCommand(new EditorScrollImpl()); - export const ScrollLineUp: CoreEditorCommand2 = registerEditorCommand(new class extends CoreEditorCommand2 { + export const ScrollLineUp: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand { constructor() { super({ id: 'scrollLineUp', @@ -1241,7 +1232,7 @@ export namespace CoreNavigationCommands { } }); - export const ScrollPageUp: CoreEditorCommand2 = registerEditorCommand(new class extends CoreEditorCommand2 { + export const ScrollPageUp: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand { constructor() { super({ id: 'scrollPageUp', @@ -1267,7 +1258,7 @@ export namespace CoreNavigationCommands { } }); - export const ScrollLineDown: CoreEditorCommand2 = registerEditorCommand(new class extends CoreEditorCommand2 { + export const ScrollLineDown: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand { constructor() { super({ id: 'scrollLineDown', @@ -1292,7 +1283,7 @@ export namespace CoreNavigationCommands { } }); - export const ScrollPageDown: CoreEditorCommand2 = registerEditorCommand(new class extends CoreEditorCommand2 { + export const ScrollPageDown: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand { constructor() { super({ id: 'scrollPageDown', @@ -1327,16 +1318,16 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, [ CursorMoveCommands.word(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position) ] ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } } @@ -1360,7 +1351,7 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { const context = cursors.context; const lastAddedCursorIndex = cursors.getLastAddedCursorIndex(); @@ -1371,7 +1362,7 @@ export namespace CoreNavigationCommands { newStates[lastAddedCursorIndex] = CursorMoveCommands.word(context, lastAddedState, lastAddedState.modelState.hasSelection(), args.position); context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, newStates @@ -1387,16 +1378,16 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, [ CursorMoveCommands.line(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position, args.viewPosition) ] ); - cursors.reveal(args.source, false, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, false); } } @@ -1420,7 +1411,7 @@ export namespace CoreNavigationCommands { this._inSelectionMode = opts.inSelectionMode; } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { const lastAddedCursorIndex = cursors.getLastAddedCursorIndex(); const states = cursors.getAll(); @@ -1428,7 +1419,7 @@ export namespace CoreNavigationCommands { newStates[lastAddedCursorIndex] = CursorMoveCommands.line(cursors.context, states[lastAddedCursorIndex], this._inSelectionMode, args.position, args.viewPosition); cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, newStates @@ -1461,14 +1452,14 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, CursorMoveCommands.expandLineSelection(cursors.context, cursors.getAll()) ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } }); @@ -1487,16 +1478,16 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, [ CursorMoveCommands.cancelSelection(cursors.context, cursors.getPrimaryCursor()) ] ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } }); @@ -1514,16 +1505,16 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, [ cursors.getPrimaryCursor() ] ); - cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth); + viewModel.revealPrimary(args.source, true); } }); @@ -1536,7 +1527,7 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { const revealLineArg = args; let lineNumber = (revealLineArg.lineNumber || 0) + 1; if (lineNumber < 1) { @@ -1571,7 +1562,7 @@ export namespace CoreNavigationCommands { const viewRange = cursors.context.coordinatesConverter.convertModelRangeToViewRange(range); - cursors.revealRange(args.source, false, viewRange, revealAt, ScrollType.Smooth); + viewModel.revealRange(args.source, false, viewRange, revealAt, ScrollType.Smooth); } }); @@ -1583,9 +1574,9 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, [ @@ -1603,9 +1594,9 @@ export namespace CoreNavigationCommands { }); } - public runCoreEditorCommand(cursors: ICursors, args: any): void { + public runCoreEditorCommand(editor: ICodeEditor, viewModel: IViewModel, cursors: ICursors, args: any): void { cursors.context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, [ diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index 88430f1d372a26abf6ccf1bd8efc0f20361d6d00..0283f74c92680d4e94b94d3cd8cf39b5db43757f 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -555,7 +555,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE const validatedModelRange = this._modelData.model.validateRange(modelRange); const viewRange = this._modelData.viewModel.coordinatesConverter.convertModelRangeToViewRange(validatedModelRange); - this._modelData.viewModel.cursor.emitCursorRevealRange('api', viewRange, null, verticalType, revealHorizontal, scrollType); + this._modelData.viewModel.revealRange('api', revealHorizontal, viewRange, verticalType, scrollType); } public revealLine(lineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void { @@ -1544,7 +1544,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE if (this.isSimpleWidget) { commandDelegate = { executeEditorCommand: (editorCommand: CoreEditorCommand, args: any): void => { - editorCommand.runCoreEditorCommand(viewModel.getCursors(), args); + editorCommand.runCoreEditorCommand(this, viewModel, viewModel.getCursors(), args); }, paste: (text: string, pasteOnNewLine: boolean, multicursorText: string[] | null, mode: string | null) => { this._paste('keyboard', text, pasteOnNewLine, multicursorText, mode); @@ -1568,7 +1568,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE } else { commandDelegate = { executeEditorCommand: (editorCommand: CoreEditorCommand, args: any): void => { - editorCommand.runCoreEditorCommand(viewModel.getCursors(), args); + editorCommand.runCoreEditorCommand(this, viewModel, viewModel.getCursors(), args); }, paste: (text: string, pasteOnNewLine: boolean, multicursorText: string[] | null, mode: string | null) => { const payload: editorCommon.PastePayload = { text, pasteOnNewLine, multicursorText, mode }; diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index a2ac6dc919d5fcf9cddd96860c1dbba44f1d4b87..83cfd453a4da4e017c9b8830f3fff81844a455e4 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -7,7 +7,7 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import { Emitter, Event } from 'vs/base/common/event'; import * as strings from 'vs/base/common/strings'; import { CursorCollection } from 'vs/editor/common/controller/cursorCollection'; -import { CursorColumns, CursorConfiguration, CursorContext, CursorState, EditOperationResult, EditOperationType, IColumnSelectData, ICursors, PartialCursorState, RevealTarget, ICursorSimpleModel } from 'vs/editor/common/controller/cursorCommon'; +import { CursorColumns, CursorConfiguration, CursorContext, CursorState, EditOperationResult, EditOperationType, IColumnSelectData, ICursors, PartialCursorState, ICursorSimpleModel } from 'vs/editor/common/controller/cursorCommon'; import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations'; import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { TypeOperations, TypeWithAutoClosingCommand } from 'vs/editor/common/controller/cursorTypeOperations'; @@ -17,8 +17,8 @@ import { ISelection, Selection, SelectionDirection } from 'vs/editor/common/core import * as editorCommon from 'vs/editor/common/editorCommon'; import { ITextModel, TrackedRangeStickiness, IModelDeltaDecoration, ICursorStateComputer, IIdentifiedSingleEditOperation, IValidEditOperation } from 'vs/editor/common/model'; import { RawContentChangedType, ModelRawContentChangedEvent, IModelLanguageChangedEvent } from 'vs/editor/common/model/textModelEvents'; -import * as viewEvents from 'vs/editor/common/view/viewEvents'; -import { dispose } from 'vs/base/common/lifecycle'; +import { ViewEventsCollector, VerticalRevealType, ViewCursorStateChangedEvent, ViewRevealRangeRequestEvent } from 'vs/editor/common/view/viewEvents'; +import { dispose, Disposable } from 'vs/base/common/lifecycle'; import { EditorOption, ConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; import { ICoordinatesConverter } from 'vs/editor/common/viewModel/viewModel'; @@ -162,7 +162,7 @@ class AutoClosedAction { } } -export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { +export class Cursor extends Disposable implements ICursors { public static readonly MAX_CURSOR_COUNT = 10000; @@ -218,7 +218,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._cursors.updateContext(this.context); } - public onLineMappingChanged(): void { + public onLineMappingChanged(eventsCollector: ViewEventsCollector): void { if (this._knownModelVersionId !== this._model.getVersionId()) { // There are model change events that I didn't yet receive. // @@ -230,7 +230,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { return; } // Ensure valid state - this.setStates('viewModel', CursorChangeReason.NotSet, this.getAll()); + this.setStates(eventsCollector, 'viewModel', CursorChangeReason.NotSet, this.getAll()); } public onDidChangeModelLanguage(e: IModelLanguageChangedEvent): void { @@ -283,7 +283,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { return this._cursors.getAll(); } - public setStates(source: string | null | undefined, reason: CursorChangeReason, states: PartialCursorState[] | null): boolean { + public setStates(eventsCollector: ViewEventsCollector, source: string | null | undefined, reason: CursorChangeReason, states: PartialCursorState[] | null): boolean { let reachedMaxCursorCount = false; if (states !== null && states.length > Cursor.MAX_CURSOR_COUNT) { states = states.slice(0, Cursor.MAX_CURSOR_COUNT); @@ -298,19 +298,38 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._validateAutoClosedActions(); - return this._emitStateChangedIfNecessary(source, reason, oldState, reachedMaxCursorCount); + return this._emitStateChangedIfNecessary(eventsCollector, source, reason, oldState, reachedMaxCursorCount); } public setColumnSelectData(columnSelectData: IColumnSelectData): void { this._columnSelectData = columnSelectData; } - public reveal(source: string | null | undefined, horizontal: boolean, target: RevealTarget, scrollType: editorCommon.ScrollType): void { - this._revealRange(source, target, viewEvents.VerticalRevealType.Simple, horizontal, scrollType); + public revealPrimary(eventsCollector: ViewEventsCollector, source: string | null | undefined, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void { + const viewPositions = this._cursors.getViewPositions(); + if (viewPositions.length > 1) { + this._emitCursorRevealRange(eventsCollector, source, null, this._cursors.getViewSelections(), VerticalRevealType.Simple, revealHorizontal, scrollType); + return; + } else { + const viewPosition = viewPositions[0]; + const viewRange = new Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column); + this._emitCursorRevealRange(eventsCollector, source, viewRange, null, VerticalRevealType.Simple, revealHorizontal, scrollType); + } } - public revealRange(source: string | null | undefined, revealHorizontal: boolean, viewRange: Range, verticalType: viewEvents.VerticalRevealType, scrollType: editorCommon.ScrollType) { - this.emitCursorRevealRange(source, viewRange, null, verticalType, revealHorizontal, scrollType); + private _revealPrimaryCursor(eventsCollector: ViewEventsCollector, source: string | null | undefined, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void { + const viewPositions = this._cursors.getViewPositions(); + if (viewPositions.length > 1) { + this._emitCursorRevealRange(eventsCollector, source, null, this._cursors.getViewSelections(), verticalType, revealHorizontal, scrollType); + } else { + const viewPosition = viewPositions[0]; + const viewRange = new Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column); + this._emitCursorRevealRange(eventsCollector, source, viewRange, null, verticalType, revealHorizontal, scrollType); + } + } + + private _emitCursorRevealRange(eventsCollector: ViewEventsCollector, source: string | null | undefined, viewRange: Range | null, viewSelections: Selection[] | null, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType) { + eventsCollector.emit(new ViewRevealRangeRequestEvent(source, viewRange, viewSelections, verticalType, revealHorizontal, scrollType)); } public saveState(): editorCommon.ICursorState[] { @@ -337,7 +356,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { return result; } - public restoreState(states: editorCommon.ICursorState[]): void { + public restoreState(eventsCollector: ViewEventsCollector, states: editorCommon.ICursorState[]): void { let desiredSelections: ISelection[] = []; @@ -374,11 +393,11 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { }); } - this.setStates('restoreState', CursorChangeReason.NotSet, CursorState.fromModelSelections(desiredSelections)); - this.reveal('restoreState', true, RevealTarget.Primary, editorCommon.ScrollType.Immediate); + this.setStates(eventsCollector, 'restoreState', CursorChangeReason.NotSet, CursorState.fromModelSelections(desiredSelections)); + this.revealPrimary(eventsCollector, 'restoreState', true, editorCommon.ScrollType.Immediate); } - public onModelContentChanged(e: ModelRawContentChangedEvent): void { + public onModelContentChanged(eventsCollector: ViewEventsCollector, e: ModelRawContentChangedEvent): void { this._knownModelVersionId = e.versionId; if (this._isHandling) { @@ -393,16 +412,16 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._cursors.dispose(); this._cursors = new CursorCollection(this.context); this._validateAutoClosedActions(); - this._emitStateChangedIfNecessary('model', CursorChangeReason.ContentFlush, null, false); + this._emitStateChangedIfNecessary(eventsCollector, 'model', CursorChangeReason.ContentFlush, null, false); } else { if (this._hasFocus && e.resultingSelection && e.resultingSelection.length > 0) { const cursorState = CursorState.fromModelSelections(e.resultingSelection); - if (this.setStates('modelChange', e.isUndoing ? CursorChangeReason.Undo : e.isRedoing ? CursorChangeReason.Redo : CursorChangeReason.RecoverFromMarkers, cursorState)) { - this._revealRange('modelChange', RevealTarget.Primary, viewEvents.VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth); + if (this.setStates(eventsCollector, 'modelChange', e.isUndoing ? CursorChangeReason.Undo : e.isRedoing ? CursorChangeReason.Redo : CursorChangeReason.RecoverFromMarkers, cursorState)) { + this._revealPrimaryCursor(eventsCollector, 'modelChange', VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth); } } else { const selectionsFromMarkers = this._cursors.readSelectionFromMarkers(); - this.setStates('modelChange', CursorChangeReason.RecoverFromMarkers, CursorState.fromModelSelections(selectionsFromMarkers)); + this.setStates(eventsCollector, 'modelChange', CursorChangeReason.RecoverFromMarkers, CursorState.fromModelSelections(selectionsFromMarkers)); } } } @@ -411,6 +430,14 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { return this._cursors.getPrimaryCursor().modelState.selection; } + public getTopMostViewPosition(): Position { + return this._cursors.getTopMostViewPosition(); + } + + public getBottomMostViewPosition(): Position { + return this._cursors.getBottomMostViewPosition(); + } + public getColumnSelectData(): IColumnSelectData { if (this._columnSelectData) { return this._columnSelectData; @@ -435,8 +462,8 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { return this._cursors.getPrimaryCursor().modelState.position; } - public setSelections(source: string | null | undefined, selections: readonly ISelection[]): void { - this.setStates(source, CursorChangeReason.NotSet, CursorState.fromModelSelections(selections)); + public setSelections(eventsCollector: ViewEventsCollector, source: string | null | undefined, selections: readonly ISelection[]): void { + this.setStates(eventsCollector, source, CursorChangeReason.NotSet, CursorState.fromModelSelections(selections)); } public getPrevEditOperationType(): EditOperationType { @@ -527,7 +554,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { // ----------------------------------------------------------------------------------------------------------- // ----- emitting events - private _emitStateChangedIfNecessary(source: string | null | undefined, reason: CursorChangeReason, oldState: CursorModelState | null, reachedMaxCursorCount: boolean): boolean { + private _emitStateChangedIfNecessary(eventsCollector: ViewEventsCollector, source: string | null | undefined, reason: CursorChangeReason, oldState: CursorModelState | null, reachedMaxCursorCount: boolean): boolean { const newState = new CursorModelState(this._model, this); if (newState.equals(oldState)) { return false; @@ -537,7 +564,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { const viewSelections = this._cursors.getViewSelections(); // Let the view get the event first. - this._emitSingleViewEvent(new viewEvents.ViewCursorStateChangedEvent(viewSelections, selections)); + eventsCollector.emit(new ViewCursorStateChangedEvent(viewSelections, selections)); // Only after the view has been notified, let the rest of the world know... if (!oldState @@ -552,38 +579,6 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { return true; } - private _revealRange(source: string | null | undefined, revealTarget: RevealTarget, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void { - const viewPositions = this._cursors.getViewPositions(); - - let viewPosition = viewPositions[0]; - - if (revealTarget === RevealTarget.TopMost) { - for (let i = 1; i < viewPositions.length; i++) { - if (viewPositions[i].isBefore(viewPosition)) { - viewPosition = viewPositions[i]; - } - } - } else if (revealTarget === RevealTarget.BottomMost) { - for (let i = 1; i < viewPositions.length; i++) { - if (viewPosition.isBeforeOrEqual(viewPositions[i])) { - viewPosition = viewPositions[i]; - } - } - } else { - if (viewPositions.length > 1) { - this.emitCursorRevealRange(source, null, this._cursors.getViewSelections(), verticalType, revealHorizontal, scrollType); - return; - } - } - - const viewRange = new Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column); - this.emitCursorRevealRange(source, viewRange, null, verticalType, revealHorizontal, scrollType); - } - - public emitCursorRevealRange(source: string | null | undefined, viewRange: Range | null, viewSelections: Selection[] | null, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType) { - this._emitSingleViewEvent(new viewEvents.ViewRevealRangeRequestEvent(source, viewRange, viewSelections, verticalType, revealHorizontal, scrollType)); - } - // ----------------------------------------------------------------------------------------------------------- // ----- handlers beyond this point @@ -623,7 +618,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { return indices; } - public executeEdits(source: string | null | undefined, edits: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): void { + public executeEdits(eventsCollector: ViewEventsCollector, source: string | null | undefined, edits: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): void { let autoClosingIndices: [number, number][] | null = null; if (source === 'snippet') { autoClosingIndices = this._findAutoClosingPairs(edits); @@ -658,14 +653,14 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { }); if (selections) { this._isHandling = false; - this.setSelections(source, selections); + this.setSelections(eventsCollector, source, selections); } if (autoClosedCharactersRanges.length > 0) { this._pushAutoClosedAction(autoClosedCharactersRanges, autoClosedEnclosingRanges); } } - private _executeEdit(callback: () => void, source: string | null | undefined, cursorChangeReason: CursorChangeReason = CursorChangeReason.NotSet): void { + private _executeEdit(callback: () => void, eventsCollector: ViewEventsCollector, source: string | null | undefined, cursorChangeReason: CursorChangeReason = CursorChangeReason.NotSet): void { if (this._configuration.options.get(EditorOption.readOnly)) { // we cannot edit when read only... this._onDidAttemptReadOnlyEdit.fire(undefined); @@ -686,17 +681,17 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._isHandling = false; this._cursors.startTrackingSelections(); this._validateAutoClosedActions(); - if (this._emitStateChangedIfNecessary(source, cursorChangeReason, oldState, false)) { - this._revealRange(source, RevealTarget.Primary, viewEvents.VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth); + if (this._emitStateChangedIfNecessary(eventsCollector, source, cursorChangeReason, oldState, false)) { + this._revealPrimaryCursor(eventsCollector, source, VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth); } } - public startComposition(): void { + public startComposition(eventsCollector: ViewEventsCollector): void { this._isDoingComposition = true; this._selectionsWhenCompositionStarted = this.getSelections().slice(0); } - public endComposition(source?: string | null | undefined): void { + public endComposition(eventsCollector: ViewEventsCollector, source?: string | null | undefined): void { this._isDoingComposition = false; this._executeEdit(() => { if (!this._isDoingComposition && source === 'keyboard') { @@ -705,10 +700,10 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { this._executeEditOperation(TypeOperations.compositionEndWithInterceptors(this._prevEditOperationType, this.context.config, this.context.model, this._selectionsWhenCompositionStarted, this.getSelections(), autoClosedCharacters)); this._selectionsWhenCompositionStarted = null; } - }, source); + }, eventsCollector, source); } - public type(text: string, source?: string | null | undefined): void { + public type(eventsCollector: ViewEventsCollector, text: string, source?: string | null | undefined): void { this._executeEdit(() => { if (source === 'keyboard') { // If this event is coming straight from the keyboard, look for electric characters and enter @@ -729,28 +724,28 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { } else { this._executeEditOperation(TypeOperations.typeWithoutInterceptors(this._prevEditOperationType, this.context.config, this.context.model, this.getSelections(), text)); } - }, source); + }, eventsCollector, source); } - public replacePreviousChar(text: string, replaceCharCnt: number, source?: string | null | undefined): void { + public replacePreviousChar(eventsCollector: ViewEventsCollector, text: string, replaceCharCnt: number, source?: string | null | undefined): void { this._executeEdit(() => { this._executeEditOperation(TypeOperations.replacePreviousChar(this._prevEditOperationType, this.context.config, this.context.model, this.getSelections(), text, replaceCharCnt)); - }, source); + }, eventsCollector, source); } - public paste(text: string, pasteOnNewLine: boolean, multicursorText?: string[] | null | undefined, source?: string | null | undefined): void { + public paste(eventsCollector: ViewEventsCollector, text: string, pasteOnNewLine: boolean, multicursorText?: string[] | null | undefined, source?: string | null | undefined): void { this._executeEdit(() => { this._executeEditOperation(TypeOperations.paste(this.context.config, this.context.model, this.getSelections(), text, pasteOnNewLine, multicursorText || [])); - }, source, CursorChangeReason.Paste); + }, eventsCollector, source, CursorChangeReason.Paste); } - public cut(source?: string | null | undefined): void { + public cut(eventsCollector: ViewEventsCollector, source?: string | null | undefined): void { this._executeEdit(() => { this._executeEditOperation(DeleteOperations.cut(this.context.config, this.context.model, this.getSelections())); - }, source); + }, eventsCollector, source); } - public executeCommand(command: editorCommon.ICommand, source?: string | null | undefined): void { + public executeCommand(eventsCollector: ViewEventsCollector, command: editorCommon.ICommand, source?: string | null | undefined): void { this._executeEdit(() => { this._cursors.killSecondaryCursors(); @@ -758,16 +753,16 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors { shouldPushStackElementBefore: false, shouldPushStackElementAfter: false })); - }, source); + }, eventsCollector, source); } - public executeCommands(commands: editorCommon.ICommand[], source?: string | null | undefined): void { + public executeCommands(eventsCollector: ViewEventsCollector, commands: editorCommon.ICommand[], source?: string | null | undefined): void { this._executeEdit(() => { this._executeEditOperation(new EditOperationResult(EditOperationType.Other, commands, { shouldPushStackElementBefore: false, shouldPushStackElementAfter: false })); - }, source); + }, eventsCollector, source); } } diff --git a/src/vs/editor/common/controller/cursorCollection.ts b/src/vs/editor/common/controller/cursorCollection.ts index 63cc38e4862e05aa2b455249bed9e2f80c812236..9b0102adffc802726c31e88cd218b3b6bf873242 100644 --- a/src/vs/editor/common/controller/cursorCollection.ts +++ b/src/vs/editor/common/controller/cursorCollection.ts @@ -82,6 +82,28 @@ export class CursorCollection { return result; } + public getTopMostViewPosition(): Position { + let result = this.primaryCursor.viewState.position; + for (let i = 0, len = this.secondaryCursors.length; i < len; i++) { + const viewPosition = this.secondaryCursors[i].viewState.position; + if (viewPosition.isBefore(result)) { + result = viewPosition; + } + } + return result; + } + + public getBottomMostViewPosition(): Position { + let result = this.primaryCursor.viewState.position; + for (let i = 0, len = this.secondaryCursors.length; i < len; i++) { + const viewPosition = this.secondaryCursors[i].viewState.position; + if (result.isBeforeOrEqual(viewPosition)) { + result = viewPosition; + } + } + return result; + } + public getSelections(): Selection[] { let result: Selection[] = []; result[0] = this.primaryCursor.modelState.selection; diff --git a/src/vs/editor/common/controller/cursorCommon.ts b/src/vs/editor/common/controller/cursorCommon.ts index 4676e2d03e7b889bf968aaec2b27d35d8eb607df..3c1e1d73c1a406c049a9d48f0d8878c4178980c4 100644 --- a/src/vs/editor/common/controller/cursorCommon.ts +++ b/src/vs/editor/common/controller/cursorCommon.ts @@ -7,17 +7,15 @@ import { CharCode } from 'vs/base/common/charCode'; import { onUnexpectedError } from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, ConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOption, EditorAutoIndentStrategy } from 'vs/editor/common/config/editorOptions'; -import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; -import { ICommand, IConfiguration, ScrollType } from 'vs/editor/common/editorCommon'; +import { ICommand, IConfiguration } from 'vs/editor/common/editorCommon'; import { ITextModel, TextModelResolvedOptions } from 'vs/editor/common/model'; import { TextModel } from 'vs/editor/common/model/textModel'; import { LanguageIdentifier } from 'vs/editor/common/modes'; import { IAutoClosingPair, StandardAutoClosingPairConditional } from 'vs/editor/common/modes/languageConfiguration'; import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry'; -import { VerticalRevealType } from 'vs/editor/common/view/viewEvents'; import { ICoordinatesConverter } from 'vs/editor/common/viewModel/viewModel'; import { Constants } from 'vs/base/common/uint'; @@ -55,10 +53,6 @@ export interface ICursors { getColumnSelectData(): IColumnSelectData; setColumnSelectData(columnSelectData: IColumnSelectData): void; - setStates(source: string | null | undefined, reason: CursorChangeReason, states: PartialCursorState[] | null): void; - reveal(source: string | null | undefined, horizontal: boolean, target: RevealTarget, scrollType: ScrollType): void; - revealRange(source: string | null | undefined, revealHorizontal: boolean, viewRange: Range, verticalType: VerticalRevealType, scrollType: ScrollType): void; - getPrevEditOperationType(): EditOperationType; setPrevEditOperationType(type: EditOperationType): void; } diff --git a/src/vs/editor/common/viewModel/viewModel.ts b/src/vs/editor/common/viewModel/viewModel.ts index b994a1277f72e48b80db9bc2d596cfdcf3d11330..aa81370574fbabe32f783ced1a88d7e6a0fbda70 100644 --- a/src/vs/editor/common/viewModel/viewModel.ts +++ b/src/vs/editor/common/viewModel/viewModel.ts @@ -10,11 +10,12 @@ import { IPosition, Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { INewScrollPosition, ScrollType } from 'vs/editor/common/editorCommon'; import { EndOfLinePreference, IActiveIndentGuideInfo, IModelDecorationOptions, TextModelResolvedOptions } from 'vs/editor/common/model'; -import { IViewEventEmitter } from 'vs/editor/common/view/viewEvents'; +import { IViewEventEmitter, VerticalRevealType } from 'vs/editor/common/view/viewEvents'; import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'; import { IEditorWhitespace, IWhitespaceChangeAccessor } from 'vs/editor/common/viewLayout/linesLayout'; import { EditorTheme } from 'vs/editor/common/view/viewContext'; -import { ICursorSimpleModel } from 'vs/editor/common/controller/cursorCommon'; +import { ICursorSimpleModel, PartialCursorState } from 'vs/editor/common/controller/cursorCommon'; +import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; export interface IViewWhitespaceViewportData { readonly id: string; @@ -137,6 +138,16 @@ export interface IViewModel extends IViewEventEmitter, ICursorSimpleModel { getEOL(): string; getPlainTextToCopy(modelRanges: Range[], emptySelectionClipboard: boolean, forceCRLF: boolean): string | string[]; getRichTextToCopy(modelRanges: Range[], emptySelectionClipboard: boolean): { html: string, mode: string } | null; + + //#region cursor + + setCursorStates(source: string | null | undefined, reason: CursorChangeReason, states: PartialCursorState[] | null): void; + revealPrimary(source: string | null | undefined, revealHorizontal: boolean): void; + revealTopMostCursor(source: string | null | undefined): void; + revealBottomMostCursor(source: string | null | undefined): void; + revealRange(source: string | null | undefined, revealHorizontal: boolean, viewRange: Range, verticalType: VerticalRevealType, scrollType: ScrollType): void; + + //#endregion } export class MinimapLinesRenderingData { diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 7a7988d1a4373e6fd7f1d3d5ae681bd8c8b23a7c..8867d59c3b73cb6e0fd1e0d3547b0f07a8cd3977 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -26,7 +26,8 @@ import { RunOnceScheduler } from 'vs/base/common/async'; import * as platform from 'vs/base/common/platform'; import { EditorTheme } from 'vs/editor/common/view/viewContext'; import { Cursor } from 'vs/editor/common/controller/cursor'; -import { ICursors } from 'vs/editor/common/controller/cursorCommon'; +import { ICursors, PartialCursorState } from 'vs/editor/common/controller/cursorCommon'; +import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents'; const USE_IDENTITY_LINES_COLLECTION = true; @@ -93,16 +94,6 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel this.coordinatesConverter = this.lines.createCoordinatesConverter(); this.cursor = this._register(new Cursor(this.configuration, model, this, this.coordinatesConverter)); - this._register(this.cursor.addViewEventListener((events) => { - try { - const eventsCollector = this._beginEmitViewEvents(); - for (const event of events) { - eventsCollector.emit(event); - } - } finally { - this._endEmitViewEvents(); - } - })); this.viewLayout = this._register(new ViewLayout(this.configuration, this.getLineCount(), scheduleAtNextAnimationFrame)); @@ -183,7 +174,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel eventsCollector.emit(new viewEvents.ViewFlushedEvent()); eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent()); eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null)); - this.cursor.onLineMappingChanged(); + this.cursor.onLineMappingChanged(eventsCollector); this.decorations.onLineMappingChanged(); this.viewLayout.onFlushed(this.getLineCount()); @@ -307,7 +298,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel if (!hadOtherModelChange && hadModelLineChangeThatChangedLineMapping) { eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent()); eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null)); - this.cursor.onLineMappingChanged(); + this.cursor.onLineMappingChanged(eventsCollector); this.decorations.onLineMappingChanged(); } } finally { @@ -329,7 +320,12 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel } } - this.cursor.onModelContentChanged(e); + try { + const eventsCollector = this._beginEmitViewEvents(); + this.cursor.onModelContentChanged(eventsCollector, e); + } finally { + this._endEmitViewEvents(); + } })); this._register(this.model.onDidChangeTokens((e) => { @@ -362,14 +358,14 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel this._register(this.model.onDidChangeOptions((e) => { // A tab size change causes a line mapping changed event => all view parts will repaint OK, no further event needed here if (this.lines.setTabSize(this.model.getOptions().tabSize)) { - this.cursor.onLineMappingChanged(); - this.decorations.onLineMappingChanged(); - this.viewLayout.onFlushed(this.getLineCount()); try { const eventsCollector = this._beginEmitViewEvents(); eventsCollector.emit(new viewEvents.ViewFlushedEvent()); eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent()); eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null)); + this.cursor.onLineMappingChanged(eventsCollector); + this.decorations.onLineMappingChanged(); + this.viewLayout.onFlushed(this.getLineCount()); } finally { this._endEmitViewEvents(); } @@ -393,7 +389,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel eventsCollector.emit(new viewEvents.ViewFlushedEvent()); eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent()); eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent(null)); - this.cursor.onLineMappingChanged(); + this.cursor.onLineMappingChanged(eventsCollector); this.decorations.onLineMappingChanged(); this.viewLayout.onFlushed(this.getLineCount()); this.viewLayout.onHeightMaybeChanged(); @@ -845,42 +841,70 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel return this.cursor.getPrimaryCursor().modelState.position; } public setSelections(source: string | null | undefined, selections: readonly ISelection[]): void { - this.cursor.setSelections(source, selections); + this._withViewEventsCollector(eventsCollector => this.cursor.setSelections(eventsCollector, source, selections)); + } + public setCursorStates(source: string | null | undefined, reason: CursorChangeReason, states: PartialCursorState[] | null): void { + this._withViewEventsCollector(eventsCollector => this.cursor.setStates(eventsCollector, source, reason, states)); } public saveCursorState(): ICursorState[] { return this.cursor.saveState(); } public restoreCursorState(states: ICursorState[]): void { - this.cursor.restoreState(states); + this._withViewEventsCollector(eventsCollector => this.cursor.restoreState(eventsCollector, states)); } public executeEdits(source: string | null | undefined, edits: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): void { - this.cursor.executeEdits(source, edits, cursorStateComputer); + this._withViewEventsCollector(eventsCollector => this.cursor.executeEdits(eventsCollector, source, edits, cursorStateComputer)); } public startComposition(): void { - this.cursor.startComposition(); + this._withViewEventsCollector(eventsCollector => this.cursor.startComposition(eventsCollector)); } public endComposition(source?: string | null | undefined): void { - this.cursor.endComposition(source); + this._withViewEventsCollector(eventsCollector => this.cursor.endComposition(eventsCollector, source)); } public type(text: string, source?: string | null | undefined): void { - this.cursor.type(text, source); + this._withViewEventsCollector(eventsCollector => this.cursor.type(eventsCollector, text, source)); } public replacePreviousChar(text: string, replaceCharCnt: number, source?: string | null | undefined): void { - this.cursor.replacePreviousChar(text, replaceCharCnt, source); + this._withViewEventsCollector(eventsCollector => this.cursor.replacePreviousChar(eventsCollector, text, replaceCharCnt, source)); } public paste(text: string, pasteOnNewLine: boolean, multicursorText?: string[] | null | undefined, source?: string | null | undefined): void { - this.cursor.paste(text, pasteOnNewLine, multicursorText, source); + this._withViewEventsCollector(eventsCollector => this.cursor.paste(eventsCollector, text, pasteOnNewLine, multicursorText, source)); } public cut(source?: string | null | undefined): void { - this.cursor.cut(source); + this._withViewEventsCollector(eventsCollector => this.cursor.cut(eventsCollector, source)); } public executeCommand(command: ICommand, source?: string | null | undefined): void { - this.cursor.executeCommand(command, source); + this._withViewEventsCollector(eventsCollector => this.cursor.executeCommand(eventsCollector, command, source)); } public executeCommands(commands: ICommand[], source?: string | null | undefined): void { - this.cursor.executeCommands(commands, source); + this._withViewEventsCollector(eventsCollector => this.cursor.executeCommands(eventsCollector, commands, source)); + } + public revealPrimary(source: string | null | undefined, revealHorizontal: boolean): void { + this._withViewEventsCollector(eventsCollector => this.cursor.revealPrimary(eventsCollector, source, revealHorizontal, ScrollType.Smooth)); + } + public revealTopMostCursor(source: string | null | undefined): void { + const viewPosition = this.cursor.getTopMostViewPosition(); + const viewRange = new Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column); + this._withViewEventsCollector(eventsCollector => eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(source, viewRange, null, viewEvents.VerticalRevealType.Simple, true, ScrollType.Smooth))); + } + public revealBottomMostCursor(source: string | null | undefined): void { + const viewPosition = this.cursor.getBottomMostViewPosition(); + const viewRange = new Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column); + this._withViewEventsCollector(eventsCollector => eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(source, viewRange, null, viewEvents.VerticalRevealType.Simple, true, ScrollType.Smooth))); + } + public revealRange(source: string | null | undefined, revealHorizontal: boolean, viewRange: Range, verticalType: viewEvents.VerticalRevealType, scrollType: ScrollType): void { + this._withViewEventsCollector(eventsCollector => eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(source, viewRange, null, verticalType, revealHorizontal, scrollType))); } //#endregion + + private _withViewEventsCollector(callback: (eventsCollector: viewEvents.ViewEventsCollector) => void): void { + try { + const eventsCollector = this._beginEmitViewEvents(); + callback(eventsCollector); + } finally { + this._endEmitViewEvents(); + } + } } diff --git a/src/vs/editor/contrib/multicursor/multicursor.ts b/src/vs/editor/contrib/multicursor/multicursor.ts index abebedd50801e9c15e323d0780b79481426e0d36..e9c8130a70e76f969971f500e77b08c27b19c5ed 100644 --- a/src/vs/editor/contrib/multicursor/multicursor.ts +++ b/src/vs/editor/contrib/multicursor/multicursor.ts @@ -9,7 +9,6 @@ import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; -import { RevealTarget } from 'vs/editor/common/controller/cursorCommon'; import { CursorChangeReason, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { CursorMoveCommands } from 'vs/editor/common/controller/cursorMoveCommands'; import { Range } from 'vs/editor/common/core/range'; @@ -61,6 +60,7 @@ export class InsertCursorAbove extends EditorAction { } const useLogicalLine = (args && args.logicalLine === true); + const viewModel = editor._getViewModel(); const cursors = editor._getCursors(); const context = cursors.context; @@ -69,12 +69,12 @@ export class InsertCursorAbove extends EditorAction { } context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, CursorMoveCommands.addCursorUp(context, cursors.getAll(), useLogicalLine) ); - cursors.reveal(args.source, true, RevealTarget.TopMost, ScrollType.Smooth); + viewModel.revealTopMostCursor(args.source); } } @@ -110,6 +110,7 @@ export class InsertCursorBelow extends EditorAction { } const useLogicalLine = (args && args.logicalLine === true); + const viewModel = editor._getViewModel(); const cursors = editor._getCursors(); const context = cursors.context; @@ -118,12 +119,12 @@ export class InsertCursorBelow extends EditorAction { } context.model.pushStackElement(); - cursors.setStates( + viewModel.setCursorStates( args.source, CursorChangeReason.Explicit, CursorMoveCommands.addCursorDown(context, cursors.getAll(), useLogicalLine) ); - cursors.reveal(args.source, true, RevealTarget.BottomMost, ScrollType.Smooth); + viewModel.revealBottomMostCursor(args.source); } } diff --git a/src/vs/editor/contrib/wordOperations/wordOperations.ts b/src/vs/editor/contrib/wordOperations/wordOperations.ts index ae5429ed0ccd9198b5ebd997c748c73133a63291..791e831aab0d34928ecdc3d9ea6c1072a792490e 100644 --- a/src/vs/editor/contrib/wordOperations/wordOperations.ts +++ b/src/vs/editor/contrib/wordOperations/wordOperations.ts @@ -53,7 +53,7 @@ export abstract class MoveWordCommand extends EditorCommand { }); model.pushStackElement(); - editor._getCursors().setStates('moveWordCommand', CursorChangeReason.NotSet, result.map(r => CursorState.fromModelSelection(r))); + editor._getViewModel().setCursorStates('moveWordCommand', CursorChangeReason.NotSet, result.map(r => CursorState.fromModelSelection(r))); if (result.length === 1) { const pos = new Position(result[0].positionLineNumber, result[0].positionColumn); editor.revealPosition(pos, ScrollType.Smooth); diff --git a/src/vs/editor/test/browser/controller/cursor.test.ts b/src/vs/editor/test/browser/controller/cursor.test.ts index 69c7157bf691f1d4d3001c6ec663de94eb20b157..19d4a4e83a7b67e530668adb203204a7f0d2ada1 100644 --- a/src/vs/editor/test/browser/controller/cursor.test.ts +++ b/src/vs/editor/test/browser/controller/cursor.test.ts @@ -27,79 +27,79 @@ import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl'; // --------- utils -function moveTo(viewModel: ViewModel, lineNumber: number, column: number, inSelectionMode: boolean = false) { +function moveTo(editor: ITestCodeEditor, viewModel: ViewModel, lineNumber: number, column: number, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.MoveToSelect.runCoreEditorCommand(viewModel.getCursors(), { + CoreNavigationCommands.MoveToSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(lineNumber, column) }); } else { - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(lineNumber, column) }); } } -function moveLeft(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveLeft(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorLeftSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorLeftSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorLeft.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorLeft.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } -function moveRight(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveRight(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorRightSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorRightSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } -function moveDown(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveDown(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorDownSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorDownSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorDown.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorDown.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } -function moveUp(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveUp(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorUpSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorUpSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorUp.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorUp.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } -function moveToBeginningOfLine(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveToBeginningOfLine(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorHomeSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorHomeSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorHome.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorHome.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } -function moveToEndOfLine(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveToEndOfLine(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorEndSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorEndSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorEnd.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorEnd.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } -function moveToBeginningOfBuffer(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveToBeginningOfBuffer(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorTopSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorTopSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorTop.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorTop.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } -function moveToEndOfBuffer(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveToEndOfBuffer(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorBottomSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorBottomSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorBottom.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorBottom.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } @@ -175,62 +175,62 @@ suite('Editor Controller - Cursor', () => { test('no move', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 1); + moveTo(editor, viewModel, 1, 1); assertCursor(viewModel, new Position(1, 1)); }); }); test('move', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 2); + moveTo(editor, viewModel, 1, 2); assertCursor(viewModel, new Position(1, 2)); }); }); test('move in selection mode', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 2, true); + moveTo(editor, viewModel, 1, 2, true); assertCursor(viewModel, new Selection(1, 1, 1, 2)); }); }); test('move beyond line end', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 25); + moveTo(editor, viewModel, 1, 25); assertCursor(viewModel, new Position(1, LINE1.length + 1)); }); }); test('move empty line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 4, 20); + moveTo(editor, viewModel, 4, 20); assertCursor(viewModel, new Position(4, 1)); }); }); test('move one char line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 5, 20); + moveTo(editor, viewModel, 5, 20); assertCursor(viewModel, new Position(5, 2)); }); }); test('selection down', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 2, 1, true); + moveTo(editor, viewModel, 2, 1, true); assertCursor(viewModel, new Selection(1, 1, 2, 1)); }); }); test('move and then select', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 2, 3); + moveTo(editor, viewModel, 2, 3); assertCursor(viewModel, new Position(2, 3)); - moveTo(viewModel, 2, 15, true); + moveTo(editor, viewModel, 2, 15, true); assertCursor(viewModel, new Selection(2, 3, 2, 15)); - moveTo(viewModel, 1, 2, true); + moveTo(editor, viewModel, 1, 2, true); assertCursor(viewModel, new Selection(2, 3, 1, 2)); }); }); @@ -239,43 +239,43 @@ suite('Editor Controller - Cursor', () => { test('move left on top left position', () => { runTest((editor, viewModel) => { - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); }); }); test('move left', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 3); + moveTo(editor, viewModel, 1, 3); assertCursor(viewModel, new Position(1, 3)); - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Position(1, 2)); }); }); test('move left with surrogate pair', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 17); + moveTo(editor, viewModel, 3, 17); assertCursor(viewModel, new Position(3, 17)); - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Position(3, 15)); }); }); test('move left goes to previous row', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 2, 1); + moveTo(editor, viewModel, 2, 1); assertCursor(viewModel, new Position(2, 1)); - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Position(1, 21)); }); }); test('move left selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 2, 1); + moveTo(editor, viewModel, 2, 1); assertCursor(viewModel, new Position(2, 1)); - moveLeft(viewModel, true); + moveLeft(editor, viewModel, true); assertCursor(viewModel, new Selection(2, 1, 1, 21)); }); }); @@ -284,45 +284,45 @@ suite('Editor Controller - Cursor', () => { test('move right on bottom right position', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 5, 2); + moveTo(editor, viewModel, 5, 2); assertCursor(viewModel, new Position(5, 2)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Position(5, 2)); }); }); test('move right', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 3); + moveTo(editor, viewModel, 1, 3); assertCursor(viewModel, new Position(1, 3)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Position(1, 4)); }); }); test('move right with surrogate pair', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 15); + moveTo(editor, viewModel, 3, 15); assertCursor(viewModel, new Position(3, 15)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Position(3, 17)); }); }); test('move right goes to next row', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 21); + moveTo(editor, viewModel, 1, 21); assertCursor(viewModel, new Position(1, 21)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Position(2, 1)); }); }); test('move right selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 21); + moveTo(editor, viewModel, 1, 21); assertCursor(viewModel, new Position(1, 21)); - moveRight(viewModel, true); + moveRight(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 21, 2, 1)); }); }); @@ -331,45 +331,45 @@ suite('Editor Controller - Cursor', () => { test('move down', () => { runTest((editor, viewModel) => { - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(2, 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(3, 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(4, 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(5, 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(5, 2)); }); }); test('move down with selection', () => { runTest((editor, viewModel) => { - moveDown(viewModel, true); + moveDown(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 1, 2, 1)); - moveDown(viewModel, true); + moveDown(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 1, 3, 1)); - moveDown(viewModel, true); + moveDown(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 1, 4, 1)); - moveDown(viewModel, true); + moveDown(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 1, 5, 1)); - moveDown(viewModel, true); + moveDown(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 1, 5, 2)); }); }); test('move down with tabs', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 5); + moveTo(editor, viewModel, 1, 5); assertCursor(viewModel, new Position(1, 5)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(2, 2)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(3, 5)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(4, 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(5, 2)); }); }); @@ -378,68 +378,68 @@ suite('Editor Controller - Cursor', () => { test('move up', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 5); + moveTo(editor, viewModel, 3, 5); assertCursor(viewModel, new Position(3, 5)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(2, 2)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(1, 5)); }); }); test('move up with selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 5); + moveTo(editor, viewModel, 3, 5); assertCursor(viewModel, new Position(3, 5)); - moveUp(viewModel, true); + moveUp(editor, viewModel, true); assertCursor(viewModel, new Selection(3, 5, 2, 2)); - moveUp(viewModel, true); + moveUp(editor, viewModel, true); assertCursor(viewModel, new Selection(3, 5, 1, 5)); }); }); test('move up and down with tabs', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 5); + moveTo(editor, viewModel, 1, 5); assertCursor(viewModel, new Position(1, 5)); - moveDown(viewModel); - moveDown(viewModel); - moveDown(viewModel); - moveDown(viewModel); + moveDown(editor, viewModel); + moveDown(editor, viewModel); + moveDown(editor, viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(5, 2)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(4, 1)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(3, 5)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(2, 2)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(1, 5)); }); }); test('move up and down with end of lines starting from a long one', () => { runTest((editor, viewModel) => { - moveToEndOfLine(viewModel); + moveToEndOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); - moveToEndOfLine(viewModel); + moveToEndOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(2, LINE2.length + 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(3, LINE3.length + 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(4, LINE4.length + 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(5, LINE5.length + 1)); - moveUp(viewModel); - moveUp(viewModel); - moveUp(viewModel); - moveUp(viewModel); + moveUp(editor, viewModel); + moveUp(editor, viewModel); + moveUp(editor, viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); }); }); @@ -448,19 +448,19 @@ suite('Editor Controller - Cursor', () => { runTest((editor, viewModel) => { viewModel.setSelections('test', [new Selection(1, 5, 1, 5)]); // going once up on the first line remembers the offset visual columns - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(2, 2)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(1, 5)); // going twice up on the first line discards the offset visual columns - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(2, 1)); }); }); @@ -469,93 +469,93 @@ suite('Editor Controller - Cursor', () => { test('move to beginning of line', () => { runTest((editor, viewModel) => { - moveToBeginningOfLine(viewModel); + moveToBeginningOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, 6)); - moveToBeginningOfLine(viewModel); + moveToBeginningOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); }); }); test('move to beginning of line from within line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); - moveToBeginningOfLine(viewModel); + moveTo(editor, viewModel, 1, 8); + moveToBeginningOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, 6)); - moveToBeginningOfLine(viewModel); + moveToBeginningOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); }); }); test('move to beginning of line from whitespace at beginning of line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 2); - moveToBeginningOfLine(viewModel); + moveTo(editor, viewModel, 1, 2); + moveToBeginningOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, 6)); - moveToBeginningOfLine(viewModel); + moveToBeginningOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); }); }); test('move to beginning of line from within line selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); - moveToBeginningOfLine(viewModel, true); + moveTo(editor, viewModel, 1, 8); + moveToBeginningOfLine(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 8, 1, 6)); - moveToBeginningOfLine(viewModel, true); + moveToBeginningOfLine(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 8, 1, 1)); }); }); test('move to beginning of line with selection multiline forward', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); - moveTo(viewModel, 3, 9, true); - moveToBeginningOfLine(viewModel, false); + moveTo(editor, viewModel, 1, 8); + moveTo(editor, viewModel, 3, 9, true); + moveToBeginningOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(3, 5, 3, 5)); }); }); test('move to beginning of line with selection multiline backward', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 9); - moveTo(viewModel, 1, 8, true); - moveToBeginningOfLine(viewModel, false); + moveTo(editor, viewModel, 3, 9); + moveTo(editor, viewModel, 1, 8, true); + moveToBeginningOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(1, 6, 1, 6)); }); }); test('move to beginning of line with selection single line forward', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 2); - moveTo(viewModel, 3, 9, true); - moveToBeginningOfLine(viewModel, false); + moveTo(editor, viewModel, 3, 2); + moveTo(editor, viewModel, 3, 9, true); + moveToBeginningOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(3, 5, 3, 5)); }); }); test('move to beginning of line with selection single line backward', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 9); - moveTo(viewModel, 3, 2, true); - moveToBeginningOfLine(viewModel, false); + moveTo(editor, viewModel, 3, 9); + moveTo(editor, viewModel, 3, 2, true); + moveToBeginningOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(3, 5, 3, 5)); }); }); test('issue #15401: "End" key is behaving weird when text is selected part 1', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); - moveTo(viewModel, 3, 9, true); - moveToBeginningOfLine(viewModel, false); + moveTo(editor, viewModel, 1, 8); + moveTo(editor, viewModel, 3, 9, true); + moveToBeginningOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(3, 5, 3, 5)); }); }); test('issue #17011: Shift+home/end now go to the end of the selection start\'s line, not the selection\'s end', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); - moveTo(viewModel, 3, 9, true); - moveToBeginningOfLine(viewModel, true); + moveTo(editor, viewModel, 1, 8); + moveTo(editor, viewModel, 3, 9, true); + moveToBeginningOfLine(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 8, 3, 5)); }); }); @@ -564,84 +564,84 @@ suite('Editor Controller - Cursor', () => { test('move to end of line', () => { runTest((editor, viewModel) => { - moveToEndOfLine(viewModel); + moveToEndOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); - moveToEndOfLine(viewModel); + moveToEndOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); }); }); test('move to end of line from within line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 6); - moveToEndOfLine(viewModel); + moveTo(editor, viewModel, 1, 6); + moveToEndOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); - moveToEndOfLine(viewModel); + moveToEndOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); }); }); test('move to end of line from whitespace at end of line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 20); - moveToEndOfLine(viewModel); + moveTo(editor, viewModel, 1, 20); + moveToEndOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); - moveToEndOfLine(viewModel); + moveToEndOfLine(editor, viewModel); assertCursor(viewModel, new Position(1, LINE1.length + 1)); }); }); test('move to end of line from within line selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 6); - moveToEndOfLine(viewModel, true); + moveTo(editor, viewModel, 1, 6); + moveToEndOfLine(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 6, 1, LINE1.length + 1)); - moveToEndOfLine(viewModel, true); + moveToEndOfLine(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 6, 1, LINE1.length + 1)); }); }); test('move to end of line with selection multiline forward', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 1); - moveTo(viewModel, 3, 9, true); - moveToEndOfLine(viewModel, false); + moveTo(editor, viewModel, 1, 1); + moveTo(editor, viewModel, 3, 9, true); + moveToEndOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(3, 17, 3, 17)); }); }); test('move to end of line with selection multiline backward', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 9); - moveTo(viewModel, 1, 1, true); - moveToEndOfLine(viewModel, false); + moveTo(editor, viewModel, 3, 9); + moveTo(editor, viewModel, 1, 1, true); + moveToEndOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(1, 21, 1, 21)); }); }); test('move to end of line with selection single line forward', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 1); - moveTo(viewModel, 3, 9, true); - moveToEndOfLine(viewModel, false); + moveTo(editor, viewModel, 3, 1); + moveTo(editor, viewModel, 3, 9, true); + moveToEndOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(3, 17, 3, 17)); }); }); test('move to end of line with selection single line backward', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 9); - moveTo(viewModel, 3, 1, true); - moveToEndOfLine(viewModel, false); + moveTo(editor, viewModel, 3, 9); + moveTo(editor, viewModel, 3, 1, true); + moveToEndOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(3, 17, 3, 17)); }); }); test('issue #15401: "End" key is behaving weird when text is selected part 2', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 1); - moveTo(viewModel, 3, 9, true); - moveToEndOfLine(viewModel, false); + moveTo(editor, viewModel, 1, 1); + moveTo(editor, viewModel, 3, 9, true); + moveToEndOfLine(editor, viewModel, false); assertCursor(viewModel, new Selection(3, 17, 3, 17)); }); }); @@ -650,39 +650,39 @@ suite('Editor Controller - Cursor', () => { test('move to beginning of buffer', () => { runTest((editor, viewModel) => { - moveToBeginningOfBuffer(viewModel); + moveToBeginningOfBuffer(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); }); }); test('move to beginning of buffer from within first line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 3); - moveToBeginningOfBuffer(viewModel); + moveTo(editor, viewModel, 1, 3); + moveToBeginningOfBuffer(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); }); }); test('move to beginning of buffer from within another line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 3); - moveToBeginningOfBuffer(viewModel); + moveTo(editor, viewModel, 3, 3); + moveToBeginningOfBuffer(editor, viewModel); assertCursor(viewModel, new Position(1, 1)); }); }); test('move to beginning of buffer from within first line selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 1, 3); - moveToBeginningOfBuffer(viewModel, true); + moveTo(editor, viewModel, 1, 3); + moveToBeginningOfBuffer(editor, viewModel, true); assertCursor(viewModel, new Selection(1, 3, 1, 1)); }); }); test('move to beginning of buffer from within another line selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 3); - moveToBeginningOfBuffer(viewModel, true); + moveTo(editor, viewModel, 3, 3); + moveToBeginningOfBuffer(editor, viewModel, true); assertCursor(viewModel, new Selection(3, 3, 1, 1)); }); }); @@ -691,39 +691,39 @@ suite('Editor Controller - Cursor', () => { test('move to end of buffer', () => { runTest((editor, viewModel) => { - moveToEndOfBuffer(viewModel); + moveToEndOfBuffer(editor, viewModel); assertCursor(viewModel, new Position(5, LINE5.length + 1)); }); }); test('move to end of buffer from within last line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 5, 1); - moveToEndOfBuffer(viewModel); + moveTo(editor, viewModel, 5, 1); + moveToEndOfBuffer(editor, viewModel); assertCursor(viewModel, new Position(5, LINE5.length + 1)); }); }); test('move to end of buffer from within another line', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 3); - moveToEndOfBuffer(viewModel); + moveTo(editor, viewModel, 3, 3); + moveToEndOfBuffer(editor, viewModel); assertCursor(viewModel, new Position(5, LINE5.length + 1)); }); }); test('move to end of buffer from within last line selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 5, 1); - moveToEndOfBuffer(viewModel, true); + moveTo(editor, viewModel, 5, 1); + moveToEndOfBuffer(editor, viewModel, true); assertCursor(viewModel, new Selection(5, 1, 5, LINE5.length + 1)); }); }); test('move to end of buffer from within another line selection', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 3, 3); - moveToEndOfBuffer(viewModel, true); + moveTo(editor, viewModel, 3, 3); + moveToEndOfBuffer(editor, viewModel, true); assertCursor(viewModel, new Selection(3, 3, 5, LINE5.length + 1)); }); }); @@ -732,7 +732,7 @@ suite('Editor Controller - Cursor', () => { test('select all', () => { runTest((editor, viewModel) => { - CoreNavigationCommands.SelectAll.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.SelectAll.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 5, LINE5.length + 1)); }); }); @@ -742,38 +742,38 @@ suite('Editor Controller - Cursor', () => { // 0 1 2 // 01234 56789012345678 0 // let LINE1 = ' \tMy First Line\t '; - moveTo(viewModel, 1, 1); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + moveTo(editor, viewModel, 1, 1); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 2, 1)); - moveTo(viewModel, 1, 2); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + moveTo(editor, viewModel, 1, 2); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 2, 1)); - moveTo(viewModel, 1, 5); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + moveTo(editor, viewModel, 1, 5); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 2, 1)); - moveTo(viewModel, 1, 19); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + moveTo(editor, viewModel, 1, 19); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 2, 1)); - moveTo(viewModel, 1, 20); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + moveTo(editor, viewModel, 1, 20); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 2, 1)); - moveTo(viewModel, 1, 21); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + moveTo(editor, viewModel, 1, 21); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 2, 1)); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 3, 1)); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 4, 1)); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 5, 1)); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 5, LINE5.length + 1)); - CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.ExpandLineSelection.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, new Selection(1, 1, 5, LINE5.length + 1)); }); }); @@ -785,7 +785,7 @@ suite('Editor Controller - Cursor', () => { viewModel.cursor.onDidChange((e) => { assert.ok(false, 'was not expecting event'); }); - moveTo(viewModel, 1, 1); + moveTo(editor, viewModel, 1, 1); }); }); @@ -796,7 +796,7 @@ suite('Editor Controller - Cursor', () => { events++; assert.deepEqual(e.selections, [new Selection(1, 2, 1, 2)]); }); - moveTo(viewModel, 1, 2); + moveTo(editor, viewModel, 1, 2); assert.equal(events, 1, 'receives 1 event'); }); }); @@ -808,7 +808,7 @@ suite('Editor Controller - Cursor', () => { events++; assert.deepEqual(e.selections, [new Selection(1, 1, 1, 2)]); }); - moveTo(viewModel, 1, 2, true); + moveTo(editor, viewModel, 1, 2, true); assert.equal(events, 1, 'receives 1 event'); }); }); @@ -817,12 +817,12 @@ suite('Editor Controller - Cursor', () => { test('saveState & restoreState', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 2, 1, true); + moveTo(editor, viewModel, 2, 1, true); assertCursor(viewModel, new Selection(1, 1, 2, 1)); let savedState = JSON.stringify(viewModel.saveCursorState()); - moveTo(viewModel, 1, 1, false); + moveTo(editor, viewModel, 1, 1, false); assertCursor(viewModel, new Position(1, 1)); viewModel.restoreCursorState(JSON.parse(savedState)); @@ -834,7 +834,7 @@ suite('Editor Controller - Cursor', () => { test('Independent model edit 1', () => { runTest((editor, viewModel) => { - moveTo(viewModel, 2, 16, true); + moveTo(editor, viewModel, 2, 16, true); editor.getModel().applyEdits([EditOperation.delete(new Range(2, 1, 2, 2))]); assertCursor(viewModel, new Selection(1, 1, 2, 15)); @@ -850,10 +850,10 @@ suite('Editor Controller - Cursor', () => { '\t}' ], {}, (editor, viewModel) => { - moveTo(viewModel, 1, 7, false); + moveTo(editor, viewModel, 1, 7, false); assertCursor(viewModel, new Position(1, 7)); - CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(viewModel.getCursors(), { + CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(4, 4), viewPosition: new Position(4, 4), mouseColumn: 15, @@ -881,31 +881,31 @@ suite('Editor Controller - Cursor', () => { ], {}, (editor, viewModel) => { viewModel.setSelections('test', [new Selection(2, 1, 2, 1)]); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Position(2, 3)); - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Position(2, 1)); viewModel.setSelections('test', [new Selection(3, 1, 3, 1)]); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Position(3, 4)); - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Position(3, 1)); viewModel.setSelections('test', [new Selection(4, 1, 4, 1)]); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Position(4, 3)); - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Position(4, 1)); viewModel.setSelections('test', [new Selection(1, 3, 1, 3)]); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(2, 5)); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Position(3, 4)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(2, 5)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Position(1, 3)); }); @@ -921,10 +921,10 @@ suite('Editor Controller - Cursor', () => { 'var concat = require("gulp-concat");', 'var newer = require("gulp-newer");', ].join('\n'), {}, (editor, viewModel) => { - moveTo(viewModel, 1, 4, false); + moveTo(editor, viewModel, 1, 4, false); assertCursor(viewModel, new Position(1, 4)); - CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(viewModel.getCursors(), { + CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(4, 1), viewPosition: new Position(4, 1), mouseColumn: 1, @@ -954,10 +954,10 @@ suite('Editor Controller - Cursor', () => { '', ].join('\n'), {}, (editor, viewModel) => { - moveTo(viewModel, 10, 10, false); + moveTo(editor, viewModel, 10, 10, false); assertCursor(viewModel, new Position(10, 10)); - CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(viewModel.getCursors(), { + CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(1, 1), viewPosition: new Position(1, 1), mouseColumn: 1, @@ -976,7 +976,7 @@ suite('Editor Controller - Cursor', () => { new Selection(1, 10, 1, 1), ]); - CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(viewModel.getCursors(), { + CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(1, 1), viewPosition: new Position(1, 1), mouseColumn: 1, @@ -1012,31 +1012,31 @@ suite('Editor Controller - Cursor', () => { '', ].join('\n'), {}, (editor, viewModel) => { - moveTo(viewModel, 10, 10, false); + moveTo(editor, viewModel, 10, 10, false); assertCursor(viewModel, new Position(10, 10)); - CoreNavigationCommands.CursorColumnSelectLeft.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectLeft.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(10, 10, 10, 9) ]); - CoreNavigationCommands.CursorColumnSelectLeft.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectLeft.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(10, 10, 10, 8) ]); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(10, 10, 10, 9) ]); - CoreNavigationCommands.CursorColumnSelectUp.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectUp.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(10, 10, 10, 9), new Selection(9, 10, 9, 9), ]); - CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(10, 10, 10, 9) ]); @@ -1054,31 +1054,31 @@ suite('Editor Controller - Cursor', () => { 'var newer = require("gulp-newer");', ].join('\n'), {}, (editor, viewModel) => { - moveTo(viewModel, 1, 4, false); + moveTo(editor, viewModel, 1, 4, false); assertCursor(viewModel, new Position(1, 4)); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 5) ]); - CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 5), new Selection(2, 4, 2, 5) ]); - CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 5), new Selection(2, 4, 2, 5), new Selection(3, 4, 3, 5), ]); - CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectDown.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 5), new Selection(2, 4, 2, 5), @@ -1089,7 +1089,7 @@ suite('Editor Controller - Cursor', () => { new Selection(7, 4, 7, 5), ]); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 6), new Selection(2, 4, 2, 6), @@ -1101,16 +1101,16 @@ suite('Editor Controller - Cursor', () => { ]); // 10 times - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 16), new Selection(2, 4, 2, 16), @@ -1122,16 +1122,16 @@ suite('Editor Controller - Cursor', () => { ]); // 10 times - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 26), new Selection(2, 4, 2, 26), @@ -1143,8 +1143,8 @@ suite('Editor Controller - Cursor', () => { ]); // 2 times => reaching the ending of lines 1 and 2 - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 28), new Selection(2, 4, 2, 28), @@ -1156,10 +1156,10 @@ suite('Editor Controller - Cursor', () => { ]); // 4 times => reaching the ending of line 3 - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 28), new Selection(2, 4, 2, 28), @@ -1171,8 +1171,8 @@ suite('Editor Controller - Cursor', () => { ]); // 2 times => reaching the ending of line 4 - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 28), new Selection(2, 4, 2, 28), @@ -1184,7 +1184,7 @@ suite('Editor Controller - Cursor', () => { ]); // 1 time => reaching the ending of line 7 - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 28), new Selection(2, 4, 2, 28), @@ -1196,9 +1196,9 @@ suite('Editor Controller - Cursor', () => { ]); // 3 times => reaching the ending of lines 5 & 6 - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 28), new Selection(2, 4, 2, 28), @@ -1210,7 +1210,7 @@ suite('Editor Controller - Cursor', () => { ]); // cannot go anywhere anymore - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 28), new Selection(2, 4, 2, 28), @@ -1222,10 +1222,10 @@ suite('Editor Controller - Cursor', () => { ]); // cannot go anywhere anymore even if we insist - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); - CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectRight.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 28), new Selection(2, 4, 2, 28), @@ -1237,7 +1237,7 @@ suite('Editor Controller - Cursor', () => { ]); // can easily go back - CoreNavigationCommands.CursorColumnSelectLeft.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorColumnSelectLeft.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assertCursor(viewModel, [ new Selection(1, 4, 1, 28), new Selection(2, 4, 2, 28), @@ -1337,7 +1337,7 @@ suite('Editor Controller - Regression tests', () => { viewModel.type('x'); assert.equal(model.getValue(EndOfLinePreference.LF), '\n\t\n\tx', 'assert4'); - CoreNavigationCommands.CursorLeft.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorLeft.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assert.equal(model.getValue(EndOfLinePreference.LF), '\n\t\n\tx', 'assert5'); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); @@ -1432,8 +1432,8 @@ suite('Editor Controller - Regression tests', () => { assert.equal(model.getLineContent(1), 'Hello world '); assertCursor(viewModel, new Position(1, 13)); - moveLeft(viewModel); - moveRight(viewModel); + moveLeft(editor, viewModel); + moveRight(editor, viewModel); model.pushEditOperations([], [EditOperation.replaceMove(new Range(1, 12, 1, 13), '')], () => []); assert.equal(model.getLineContent(1), 'Hello world'); @@ -1490,7 +1490,7 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 1, 6, false); + moveTo(editor, viewModel, 1, 6, false); assertCursor(viewModel, new Selection(1, 6, 1, 6)); CoreEditingCommands.Outdent.runEditorCommand(null, editor, null); @@ -1510,7 +1510,7 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 1, 7, false); + moveTo(editor, viewModel, 1, 7, false); assertCursor(viewModel, new Selection(1, 7, 1, 7)); CoreEditingCommands.Outdent.runEditorCommand(null, editor, null); @@ -1532,7 +1532,7 @@ suite('Editor Controller - Regression tests', () => { model: model, useTabStops: false }, (editor, viewModel) => { - moveTo(viewModel, 1, 9, false); + moveTo(editor, viewModel, 1, 9, false); assertCursor(viewModel, new Selection(1, 9, 1, 9)); CoreEditingCommands.Outdent.runEditorCommand(null, editor, null); @@ -1560,7 +1560,7 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 7, 1, false); + moveTo(editor, viewModel, 7, 1, false); assertCursor(viewModel, new Selection(7, 1, 7, 1)); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -1580,7 +1580,7 @@ suite('Editor Controller - Regression tests', () => { ], {}, (editor, viewModel) => { const model = editor.getModel()!; - moveTo(viewModel, 2, 1, false); + moveTo(editor, viewModel, 2, 1, false); assertCursor(viewModel, new Selection(2, 1, 2, 1)); viewModel.cut('keyboard'); @@ -1596,7 +1596,7 @@ suite('Editor Controller - Regression tests', () => { ], {}, (editor, viewModel) => { const model = editor.getModel()!; - moveTo(viewModel, 2, 1, false); + moveTo(editor, viewModel, 2, 1, false); assertCursor(viewModel, new Selection(2, 1, 2, 1)); viewModel.cut('keyboard'); @@ -1616,9 +1616,9 @@ suite('Editor Controller - Regression tests', () => { 'hello' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 1, 3, false); - moveTo(viewModel, 1, 5, true); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 3, false); + moveTo(editor, viewModel, 1, 5, true); assertCursor(viewModel, new Selection(1, 3, 1, 5)); viewModel.type('(', 'keyboard'); @@ -1641,8 +1641,8 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 3, 2, false); - moveTo(viewModel, 1, 14, true); + moveTo(editor, viewModel, 3, 2, false); + moveTo(editor, viewModel, 1, 14, true); assertCursor(viewModel, new Selection(3, 2, 1, 14)); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); @@ -1661,9 +1661,9 @@ suite('Editor Controller - Regression tests', () => { 'line1', 'line2' ], - }, (model, viewModel) => { - moveTo(viewModel, 2, 1, false); - moveTo(viewModel, 2, 6, true); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 1, false); + moveTo(editor, viewModel, 2, 6, true); viewModel.paste('line1\n', true); @@ -1680,7 +1680,7 @@ suite('Editor Controller - Regression tests', () => { 'line sel 2', 'line3' ], - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(2, 6, 2, 9)]); viewModel.paste('line1\n', true); @@ -1699,7 +1699,7 @@ suite('Editor Controller - Regression tests', () => { 'line2', 'line3' ], - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 1, 1, 1), new Selection(2, 1, 2, 1)]); viewModel.paste( @@ -1729,7 +1729,7 @@ suite('Editor Controller - Regression tests', () => { 'test', 'test' ], - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [ new Selection(1, 1, 1, 5), new Selection(2, 1, 2, 5), @@ -1772,7 +1772,7 @@ suite('Editor Controller - Regression tests', () => { 'test', 'test' ], - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [ new Selection(1, 1, 1, 5), new Selection(2, 1, 2, 5), @@ -1802,7 +1802,7 @@ suite('Editor Controller - Regression tests', () => { 'line2', 'line3' ], - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 1, 1, 1), new Selection(2, 1, 2, 1), new Selection(3, 1, 3, 1)]); viewModel.paste( @@ -1826,7 +1826,7 @@ suite('Editor Controller - Regression tests', () => { 'line2', 'line3' ], - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 1, 1, 1), new Selection(2, 1, 2, 1), new Selection(3, 1, 3, 1)]); viewModel.paste( @@ -1853,8 +1853,8 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 1, 1, false); - moveTo(viewModel, 3, 4, true); + moveTo(editor, viewModel, 1, 1, false); + moveTo(editor, viewModel, 3, 4, true); let isFirst = true; model.onDidChangeContent(() => { @@ -1902,8 +1902,8 @@ suite('Editor Controller - Regression tests', () => { 'just some text', ], languageIdentifier: null - }, (model, viewModel) => { - moveTo(viewModel, 3, 1, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 1, false); viewModel.type('😍', 'keyboard'); @@ -1927,7 +1927,7 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 3, 2, false); + moveTo(editor, viewModel, 3, 2, false); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(3), '\t \tx: 3'); }); @@ -1947,8 +1947,8 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 1, 15, false); - moveTo(viewModel, 1, 22, true); + moveTo(editor, viewModel, 1, 15, false); + moveTo(editor, viewModel, 1, 22, true); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(1), 'var foo = 123;\t// this is a comment'); }); @@ -1962,8 +1962,8 @@ suite('Editor Controller - Regression tests', () => { text: [ ' /* Just some more text a+= 3 +5-3 + 7 */ ' ], - }, (model, viewModel) => { - moveTo(viewModel, 1, 1, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 1, false); function assertWordRight(col: number, expectedCol: number) { let args = { @@ -1973,9 +1973,9 @@ suite('Editor Controller - Regression tests', () => { } }; if (col === 1) { - CoreNavigationCommands.WordSelect.runCoreEditorCommand(viewModel.getCursors(), args); + CoreNavigationCommands.WordSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), args); } else { - CoreNavigationCommands.WordSelectDrag.runCoreEditorCommand(viewModel.getCursors(), args); + CoreNavigationCommands.WordSelectDrag.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), args); } assert.equal(viewModel.getSelection().startColumn, 1, 'TEST FOR ' + col); @@ -2043,10 +2043,10 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - CoreNavigationCommands.WordSelect.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(1, 8) }); + CoreNavigationCommands.WordSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(1, 8) }); assert.deepEqual(viewModel.getSelection(), new Selection(1, 6, 1, 10)); - CoreNavigationCommands.WordSelectDrag.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(1, 8) }); + CoreNavigationCommands.WordSelectDrag.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(1, 8) }); assert.deepEqual(viewModel.getSelection(), new Selection(1, 6, 1, 10)); }); @@ -2061,7 +2061,7 @@ suite('Editor Controller - Regression tests', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - CoreNavigationCommands.WordSelect.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(1, 5) }); + CoreNavigationCommands.WordSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(1, 5) }); assert.deepEqual(viewModel.getSelection(), new Selection(1, 5, 1, 8)); }); @@ -2105,7 +2105,7 @@ suite('Editor Controller - Regression tests', () => { } usingCursor({ text: text - }, (model, viewModel) => { + }, (editor, model, viewModel) => { let selections: Selection[] = []; for (let i = 0; i < LINE_CNT; i++) { @@ -2131,7 +2131,7 @@ suite('Editor Controller - Regression tests', () => { 'first line', 'second line' ] - }, (model, viewModel) => { + }, (editor, model, viewModel) => { model.setEOL(EndOfLineSequence.CRLF); viewModel.setSelections('test', [new Selection(2, 2, 2, 2)]); @@ -2147,7 +2147,7 @@ suite('Editor Controller - Regression tests', () => { 'first line', 'second line' ] - }, (model, viewModel) => { + }, (editor, model, viewModel) => { model.setEOL(EndOfLineSequence.CRLF); viewModel.setSelections('test', [new Selection(2, 2, 2, 2)]); @@ -2173,33 +2173,33 @@ suite('Editor Controller - Regression tests', () => { ], { wordWrap: 'wordWrapColumn', wordWrapColumn: 16 }, (editor, viewModel) => { viewModel.setSelections('test', [new Selection(1, 7, 1, 7)]); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(1, 8, 1, 8)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(1, 9, 1, 9)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(1, 10, 1, 10)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(1, 11, 1, 11)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(1, 12, 1, 12)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(1, 13, 1, 13)); // moving to view line 2 - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(1, 14, 1, 14)); - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Selection(1, 13, 1, 13)); // moving back to view line 1 - moveLeft(viewModel); + moveLeft(editor, viewModel); assertCursor(viewModel, new Selection(1, 12, 1, 12)); }); }); @@ -2208,8 +2208,8 @@ suite('Editor Controller - Regression tests', () => { withTestCodeEditor([ 'Authorization: \'Bearer pHKRfCTFSnGxs6akKlb9ddIXcca0sIUSZJutPHYqz7vEeHdMTMh0SGN0IGU3a0n59DXjTLRsj5EJ2u33qLNIFi9fk5XF8pK39PndLYUZhPt4QvHGLScgSkK0L4gwzkzMloTQPpKhqiikiIOvyNNSpd2o8j29NnOmdTUOKi9DVt74PD2ohKxyOrWZ6oZprTkb3eKajcpnS0LABKfaw2rmv4\',' ].join('\n'), { wordWrap: 'wordWrapColumn', wordWrapColumn: 100 }, (editor, viewModel) => { - moveTo(viewModel, 1, 43, false); - moveTo(viewModel, 1, 147, true); + moveTo(editor, viewModel, 1, 43, false); + moveTo(editor, viewModel, 1, 147, true); assertCursor(viewModel, new Selection(1, 43, 1, 147)); editor.getModel().applyEdits([{ @@ -2231,16 +2231,16 @@ suite('Editor Controller - Regression tests', () => { ], {}, (editor, viewModel) => { viewModel.setSelections('test', [new Selection(1, 5, 1, 5)]); - moveDown(viewModel); + moveDown(editor, viewModel); assertCursor(viewModel, new Selection(2, 9, 2, 9)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(2, 10, 2, 10)); - moveRight(viewModel); + moveRight(editor, viewModel); assertCursor(viewModel, new Selection(2, 11, 2, 11)); - moveUp(viewModel); + moveUp(editor, viewModel); assertCursor(viewModel, new Selection(1, 6, 1, 6)); }); }); @@ -2471,8 +2471,8 @@ suite('Editor Controller - Cursor Configuration', () => { '', '1' ] - }, (model, viewModel) => { - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(1, 21), source: 'keyboard' }); + }, (editor, model, viewModel) => { + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(1, 21), source: 'keyboard' }); viewModel.type('\n', 'keyboard'); assert.equal(model.getLineContent(1), ' \tMy First Line\t '); assert.equal(model.getLineContent(2), ' '); @@ -2496,56 +2496,56 @@ suite('Editor Controller - Cursor Configuration', () => { withTestCodeEditor(null, { model: model }, (editor, viewModel) => { // Tab on column 1 - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(2, 1) }); + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(2, 1) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), ' My Second Line123'); CoreEditingCommands.Undo.runEditorCommand(null, editor, null); // Tab on column 2 assert.equal(model.getLineContent(2), 'My Second Line123'); - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(2, 2) }); + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(2, 2) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), 'M y Second Line123'); CoreEditingCommands.Undo.runEditorCommand(null, editor, null); // Tab on column 3 assert.equal(model.getLineContent(2), 'My Second Line123'); - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(2, 3) }); + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(2, 3) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), 'My Second Line123'); CoreEditingCommands.Undo.runEditorCommand(null, editor, null); // Tab on column 4 assert.equal(model.getLineContent(2), 'My Second Line123'); - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(2, 4) }); + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(2, 4) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), 'My Second Line123'); CoreEditingCommands.Undo.runEditorCommand(null, editor, null); // Tab on column 5 assert.equal(model.getLineContent(2), 'My Second Line123'); - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(2, 5) }); + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(2, 5) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), 'My S econd Line123'); CoreEditingCommands.Undo.runEditorCommand(null, editor, null); // Tab on column 5 assert.equal(model.getLineContent(2), 'My Second Line123'); - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(2, 5) }); + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(2, 5) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), 'My S econd Line123'); CoreEditingCommands.Undo.runEditorCommand(null, editor, null); // Tab on column 13 assert.equal(model.getLineContent(2), 'My Second Line123'); - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(2, 13) }); + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(2, 13) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), 'My Second Li ne123'); CoreEditingCommands.Undo.runEditorCommand(null, editor, null); // Tab on column 14 assert.equal(model.getLineContent(2), 'My Second Line123'); - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { position: new Position(2, 14) }); + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(2, 14) }); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), 'My Second Lin e123'); }); @@ -2560,8 +2560,8 @@ suite('Editor Controller - Cursor Configuration', () => { '\thello' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 1, 7, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 7, false); assertCursor(viewModel, new Selection(1, 7, 1, 7)); viewModel.type('\n', 'keyboard'); @@ -2577,8 +2577,8 @@ suite('Editor Controller - Cursor Configuration', () => { '\thello' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 1, 7, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 7, false); assertCursor(viewModel, new Selection(1, 7, 1, 7)); viewModel.type('\n', 'keyboard'); @@ -2594,8 +2594,8 @@ suite('Editor Controller - Cursor Configuration', () => { '\thell()' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 1, 7, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 7, false); assertCursor(viewModel, new Selection(1, 7, 1, 7)); viewModel.type('\n', 'keyboard'); @@ -2612,10 +2612,10 @@ suite('Editor Controller - Cursor Configuration', () => { modelOpts: { trimAutoWhitespace: false } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { // Move cursor to the end, verify that we do not trim whitespaces if line has values - moveTo(viewModel, 1, model.getLineContent(1).length + 1); + moveTo(editor, viewModel, 1, model.getLineContent(1).length + 1); viewModel.type('\n', 'keyboard'); assert.equal(model.getLineContent(1), ' some line abc '); assert.equal(model.getLineContent(2), ' '); @@ -2633,8 +2633,8 @@ suite('Editor Controller - Cursor Configuration', () => { text: [ ' ' ] - }, (model, viewModel) => { - moveTo(viewModel, 1, model.getLineContent(1).length + 1); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, model.getLineContent(1).length + 1); viewModel.type('\n', 'keyboard'); assert.equal(model.getLineContent(1), ' '); assert.equal(model.getLineContent(2), ' '); @@ -2653,9 +2653,9 @@ suite('Editor Controller - Cursor Configuration', () => { 'function foo (params: string) {}' ], languageIdentifier: mode.getLanguageIdentifier(), - }, (model, viewModel) => { + }, (editor, model, viewModel) => { - moveTo(viewModel, 1, 32); + moveTo(editor, viewModel, 1, 32); viewModel.type('\n', 'keyboard'); assert.equal(model.getLineContent(1), 'function foo (params: string) {'); assert.equal(model.getLineContent(2), ' '); @@ -2697,7 +2697,7 @@ suite('Editor Controller - Cursor Configuration', () => { withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 3, 1); + moveTo(editor, viewModel, 3, 1); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(1), ' if (a) {'); assert.equal(model.getLineContent(2), ' '); @@ -2705,7 +2705,7 @@ suite('Editor Controller - Cursor Configuration', () => { assert.equal(model.getLineContent(4), ''); assert.equal(model.getLineContent(5), ' }'); - moveTo(viewModel, 4, 1); + moveTo(editor, viewModel, 4, 1); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(1), ' if (a) {'); assert.equal(model.getLineContent(2), ' '); @@ -2713,7 +2713,7 @@ suite('Editor Controller - Cursor Configuration', () => { assert.equal(model.getLineContent(4), ' '); assert.equal(model.getLineContent(5), ' }'); - moveTo(viewModel, 5, model.getLineMaxColumn(5)); + moveTo(editor, viewModel, 5, model.getLineMaxColumn(5)); viewModel.type('something', 'keyboard'); assert.equal(model.getLineContent(1), ' if (a) {'); assert.equal(model.getLineContent(2), ' '); @@ -2735,7 +2735,7 @@ suite('Editor Controller - Cursor Configuration', () => { withTestCodeEditor(null, { model: model }, (editor, viewModel) => { // Move cursor to the end, verify that we do not trim whitespaces if line has values - moveTo(viewModel, 1, model.getLineContent(1).length + 1); + moveTo(editor, viewModel, 1, model.getLineContent(1).length + 1); viewModel.type('\n', 'keyboard'); assert.equal(model.getLineContent(1), ' some line abc '); assert.equal(model.getLineContent(2), ' '); @@ -2760,7 +2760,7 @@ suite('Editor Controller - Cursor Configuration', () => { assert.equal(model.getLineContent(4), ' '); // Trimmed if we will keep only text - moveTo(viewModel, 1, 5); + moveTo(editor, viewModel, 1, 5); viewModel.type('\n', 'keyboard'); assert.equal(model.getLineContent(1), ' '); assert.equal(model.getLineContent(2), ' some line abc '); @@ -2769,8 +2769,8 @@ suite('Editor Controller - Cursor Configuration', () => { assert.equal(model.getLineContent(5), ''); // Trimmed if we will keep only text by selection - moveTo(viewModel, 2, 5); - moveTo(viewModel, 3, 1, true); + moveTo(editor, viewModel, 2, 5); + moveTo(editor, viewModel, 3, 1, true); viewModel.type('\n', 'keyboard'); assert.equal(model.getLineContent(1), ' '); assert.equal(model.getLineContent(2), ' '); @@ -2794,7 +2794,7 @@ suite('Editor Controller - Cursor Configuration', () => { withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 3, model.getLineMaxColumn(3)); + moveTo(editor, viewModel, 3, model.getLineMaxColumn(3)); viewModel.type('\n', 'keyboard'); assert.equal(model.getValue(), [ @@ -2862,7 +2862,7 @@ suite('Editor Controller - Cursor Configuration', () => { withTestCodeEditor(null, { model: model, useTabStops: false }, (editor, viewModel) => { // DeleteLeft removes just one whitespace - moveTo(viewModel, 2, 9); + moveTo(editor, viewModel, 2, 9); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), ' a '); }); @@ -2881,12 +2881,12 @@ suite('Editor Controller - Cursor Configuration', () => { withTestCodeEditor(null, { model: model, useTabStops: true }, (editor, viewModel) => { // DeleteLeft does not remove tab size, because some text exists before - moveTo(viewModel, 2, model.getLineContent(2).length + 1); + moveTo(editor, viewModel, 2, model.getLineContent(2).length + 1); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), ' a '); // DeleteLeft removes tab size = 4 - moveTo(viewModel, 2, 9); + moveTo(editor, viewModel, 2, 9); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), ' a '); @@ -2899,12 +2899,12 @@ suite('Editor Controller - Cursor Configuration', () => { assert.equal(model.getLineContent(2), ' a '); // Nothing is broken when cursor is in (1,1) - moveTo(viewModel, 1, 1); + moveTo(editor, viewModel, 1, 1); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(1), ' \t \t x'); // DeleteLeft stops at tab stops even in mixed whitespace case - moveTo(viewModel, 1, 10); + moveTo(editor, viewModel, 1, 10); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(1), ' \t \t x'); @@ -2918,7 +2918,7 @@ suite('Editor Controller - Cursor Configuration', () => { assert.equal(model.getLineContent(1), 'x'); // DeleteLeft on last line - moveTo(viewModel, 3, model.getLineContent(3).length + 1); + moveTo(editor, viewModel, 3, model.getLineContent(3).length + 1); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(3), ''); @@ -2927,8 +2927,8 @@ suite('Editor Controller - Cursor Configuration', () => { assert.equal(model.getValue(EndOfLinePreference.LF), 'x\n a '); // In case of selection DeleteLeft only deletes selected text - moveTo(viewModel, 2, 3); - moveTo(viewModel, 2, 4, true); + moveTo(editor, viewModel, 2, 3); + moveTo(editor, viewModel, 2, 4, true); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(2), ' a '); }); @@ -2962,7 +2962,7 @@ suite('Editor Controller - Cursor Configuration', () => { viewModel.type('x'); assert.equal(model.getValue(EndOfLinePreference.LF), '\n\ty\n\tx', 'assert4'); - CoreNavigationCommands.CursorLeft.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorLeft.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); assert.equal(model.getValue(EndOfLinePreference.LF), '\n\ty\n\tx', 'assert5'); CoreEditingCommands.DeleteLeft.runEditorCommand(null, editor, null); @@ -3047,15 +3047,15 @@ suite('Editor Controller - Indentation Rules', () => { languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false }, editorOpts: { autoIndent: 'full' } - }, (model, viewModel) => { - moveTo(viewModel, 1, 12, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 12, false); assertCursor(viewModel, new Selection(1, 12, 1, 12)); viewModel.type('\n', 'keyboard'); model.forceTokenization(model.getLineCount()); assertCursor(viewModel, new Selection(2, 2, 2, 2)); - moveTo(viewModel, 3, 13, false); + moveTo(editor, viewModel, 3, 13, false); assertCursor(viewModel, new Selection(3, 13, 3, 13)); viewModel.type('\n', 'keyboard'); @@ -3071,8 +3071,8 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), editorOpts: { autoIndent: 'full' } - }, (model, viewModel) => { - moveTo(viewModel, 2, 2, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 2, false); assertCursor(viewModel, new Selection(2, 2, 2, 2)); viewModel.type('}', 'keyboard'); @@ -3090,8 +3090,8 @@ suite('Editor Controller - Indentation Rules', () => { languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false }, editorOpts: { autoIndent: 'full' } - }, (model, viewModel) => { - moveTo(viewModel, 2, 15, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 15, false); assertCursor(viewModel, new Selection(2, 15, 2, 15)); viewModel.type('\n', 'keyboard'); @@ -3110,15 +3110,15 @@ suite('Editor Controller - Indentation Rules', () => { languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false }, editorOpts: { autoIndent: 'full' } - }, (model, viewModel) => { - moveTo(viewModel, 2, 14, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 14, false); assertCursor(viewModel, new Selection(2, 14, 2, 14)); viewModel.type('\n', 'keyboard'); model.forceTokenization(model.getLineCount()); assertCursor(viewModel, new Selection(3, 1, 3, 1)); - moveTo(viewModel, 5, 16, false); + moveTo(editor, viewModel, 5, 16, false); assertCursor(viewModel, new Selection(5, 16, 5, 16)); viewModel.type('\n', 'keyboard'); @@ -3139,7 +3139,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model, autoIndent: 'full' }, (editor, viewModel) => { - moveTo(viewModel, 2, 11, false); + moveTo(editor, viewModel, 2, 11, false); assertCursor(viewModel, new Selection(2, 11, 2, 11)); viewModel.type('\n', 'keyboard'); @@ -3164,8 +3164,8 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), editorOpts: { autoIndent: 'full' } - }, (model, viewModel) => { - moveTo(viewModel, 3, 13, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 13, false); assertCursor(viewModel, new Selection(3, 13, 3, 13)); viewModel.type('\n', 'keyboard'); @@ -3184,9 +3184,9 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 4, 3, false); - moveTo(viewModel, 4, 4, true); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 4, 3, false); + moveTo(editor, viewModel, 4, 4, true); assertCursor(viewModel, new Selection(4, 3, 4, 4)); viewModel.type('\n', 'keyboard'); @@ -3203,9 +3203,9 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 2, 12, false); - moveTo(viewModel, 2, 13, true); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 12, false); + moveTo(editor, viewModel, 2, 13, true); assertCursor(viewModel, new Selection(2, 12, 2, 13)); viewModel.type('\n', 'keyboard'); @@ -3223,8 +3223,8 @@ suite('Editor Controller - Indentation Rules', () => { '\tif (true) {' ], languageIdentifier: mode.getLanguageIdentifier(), - }, (model, viewModel) => { - moveTo(viewModel, 1, 12, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 12, false); assertCursor(viewModel, new Selection(1, 12, 1, 12)); viewModel.type('\n', 'keyboard'); @@ -3232,7 +3232,7 @@ suite('Editor Controller - Indentation Rules', () => { model.forceTokenization(model.getLineCount()); - moveTo(viewModel, 3, 13, false); + moveTo(editor, viewModel, 3, 13, false); assertCursor(viewModel, new Selection(3, 13, 3, 13)); viewModel.type('\n', 'keyboard'); @@ -3247,15 +3247,15 @@ suite('Editor Controller - Indentation Rules', () => { ' if (true) {' ], languageIdentifier: mode.getLanguageIdentifier(), - }, (model, viewModel) => { - moveTo(viewModel, 1, 12, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 12, false); assertCursor(viewModel, new Selection(1, 12, 1, 12)); viewModel.type('\n', 'keyboard'); model.forceTokenization(model.getLineCount()); assertCursor(viewModel, new Selection(2, 5, 2, 5)); - moveTo(viewModel, 3, 16, false); + moveTo(editor, viewModel, 3, 16, false); assertCursor(viewModel, new Selection(3, 16, 3, 16)); viewModel.type('\n', 'keyboard'); @@ -3272,15 +3272,15 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 1, 12, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 12, false); assertCursor(viewModel, new Selection(1, 12, 1, 12)); viewModel.type('\n', 'keyboard'); model.forceTokenization(model.getLineCount()); assertCursor(viewModel, new Selection(2, 2, 2, 2)); - moveTo(viewModel, 3, 16, false); + moveTo(editor, viewModel, 3, 16, false); assertCursor(viewModel, new Selection(3, 16, 3, 16)); viewModel.type('\n', 'keyboard'); @@ -3302,8 +3302,8 @@ suite('Editor Controller - Indentation Rules', () => { languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false }, editorOpts: { autoIndent: 'full' } - }, (model, viewModel) => { - moveTo(viewModel, 5, 4, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 5, 4, false); assertCursor(viewModel, new Selection(5, 4, 5, 4)); viewModel.type('\n', 'keyboard'); @@ -3322,8 +3322,8 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 3, 9, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 9, false); assertCursor(viewModel, new Selection(3, 9, 3, 9)); viewModel.type('\n', 'keyboard'); @@ -3342,8 +3342,8 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 3, 3, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 3, false); assertCursor(viewModel, new Selection(3, 3, 3, 3)); viewModel.type('\n', 'keyboard'); @@ -3361,8 +3361,8 @@ suite('Editor Controller - Indentation Rules', () => { ' }a}' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 3, 11, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 11, false); assertCursor(viewModel, new Selection(3, 11, 3, 11)); viewModel.type('\n', 'keyboard'); @@ -3381,15 +3381,15 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 3, 2, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 2, false); assertCursor(viewModel, new Selection(3, 2, 3, 2)); viewModel.type('\n', 'keyboard'); assertCursor(viewModel, new Selection(4, 2, 4, 2)); assert.equal(model.getLineContent(4), '\t\treturn true;', '001'); - moveTo(viewModel, 4, 1, false); + moveTo(editor, viewModel, 4, 1, false); assertCursor(viewModel, new Selection(4, 1, 4, 1)); viewModel.type('\n', 'keyboard'); @@ -3408,15 +3408,15 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 3, 4, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 4, false); assertCursor(viewModel, new Selection(3, 4, 3, 4)); viewModel.type('\n', 'keyboard'); assertCursor(viewModel, new Selection(4, 3, 4, 3)); assert.equal(model.getLineContent(4), '\t\t\treturn true;', '001'); - moveTo(viewModel, 4, 1, false); + moveTo(editor, viewModel, 4, 1, false); assertCursor(viewModel, new Selection(4, 1, 4, 1)); viewModel.type('\n', 'keyboard'); @@ -3434,15 +3434,15 @@ suite('Editor Controller - Indentation Rules', () => { '}a}' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 3, 2, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 2, false); assertCursor(viewModel, new Selection(3, 2, 3, 2)); viewModel.type('\n', 'keyboard'); assertCursor(viewModel, new Selection(4, 2, 4, 2)); assert.equal(model.getLineContent(4), ' return true;', '001'); - moveTo(viewModel, 4, 3, false); + moveTo(editor, viewModel, 4, 3, false); viewModel.type('\n', 'keyboard'); assertCursor(viewModel, new Selection(5, 3, 5, 3)); assert.equal(model.getLineContent(5), ' return true;', '002'); @@ -3467,15 +3467,15 @@ suite('Editor Controller - Indentation Rules', () => { tabSize: 2, indentSize: 2 } - }, (model, viewModel) => { - moveTo(viewModel, 3, 3, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 3, false); assertCursor(viewModel, new Selection(3, 3, 3, 3)); viewModel.type('\n', 'keyboard'); assertCursor(viewModel, new Selection(4, 4, 4, 4)); assert.equal(model.getLineContent(4), ' return true;', '001'); - moveTo(viewModel, 9, 4, false); + moveTo(editor, viewModel, 9, 4, false); viewModel.type('\n', 'keyboard'); assertCursor(viewModel, new Selection(10, 5, 10, 5)); assert.equal(model.getLineContent(10), ' return true;', '001'); @@ -3493,9 +3493,9 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), modelOpts: { tabSize: 2 } - }, (model, viewModel) => { - moveTo(viewModel, 3, 5, false); - moveTo(viewModel, 4, 3, true); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 5, false); + moveTo(editor, viewModel, 4, 3, true); assertCursor(viewModel, new Selection(3, 5, 4, 3)); viewModel.type('\n', 'keyboard'); @@ -3516,9 +3516,9 @@ suite('Editor Controller - Indentation Rules', () => { insertSpaces: false, }, languageIdentifier: mode.getLanguageIdentifier(), - }, (model, viewModel) => { - moveTo(viewModel, 3, 8, false); - moveTo(viewModel, 2, 12, true); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 8, false); + moveTo(editor, viewModel, 2, 12, true); assertCursor(viewModel, new Selection(3, 8, 2, 12)); viewModel.type('\n', 'keyboard'); @@ -3539,9 +3539,9 @@ suite('Editor Controller - Indentation Rules', () => { insertSpaces: false, }, languageIdentifier: mode.getLanguageIdentifier(), - }, (model, viewModel) => { - moveTo(viewModel, 2, 12, false); - moveTo(viewModel, 3, 8, true); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 12, false); + moveTo(editor, viewModel, 3, 8, true); assertCursor(viewModel, new Selection(2, 12, 3, 8)); viewModel.type('\n', 'keyboard'); @@ -3561,8 +3561,8 @@ suite('Editor Controller - Indentation Rules', () => { '?>' ], modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 5, 3, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 5, 3, false); assertCursor(viewModel, new Selection(5, 3, 5, 3)); viewModel.type('\n', 'keyboard'); @@ -3580,8 +3580,8 @@ suite('Editor Controller - Indentation Rules', () => { ' ' ], modelOpts: { insertSpaces: false } - }, (model, viewModel) => { - moveTo(viewModel, 3, 2, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 2, false); assertCursor(viewModel, new Selection(3, 2, 3, 2)); viewModel.type('\n', 'keyboard'); @@ -3607,7 +3607,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 4, 1, false); + moveTo(editor, viewModel, 4, 1, false); assertCursor(viewModel, new Selection(4, 1, 4, 1)); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -3635,7 +3635,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 4, 2, false); + moveTo(editor, viewModel, 4, 2, false); assertCursor(viewModel, new Selection(4, 2, 4, 2)); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -3663,7 +3663,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 4, 1, false); + moveTo(editor, viewModel, 4, 1, false); assertCursor(viewModel, new Selection(4, 1, 4, 1)); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -3690,7 +3690,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 4, 3, false); + moveTo(editor, viewModel, 4, 3, false); assertCursor(viewModel, new Selection(4, 3, 4, 3)); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -3717,7 +3717,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 4, 4, false); + moveTo(editor, viewModel, 4, 4, false); assertCursor(viewModel, new Selection(4, 4, 4, 4)); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -3743,7 +3743,7 @@ suite('Editor Controller - Indentation Rules', () => { withTestCodeEditor(null, { model: model }, (editor, viewModel) => { - moveTo(viewModel, 3, 1); + moveTo(editor, viewModel, 3, 1); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); assert.equal(model.getLineContent(1), ' if (a) {'); assert.equal(model.getLineContent(2), ' '); @@ -3772,7 +3772,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model, autoIndent: 'full' }, (editor, viewModel) => { - moveTo(viewModel, 4, 7, false); + moveTo(editor, viewModel, 4, 7, false); assertCursor(viewModel, new Selection(4, 7, 4, 7)); viewModel.type('d', 'keyboard'); @@ -3793,8 +3793,8 @@ suite('Editor Controller - Indentation Rules', () => { '\t}' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 5, 3, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 5, 3, false); assertCursor(viewModel, new Selection(5, 3, 5, 3)); viewModel.type('e', 'keyboard'); @@ -3814,8 +3814,8 @@ suite('Editor Controller - Indentation Rules', () => { '}' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 3, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 3, false); assertCursor(viewModel, new Selection(2, 3, 2, 3)); viewModel.type(' ', 'keyboard'); @@ -3833,8 +3833,8 @@ suite('Editor Controller - Indentation Rules', () => { ], languageIdentifier: mode.getLanguageIdentifier(), editorOpts: { autoIndent: 'full' } - }, (model, viewModel) => { - moveTo(viewModel, 3, 3, false); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 3, false); assertCursor(viewModel, new Selection(3, 3, 3, 3)); viewModel.type('}', 'keyboard'); @@ -3882,7 +3882,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model, autoIndent: 'advanced' }, (editor, viewModel) => { - moveTo(viewModel, 7, 6, false); + moveTo(editor, viewModel, 7, 6, false); assertCursor(viewModel, new Selection(7, 6, 7, 6)); viewModel.type('\n', 'keyboard'); @@ -3946,7 +3946,7 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model, autoIndent: 'advanced' }, (editor, viewModel) => { - moveTo(viewModel, 8, 1, false); + moveTo(editor, viewModel, 8, 1, false); assertCursor(viewModel, new Selection(8, 1, 8, 1)); CoreEditingCommands.Tab.runEditorCommand(null, editor, null); @@ -4009,26 +4009,26 @@ suite('Editor Controller - Indentation Rules', () => { ); withTestCodeEditor(null, { model: model, autoIndent: 'full' }, (editor, viewModel) => { - moveTo(viewModel, 3, 19, false); + moveTo(editor, viewModel, 3, 19, false); assertCursor(viewModel, new Selection(3, 19, 3, 19)); viewModel.type('\n', 'keyboard'); assert.deepEqual(model.getLineContent(4), ' '); - moveTo(viewModel, 5, 18, false); + moveTo(editor, viewModel, 5, 18, false); assertCursor(viewModel, new Selection(5, 18, 5, 18)); viewModel.type('\n', 'keyboard'); assert.deepEqual(model.getLineContent(6), ' '); - moveTo(viewModel, 7, 15, false); + moveTo(editor, viewModel, 7, 15, false); assertCursor(viewModel, new Selection(7, 15, 7, 15)); viewModel.type('\n', 'keyboard'); assert.deepEqual(model.getLineContent(8), ' '); assert.deepEqual(model.getLineContent(9), ' ]'); - moveTo(viewModel, 10, 18, false); + moveTo(editor, viewModel, 10, 18, false); assertCursor(viewModel, new Selection(10, 18, 10, 18)); viewModel.type('\n', 'keyboard'); @@ -4047,12 +4047,12 @@ interface ICursorOpts { editorOpts?: IEditorOptions; } -function usingCursor(opts: ICursorOpts, callback: (model: TextModel, viewModel: ViewModel) => void): void { +function usingCursor(opts: ICursorOpts, callback: (editor: ITestCodeEditor, model: TextModel, viewModel: ViewModel) => void): void { const model = createTextModel(opts.text.join('\n'), opts.modelOpts, opts.languageIdentifier); const editorOptions: TestCodeEditorCreationOptions = opts.editorOpts || {}; editorOptions.model = model; withTestCodeEditor(null, editorOptions, (editor, viewModel) => { - callback(model, viewModel); + callback(editor, model, viewModel); }); } @@ -4084,8 +4084,8 @@ suite('ElectricCharacter', () => { '' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 1); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 1); viewModel.type('*', 'keyboard'); assert.deepEqual(model.getLineContent(2), '*'); }); @@ -4100,8 +4100,8 @@ suite('ElectricCharacter', () => { '' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 1); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 1); viewModel.type('}', 'keyboard'); assert.deepEqual(model.getLineContent(2), ' }'); }); @@ -4116,8 +4116,8 @@ suite('ElectricCharacter', () => { ' ' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 5); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 5); viewModel.type('}', 'keyboard'); assert.deepEqual(model.getLineContent(2), ' }'); }); @@ -4134,8 +4134,8 @@ suite('ElectricCharacter', () => { ' ' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 4, 1); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 4, 1); viewModel.type('}', 'keyboard'); assert.deepEqual(model.getLineContent(4), ' } '); }); @@ -4152,8 +4152,8 @@ suite('ElectricCharacter', () => { ' } ' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 4, 6); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 4, 6); viewModel.type('}', 'keyboard'); assert.deepEqual(model.getLineContent(4), ' } }'); }); @@ -4168,8 +4168,8 @@ suite('ElectricCharacter', () => { '// hello' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 1); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 1); viewModel.type('}', 'keyboard'); assert.deepEqual(model.getLineContent(2), ' }// hello'); }); @@ -4184,8 +4184,8 @@ suite('ElectricCharacter', () => { ' ' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 3); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 3); viewModel.type('}', 'keyboard'); assert.deepEqual(model.getLineContent(2), ' }'); }); @@ -4200,8 +4200,8 @@ suite('ElectricCharacter', () => { 'a' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 2); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 2); viewModel.type('}', 'keyboard'); assert.deepEqual(model.getLineContent(2), 'a}'); }); @@ -4217,8 +4217,8 @@ suite('ElectricCharacter', () => { '})' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 13); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 13); viewModel.type('*', 'keyboard'); assert.deepEqual(model.getLineContent(2), ' ( 1 + 2 ) *'); }); @@ -4232,8 +4232,8 @@ suite('ElectricCharacter', () => { '(div', ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 1, 5); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 1, 5); let changeText: string | null = null; model.onDidChangeContent(e => { changeText = e.changes[0].text; @@ -4254,8 +4254,8 @@ suite('ElectricCharacter', () => { '\t3' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 3, 3); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 3, 3); viewModel.type(')', 'keyboard'); assert.deepEqual(model.getLineContent(3), '\t3)'); }); @@ -4270,8 +4270,8 @@ suite('ElectricCharacter', () => { '/*' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 3); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 3); viewModel.type('*', 'keyboard'); assert.deepEqual(model.getLineContent(2), '/** */'); }); @@ -4286,8 +4286,8 @@ suite('ElectricCharacter', () => { ' /*' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 5); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 5); viewModel.type('*', 'keyboard'); assert.deepEqual(model.getLineContent(2), ' /** */'); }); @@ -4302,9 +4302,9 @@ suite('ElectricCharacter', () => { 'word' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - moveTo(viewModel, 2, 5); - moveTo(viewModel, 2, 1, true); + }, (editor, model, viewModel) => { + moveTo(editor, viewModel, 2, 5); + moveTo(editor, viewModel, 2, 1, true); viewModel.type('}', 'keyboard'); assert.deepEqual(model.getLineContent(2), '}'); }); @@ -4377,10 +4377,10 @@ suite('autoClosingPairs', () => { return result; } - function assertType(model: TextModel, viewModel: ViewModel, lineNumber: number, column: number, chr: string, expectedInsert: string, message: string): void { + function assertType(editor: ITestCodeEditor, model: TextModel, viewModel: ViewModel, lineNumber: number, column: number, chr: string, expectedInsert: string, message: string): void { let lineContent = model.getLineContent(lineNumber); let expected = lineContent.substr(0, column - 1) + expectedInsert + lineContent.substr(column - 1); - moveTo(viewModel, lineNumber, column); + moveTo(editor, viewModel, lineNumber, column); viewModel.type(chr, 'keyboard'); assert.deepEqual(model.getLineContent(lineNumber), expected, message); model.undo(); @@ -4400,7 +4400,7 @@ suite('autoClosingPairs', () => { 'var h = { a: \'value\' };', ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { let autoClosePositions = [ 'var| a| |=| [|]|;|', @@ -4419,9 +4419,9 @@ suite('autoClosingPairs', () => { for (let column = 1; column < autoCloseColumns.length; column++) { model.forceTokenization(lineNumber); if (autoCloseColumns[column] === ColumnType.Special1) { - assertType(model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); } else { - assertType(model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); } } } @@ -4446,7 +4446,7 @@ suite('autoClosingPairs', () => { editorOpts: { autoClosingBrackets: 'beforeWhitespace' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { let autoClosePositions = [ 'var| a| =| [|];|', @@ -4465,9 +4465,9 @@ suite('autoClosingPairs', () => { for (let column = 1; column < autoCloseColumns.length; column++) { model.forceTokenization(lineNumber); if (autoCloseColumns[column] === ColumnType.Special1) { - assertType(model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); } else { - assertType(model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); } } } @@ -4486,7 +4486,7 @@ suite('autoClosingPairs', () => { autoClosingBrackets: 'beforeWhitespace', autoClosingQuotes: 'never' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { let autoClosePositions = [ 'var| a| =| [|];|', @@ -4498,11 +4498,11 @@ suite('autoClosingPairs', () => { for (let column = 1; column < autoCloseColumns.length; column++) { model.forceTokenization(lineNumber); if (autoCloseColumns[column] === ColumnType.Special1) { - assertType(model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); } else { - assertType(model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); } - assertType(model, viewModel, lineNumber, column, '\'', '\'', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '\'', '\'', `does not auto close @ (${lineNumber}, ${column})`); } } }); @@ -4516,7 +4516,7 @@ suite('autoClosingPairs', () => { autoClosingBrackets: 'never', autoClosingQuotes: 'beforeWhitespace' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { let autoClosePositions = [ 'var b =| [|];|', @@ -4528,11 +4528,11 @@ suite('autoClosingPairs', () => { for (let column = 1; column < autoCloseColumns.length; column++) { model.forceTokenization(lineNumber); if (autoCloseColumns[column] === ColumnType.Special1) { - assertType(model, viewModel, lineNumber, column, '\'', '\'\'', `auto closes @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '\'', '\'\'', `auto closes @ (${lineNumber}, ${column})`); } else { - assertType(model, viewModel, lineNumber, column, '\'', '\'', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '\'', '\'', `does not auto close @ (${lineNumber}, ${column})`); } - assertType(model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); } } }); @@ -4557,7 +4557,7 @@ suite('autoClosingPairs', () => { editorOpts: { autoClosingBrackets: 'languageDefined' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { let autoClosePositions = [ 'v|ar |a = [|];|', @@ -4576,9 +4576,9 @@ suite('autoClosingPairs', () => { for (let column = 1; column < autoCloseColumns.length; column++) { model.forceTokenization(lineNumber); if (autoCloseColumns[column] === ColumnType.Special1) { - assertType(model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); } else { - assertType(model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); } } } @@ -4604,7 +4604,7 @@ suite('autoClosingPairs', () => { autoClosingBrackets: 'never', autoClosingQuotes: 'never' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { let autoClosePositions = [ 'var a = [];', @@ -4623,11 +4623,11 @@ suite('autoClosingPairs', () => { for (let column = 1; column < autoCloseColumns.length; column++) { model.forceTokenization(lineNumber); if (autoCloseColumns[column] === ColumnType.Special1) { - assertType(model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); - assertType(model, viewModel, lineNumber, column, '"', '""', `auto closes @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '()', `auto closes @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '"', '""', `auto closes @ (${lineNumber}, ${column})`); } else { - assertType(model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); - assertType(model, viewModel, lineNumber, column, '"', '"', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '(', '(', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '"', '"', `does not auto close @ (${lineNumber}, ${column})`); } } } @@ -4642,7 +4642,7 @@ suite('autoClosingPairs', () => { 'var a = asd' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [ new Selection(1, 1, 1, 4), @@ -4668,7 +4668,7 @@ suite('autoClosingPairs', () => { editorOpts: { autoSurround: 'never' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [ new Selection(1, 1, 1, 4), @@ -4688,7 +4688,7 @@ suite('autoClosingPairs', () => { editorOpts: { autoSurround: 'quotes' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [ new Selection(1, 1, 1, 4), @@ -4711,7 +4711,7 @@ suite('autoClosingPairs', () => { editorOpts: { autoSurround: 'brackets' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [ new Selection(1, 1, 1, 4), @@ -4742,7 +4742,7 @@ suite('autoClosingPairs', () => { 'var h = { a: \'value\' };', ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { let autoClosePositions = [ 'var a |=| [|]|;|', @@ -4761,11 +4761,11 @@ suite('autoClosingPairs', () => { for (let column = 1; column < autoCloseColumns.length; column++) { model.forceTokenization(lineNumber); if (autoCloseColumns[column] === ColumnType.Special1) { - assertType(model, viewModel, lineNumber, column, '\'', '\'\'', `auto closes @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '\'', '\'\'', `auto closes @ (${lineNumber}, ${column})`); } else if (autoCloseColumns[column] === ColumnType.Special2) { - assertType(model, viewModel, lineNumber, column, '\'', '', `over types @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '\'', '', `over types @ (${lineNumber}, ${column})`); } else { - assertType(model, viewModel, lineNumber, column, '\'', '\'', `does not auto close @ (${lineNumber}, ${column})`); + assertType(editor, model, viewModel, lineNumber, column, '\'', '\'', `does not auto close @ (${lineNumber}, ${column})`); } } } @@ -4780,7 +4780,7 @@ suite('autoClosingPairs', () => { '', ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { model.setValue('begi'); viewModel.setSelections('test', [new Selection(1, 5, 1, 5)]); @@ -4825,17 +4825,17 @@ suite('autoClosingPairs', () => { 'Big LAMB' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { model.forceTokenization(model.getLineCount()); - assertType(model, viewModel, 1, 4, '"', '"', `does not double quote when ending with open`); + assertType(editor, model, viewModel, 1, 4, '"', '"', `does not double quote when ending with open`); model.forceTokenization(model.getLineCount()); - assertType(model, viewModel, 2, 4, '"', '"', `does not double quote when ending with open`); + assertType(editor, model, viewModel, 2, 4, '"', '"', `does not double quote when ending with open`); model.forceTokenization(model.getLineCount()); - assertType(model, viewModel, 3, 4, '"', '"', `does not double quote when ending with open`); + assertType(editor, model, viewModel, 3, 4, '"', '"', `does not double quote when ending with open`); model.forceTokenization(model.getLineCount()); - assertType(model, viewModel, 4, 2, '"', '"', `does not double quote when ending with open`); + assertType(editor, model, viewModel, 4, 2, '"', '"', `does not double quote when ending with open`); model.forceTokenization(model.getLineCount()); - assertType(model, viewModel, 4, 3, '"', '"', `does not double quote when ending with open`); + assertType(editor, model, viewModel, 4, 3, '"', '"', `does not double quote when ending with open`); }); mode.dispose(); }); @@ -4847,8 +4847,8 @@ suite('autoClosingPairs', () => { 'var arr = ["b", "c"];' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - assertType(model, viewModel, 1, 12, '"', '""', `does not over type and will auto close`); + }, (editor, model, viewModel) => { + assertType(editor, model, viewModel, 1, 12, '"', '""', `does not over type and will auto close`); }); mode.dispose(); }); @@ -4860,7 +4860,7 @@ suite('autoClosingPairs', () => { '', ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { function typeCharacters(viewModel: ViewModel, chars: string): void { for (let i = 0, len = chars.length; i < len; i++) { @@ -4927,7 +4927,7 @@ suite('autoClosingPairs', () => { 'y=();' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { assertCursor(viewModel, new Position(1, 1)); viewModel.type('x=(', 'keyboard'); @@ -4957,7 +4957,7 @@ suite('autoClosingPairs', () => { 'y=();' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { assertCursor(viewModel, new Position(1, 1)); viewModel.type('x=(', 'keyboard'); @@ -4978,7 +4978,7 @@ suite('autoClosingPairs', () => { 'y=();' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { assertCursor(viewModel, new Position(1, 1)); viewModel.type('x=(', 'keyboard'); @@ -5002,7 +5002,7 @@ suite('autoClosingPairs', () => { 'y=();' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { assertCursor(viewModel, new Position(1, 1)); viewModel.type('x=(', 'keyboard'); @@ -5027,7 +5027,7 @@ suite('autoClosingPairs', () => { 'std::cout << \'"\' << entryMap' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 29, 1, 29)]); viewModel.type('[', 'keyboard'); @@ -5087,8 +5087,8 @@ suite('autoClosingPairs', () => { 'foo\'hello\'' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { - assertType(model, viewModel, 1, 4, '(', '(', `does not auto close @ (1, 4)`); + }, (editor, model, viewModel) => { + assertType(editor, model, viewModel, 1, 4, '(', '(', `does not auto close @ (1, 4)`); }); mode.dispose(); }); @@ -5100,7 +5100,7 @@ suite('autoClosingPairs', () => { '
{ + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 8, 1, 8)]); viewModel.executeEdits('snippet', [{ range: new Range(1, 6, 1, 8), text: 'id=""' }], () => [new Selection(1, 10, 1, 10)]); @@ -5126,7 +5126,7 @@ suite('autoClosingPairs', () => { editorOpts: { autoClosingOvertype: 'always' } - }, (model, viewModel) => { + }, (editor, model, viewModel) => { assertCursor(viewModel, new Position(1, 1)); viewModel.type('x=(', 'keyboard'); @@ -5152,7 +5152,7 @@ suite('autoClosingPairs', () => { text: [ ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { assertCursor(viewModel, new Position(1, 1)); // Typing ` + e on the mac US intl kb layout @@ -5173,7 +5173,7 @@ suite('autoClosingPairs', () => { 'test' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 1, 1, 5)]); // Typing ` + e on the mac US intl kb layout @@ -5195,7 +5195,7 @@ suite('autoClosingPairs', () => { 'console.log();' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 13, 1, 13)]); @@ -5221,7 +5221,7 @@ suite('autoClosingPairs', () => { '' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 1, 1, 1)]); @@ -5251,14 +5251,14 @@ suite('autoClosingPairs', () => { 'world' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { assertCursor(viewModel, new Position(1, 1)); // Typing ` and pressing shift+down on the mac US intl kb layout // Here we're just replaying what the cursor gets viewModel.startComposition(); viewModel.type('`', 'keyboard'); - moveDown(viewModel, true); + moveDown(editor, viewModel, true); viewModel.replacePreviousChar('`', 1, 'keyboard'); viewModel.replacePreviousChar('`', 1, 'keyboard'); viewModel.endComposition('keyboard'); @@ -5276,7 +5276,7 @@ suite('autoClosingPairs', () => { '' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { assertCursor(viewModel, new Position(1, 1)); // on the mac US intl kb layout @@ -5343,7 +5343,7 @@ suite('autoClosingPairs', () => { '{}' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [new Selection(1, 2, 1, 2)]); // Typing a + backspace @@ -5363,7 +5363,7 @@ suite('autoClosingPairs', () => { 'var a = asd' ], languageIdentifier: mode.getLanguageIdentifier() - }, (model, viewModel) => { + }, (editor, model, viewModel) => { viewModel.setSelections('test', [ new Selection(1, 9, 1, 9), diff --git a/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts b/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts index de8fb60b241b23003777b329d5a8932d38f96e93..bd569cd160abfeb72836eee15cafd1e7948966e6 100644 --- a/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts +++ b/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts @@ -30,7 +30,7 @@ suite('Cursor move command test', () => { test('move left should move to left character', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveLeft(editor, viewModel); cursorEqual(viewModel, 1, 7); }); @@ -38,7 +38,7 @@ suite('Cursor move command test', () => { test('move left should move to left by n characters', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveLeft(editor, viewModel, 3); cursorEqual(viewModel, 1, 5); }); @@ -46,7 +46,7 @@ suite('Cursor move command test', () => { test('move left should move to left by half line', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveLeft(editor, viewModel, 1, CursorMove.RawUnit.HalfLine); cursorEqual(viewModel, 1, 1); }); @@ -54,7 +54,7 @@ suite('Cursor move command test', () => { test('move left moves to previous line', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 2, 3); + moveTo(editor, viewModel, 2, 3); moveLeft(editor, viewModel, 10); cursorEqual(viewModel, 1, 21); }); @@ -62,7 +62,7 @@ suite('Cursor move command test', () => { test('move right should move to right character', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 5); + moveTo(editor, viewModel, 1, 5); moveRight(editor, viewModel); cursorEqual(viewModel, 1, 6); }); @@ -70,7 +70,7 @@ suite('Cursor move command test', () => { test('move right should move to right by n characters', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 2); + moveTo(editor, viewModel, 1, 2); moveRight(editor, viewModel, 6); cursorEqual(viewModel, 1, 8); }); @@ -78,7 +78,7 @@ suite('Cursor move command test', () => { test('move right should move to right by half line', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 4); + moveTo(editor, viewModel, 1, 4); moveRight(editor, viewModel, 1, CursorMove.RawUnit.HalfLine); cursorEqual(viewModel, 1, 14); }); @@ -86,7 +86,7 @@ suite('Cursor move command test', () => { test('move right moves to next line', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveRight(editor, viewModel, 100); cursorEqual(viewModel, 2, 1); }); @@ -94,7 +94,7 @@ suite('Cursor move command test', () => { test('move to first character of line from middle', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveToLineStart(editor, viewModel); cursorEqual(viewModel, 1, 1); }); @@ -102,7 +102,7 @@ suite('Cursor move command test', () => { test('move to first character of line from first non white space character', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 6); + moveTo(editor, viewModel, 1, 6); moveToLineStart(editor, viewModel); cursorEqual(viewModel, 1, 1); }); @@ -110,7 +110,7 @@ suite('Cursor move command test', () => { test('move to first character of line from first character', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 1); + moveTo(editor, viewModel, 1, 1); moveToLineStart(editor, viewModel); cursorEqual(viewModel, 1, 1); }); @@ -118,7 +118,7 @@ suite('Cursor move command test', () => { test('move to first non white space character of line from middle', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveToLineFirstNonWhitespaceCharacter(editor, viewModel); cursorEqual(viewModel, 1, 6); }); @@ -126,7 +126,7 @@ suite('Cursor move command test', () => { test('move to first non white space character of line from first non white space character', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 6); + moveTo(editor, viewModel, 1, 6); moveToLineFirstNonWhitespaceCharacter(editor, viewModel); cursorEqual(viewModel, 1, 6); }); @@ -134,7 +134,7 @@ suite('Cursor move command test', () => { test('move to first non white space character of line from first character', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 1); + moveTo(editor, viewModel, 1, 1); moveToLineFirstNonWhitespaceCharacter(editor, viewModel); cursorEqual(viewModel, 1, 6); }); @@ -142,7 +142,7 @@ suite('Cursor move command test', () => { test('move to end of line from middle', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveToLineEnd(editor, viewModel); cursorEqual(viewModel, 1, 21); }); @@ -150,7 +150,7 @@ suite('Cursor move command test', () => { test('move to end of line from last non white space character', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 19); + moveTo(editor, viewModel, 1, 19); moveToLineEnd(editor, viewModel); cursorEqual(viewModel, 1, 21); }); @@ -158,7 +158,7 @@ suite('Cursor move command test', () => { test('move to end of line from line end', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 21); + moveTo(editor, viewModel, 1, 21); moveToLineEnd(editor, viewModel); cursorEqual(viewModel, 1, 21); }); @@ -166,7 +166,7 @@ suite('Cursor move command test', () => { test('move to last non white space character from middle', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveToLineLastNonWhitespaceCharacter(editor, viewModel); cursorEqual(viewModel, 1, 19); }); @@ -174,7 +174,7 @@ suite('Cursor move command test', () => { test('move to last non white space character from last non white space character', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 19); + moveTo(editor, viewModel, 1, 19); moveToLineLastNonWhitespaceCharacter(editor, viewModel); cursorEqual(viewModel, 1, 19); }); @@ -182,7 +182,7 @@ suite('Cursor move command test', () => { test('move to last non white space character from line end', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 21); + moveTo(editor, viewModel, 1, 21); moveToLineLastNonWhitespaceCharacter(editor, viewModel); cursorEqual(viewModel, 1, 19); }); @@ -190,7 +190,7 @@ suite('Cursor move command test', () => { test('move to center of line not from center', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 8); + moveTo(editor, viewModel, 1, 8); moveToLineCenter(editor, viewModel); cursorEqual(viewModel, 1, 11); }); @@ -198,7 +198,7 @@ suite('Cursor move command test', () => { test('move to center of line from center', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 11); + moveTo(editor, viewModel, 1, 11); moveToLineCenter(editor, viewModel); cursorEqual(viewModel, 1, 11); }); @@ -222,7 +222,7 @@ suite('Cursor move command test', () => { test('move up by cursor move command', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 3, 5); + moveTo(editor, viewModel, 3, 5); cursorEqual(viewModel, 3, 5); moveUp(editor, viewModel, 2); @@ -235,7 +235,7 @@ suite('Cursor move command test', () => { test('move up by model line cursor move command', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 3, 5); + moveTo(editor, viewModel, 3, 5); cursorEqual(viewModel, 3, 5); moveUpByModelLine(editor, viewModel, 2); @@ -248,7 +248,7 @@ suite('Cursor move command test', () => { test('move down by model line cursor move command', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 3, 5); + moveTo(editor, viewModel, 3, 5); cursorEqual(viewModel, 3, 5); moveDownByModelLine(editor, viewModel, 2); @@ -261,7 +261,7 @@ suite('Cursor move command test', () => { test('move up with selection by cursor move command', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 3, 5); + moveTo(editor, viewModel, 3, 5); cursorEqual(viewModel, 3, 5); moveUp(editor, viewModel, 1, true); @@ -274,7 +274,7 @@ suite('Cursor move command test', () => { test('move up and down with tabs by cursor move command', () => { executeTest((editor, viewModel) => { - moveTo(viewModel, 1, 5); + moveTo(editor, viewModel, 1, 5); cursorEqual(viewModel, 1, 5); moveDown(editor, viewModel, 4); @@ -296,10 +296,10 @@ suite('Cursor move command test', () => { test('move up and down with end of lines starting from a long one by cursor move command', () => { executeTest((editor, viewModel) => { - moveToEndOfLine(viewModel); + moveToEndOfLine(editor, viewModel); cursorEqual(viewModel, 1, 21); - moveToEndOfLine(viewModel); + moveToEndOfLine(editor, viewModel); cursorEqual(viewModel, 1, 21); moveDown(editor, viewModel, 2); @@ -320,7 +320,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(1, 1, 10, 1); - moveTo(viewModel, 2, 2); + moveTo(editor, viewModel, 2, 2); moveToTop(editor, viewModel); cursorEqual(viewModel, 1, 6); @@ -331,7 +331,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(2, 1, 10, 1); - moveTo(viewModel, 4, 1); + moveTo(editor, viewModel, 4, 1); moveToTop(editor, viewModel); cursorEqual(viewModel, 2, 2); @@ -342,7 +342,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(1, 1, 10, 1); - moveTo(viewModel, 4, 1); + moveTo(editor, viewModel, 4, 1); moveToTop(editor, viewModel, 3); cursorEqual(viewModel, 3, 5); @@ -353,7 +353,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(1, 1, 3, 1); - moveTo(viewModel, 2, 2); + moveTo(editor, viewModel, 2, 2); moveToTop(editor, viewModel, 4); cursorEqual(viewModel, 3, 5); @@ -364,7 +364,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(3, 1, 3, 1); - moveTo(viewModel, 2, 2); + moveTo(editor, viewModel, 2, 2); moveToCenter(editor, viewModel); cursorEqual(viewModel, 3, 5); @@ -375,7 +375,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(1, 1, 5, 1); - moveTo(viewModel, 2, 2); + moveTo(editor, viewModel, 2, 2); moveToBottom(editor, viewModel); cursorEqual(viewModel, 5, 1); @@ -386,7 +386,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(2, 1, 3, 1); - moveTo(viewModel, 2, 2); + moveTo(editor, viewModel, 2, 2); moveToBottom(editor, viewModel); cursorEqual(viewModel, 3, 5); @@ -397,7 +397,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(1, 1, 5, 1); - moveTo(viewModel, 4, 1); + moveTo(editor, viewModel, 4, 1); moveToBottom(editor, viewModel, 3); cursorEqual(viewModel, 3, 5); @@ -408,7 +408,7 @@ suite('Cursor move command test', () => { executeTest((editor, viewModel) => { viewModel.getCompletelyVisibleViewRange = () => new Range(2, 1, 5, 1); - moveTo(viewModel, 4, 1); + moveTo(editor, viewModel, 4, 1); moveToBottom(editor, viewModel, 5); cursorEqual(viewModel, 2, 2); @@ -501,22 +501,22 @@ function selectionEqual(selection: Selection, posLineNumber: number, posColumn: }, 'selection equal'); } -function moveTo(viewModel: ViewModel, lineNumber: number, column: number, inSelectionMode: boolean = false) { +function moveTo(editor: ITestCodeEditor, viewModel: ViewModel, lineNumber: number, column: number, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.MoveToSelect.runCoreEditorCommand(viewModel.getCursors(), { + CoreNavigationCommands.MoveToSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(lineNumber, column) }); } else { - CoreNavigationCommands.MoveTo.runCoreEditorCommand(viewModel.getCursors(), { + CoreNavigationCommands.MoveTo.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), { position: new Position(lineNumber, column) }); } } -function moveToEndOfLine(viewModel: ViewModel, inSelectionMode: boolean = false) { +function moveToEndOfLine(editor: ITestCodeEditor, viewModel: ViewModel, inSelectionMode: boolean = false) { if (inSelectionMode) { - CoreNavigationCommands.CursorEndSelect.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorEndSelect.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } else { - CoreNavigationCommands.CursorEnd.runCoreEditorCommand(viewModel.getCursors(), {}); + CoreNavigationCommands.CursorEnd.runCoreEditorCommand(editor, viewModel, viewModel.getCursors(), {}); } } diff --git a/src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.ts b/src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.ts index f4c36cd032cc052fdc6b44f92e383692accba501..3cfbb844cbee98a7e8ca342cd2f1f405709c57c4 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.ts @@ -47,6 +47,7 @@ export class ToggleColumnSelectionAction extends Action { if (!codeEditor || codeEditor !== this._getCodeEditor() || oldValue === newValue || !codeEditor.hasModel()) { return; } + const viewModel = codeEditor._getViewModel(); const cursors = codeEditor._getCursors(); if (codeEditor.getOption(EditorOption.columnSelection)) { const selection = codeEditor.getSelection(); @@ -55,12 +56,12 @@ export class ToggleColumnSelectionAction extends Action { const modelPosition = new Position(selection.positionLineNumber, selection.positionColumn); const viewPosition = cursors.context.coordinatesConverter.convertModelPositionToViewPosition(modelPosition); - CoreNavigationCommands.MoveTo.runCoreEditorCommand(cursors, { + CoreNavigationCommands.MoveTo.runCoreEditorCommand(codeEditor, viewModel, cursors, { position: modelSelectionStart, viewPosition: viewSelectionStart }); const visibleColumn = CursorColumns.visibleColumnFromColumn2(cursors.context.config, cursors.context.viewModel, viewPosition); - CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(cursors, { + CoreNavigationCommands.ColumnSelect.runCoreEditorCommand(codeEditor, viewModel, cursors, { position: modelPosition, viewPosition: viewPosition, doColumnSelect: true,