From 8b94148a0456cb1267edc688534089d057f7ccd8 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 19 May 2017 00:41:42 +0200 Subject: [PATCH] Renames --- src/vs/editor/common/controller/cursor.ts | 33 +--- .../controller/cursorDeleteOperations.ts | 48 +++--- .../common/controller/cursorTypeOperations.ts | 156 ++++++++---------- 3 files changed, 103 insertions(+), 134 deletions(-) diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index 5c05fddaa84..5df9f478073 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -14,7 +14,7 @@ import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { Selection, SelectionDirection, ISelection } from 'vs/editor/common/core/selection'; import * as editorCommon from 'vs/editor/common/editorCommon'; -import { CursorColumns, CursorConfiguration, EditOperationResult, SingleCursorState, IViewModelHelper, CursorContext, CursorState, RevealTarget, IColumnSelectData, ICursors } from 'vs/editor/common/controller/cursorCommon'; +import { CursorColumns, CursorConfiguration, EditOperationResult, IViewModelHelper, CursorContext, CursorState, RevealTarget, IColumnSelectData, ICursors } from 'vs/editor/common/controller/cursorCommon'; import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry'; import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations'; import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations'; @@ -533,23 +533,6 @@ export class Cursor extends Disposable implements ICursors { // -------------------- START editing operations - // TODO@Alex: remove - private _getAllCursorsModelState(sorted: boolean = false): SingleCursorState[] { - let cursors = this._cursors.getAll(); - - if (sorted) { - cursors = cursors.sort((a, b) => { - return Range.compareRangesUsingStarts(a.modelState.selection, b.modelState.selection); - }); - } - - let r: SingleCursorState[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - r[i] = cursors[i].modelState; - } - return r; - } - private _type(args: CursorOperationArgs<{ text: string; }>): EditOperationResult { const text = args.eventData.text; @@ -570,21 +553,21 @@ export class Cursor extends Disposable implements ICursors { this._createAndInterpretHandlerCtx(() => { // Decide what all cursors will do up-front - return TypeOperations.typeWithInterceptors(this.context.config, this.context.model, this._getAllCursorsModelState(), chr); + return TypeOperations.typeWithInterceptors(this.context.config, this.context.model, this.getSelections(), chr); }); } return null; } else { - return TypeOperations.typeWithoutInterceptors(this.context.config, this.context.model, this._getAllCursorsModelState(), text); + return TypeOperations.typeWithoutInterceptors(this.context.config, this.context.model, this.getSelections(), text); } } private _replacePreviousChar(args: CursorOperationArgs<{ text: string; replaceCharCnt: number; }>): EditOperationResult { let text = args.eventData.text; let replaceCharCnt = args.eventData.replaceCharCnt; - return TypeOperations.replacePreviousChar(this.context.config, this.context.model, this._getAllCursorsModelState(), text, replaceCharCnt); + return TypeOperations.replacePreviousChar(this.context.config, this.context.model, this.getSelections(), text, replaceCharCnt); } private _compositionStart(args: CursorOperationArgs): EditOperationResult { @@ -625,14 +608,16 @@ export class Cursor extends Disposable implements ICursors { const distributedPaste = this._distributePasteToCursors(args); if (distributedPaste) { - return TypeOperations.distributedPaste(this.context.config, this.context.model, this._getAllCursorsModelState(true), distributedPaste); + let selections = this.getSelections(); + selections = selections.sort(Range.compareRangesUsingStarts); + return TypeOperations.distributedPaste(this.context.config, this.context.model, selections, distributedPaste); } else { - return TypeOperations.paste(this.context.config, this.context.model, this._getAllCursorsModelState(), args.eventData.text, args.eventData.pasteOnNewLine); + return TypeOperations.paste(this.context.config, this.context.model, this.getSelections(), args.eventData.text, args.eventData.pasteOnNewLine); } } private _cut(args: CursorOperationArgs): EditOperationResult { - return DeleteOperations.cut(this.context.config, this.context.model, this._getAllCursorsModelState()); + return DeleteOperations.cut(this.context.config, this.context.model, this.getSelections()); } // -------------------- END editing operations diff --git a/src/vs/editor/common/controller/cursorDeleteOperations.ts b/src/vs/editor/common/controller/cursorDeleteOperations.ts index b6552f40e5d..c968bb49f76 100644 --- a/src/vs/editor/common/controller/cursorDeleteOperations.ts +++ b/src/vs/editor/common/controller/cursorDeleteOperations.ts @@ -5,7 +5,7 @@ 'use strict'; import { ReplaceCommand } from 'vs/editor/common/commands/replaceCommand'; -import { SingleCursorState, CursorColumns, CursorConfiguration, ICursorSimpleModel, EditOperationResult } from 'vs/editor/common/controller/cursorCommon'; +import { CursorColumns, CursorConfiguration, ICursorSimpleModel, EditOperationResult } from 'vs/editor/common/controller/cursorCommon'; import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; import { MoveOperations } from 'vs/editor/common/controller/cursorMoveOperations'; @@ -14,16 +14,16 @@ import { ICommand } from "vs/editor/common/editorCommon"; export class DeleteOperations { - public static deleteRight(config: CursorConfiguration, model: ICursorSimpleModel, cursors: Selection[]): [boolean, ICommand[]] { + public static deleteRight(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): [boolean, ICommand[]] { let commands: ICommand[] = []; let shouldPushStackElementBefore = false; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; - let deleteSelection: Range = cursor; + let deleteSelection: Range = selection; if (deleteSelection.isEmpty()) { - let position = cursor.getPosition(); + let position = selection.getPosition(); let rightOfPosition = MoveOperations.right(config, model, position.lineNumber, position.column); deleteSelection = new Range( rightOfPosition.lineNumber, @@ -48,13 +48,13 @@ export class DeleteOperations { return [shouldPushStackElementBefore, commands]; } - private static _isAutoClosingPairDelete(config: CursorConfiguration, model: ICursorSimpleModel, cursors: Selection[]): boolean { + private static _isAutoClosingPairDelete(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): boolean { if (!config.autoClosingBrackets) { return false; } - for (let i = 0, len = cursors.length; i < len; i++) { - const selection = cursors[i]; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; const position = selection.getPosition(); if (!selection.isEmpty()) { @@ -79,11 +79,10 @@ export class DeleteOperations { return true; } - private static _runAutoClosingPairDelete(config: CursorConfiguration, model: ICursorSimpleModel, cursors: Selection[]): [boolean, ICommand[]] { + private static _runAutoClosingPairDelete(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): [boolean, ICommand[]] { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - const position = cursor.getPosition(); + for (let i = 0, len = selections.length; i < len; i++) { + const position = selections[i].getPosition(); const deleteSelection = new Range( position.lineNumber, position.column - 1, @@ -95,21 +94,21 @@ export class DeleteOperations { return [true, commands]; } - public static deleteLeft(config: CursorConfiguration, model: ICursorSimpleModel, cursors: Selection[]): [boolean, ICommand[]] { + public static deleteLeft(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): [boolean, ICommand[]] { - if (this._isAutoClosingPairDelete(config, model, cursors)) { - return this._runAutoClosingPairDelete(config, model, cursors); + if (this._isAutoClosingPairDelete(config, model, selections)) { + return this._runAutoClosingPairDelete(config, model, selections); } let commands: ICommand[] = []; let shouldPushStackElementBefore = false; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; - let deleteSelection: Range = cursor; + let deleteSelection: Range = selection; if (deleteSelection.isEmpty()) { - let position = cursor.getPosition(); + let position = selection.getPosition(); if (config.useTabStops && position.column > 1) { let lineContent = model.getLineContent(position.lineNumber); @@ -155,17 +154,16 @@ export class DeleteOperations { return [shouldPushStackElementBefore, commands]; } - public static cut(config: CursorConfiguration, model: ICursorSimpleModel, cursors: SingleCursorState[]): EditOperationResult { + public static cut(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): EditOperationResult { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - let selection = cursor.selection; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; if (selection.isEmpty()) { if (config.emptySelectionClipboard) { // This is a full line cut - let position = cursor.position; + let position = selection.getPosition(); let startLineNumber: number, startColumn: number, diff --git a/src/vs/editor/common/controller/cursorTypeOperations.ts b/src/vs/editor/common/controller/cursorTypeOperations.ts index 4b8237f13eb..899ff598a82 100644 --- a/src/vs/editor/common/controller/cursorTypeOperations.ts +++ b/src/vs/editor/common/controller/cursorTypeOperations.ts @@ -6,7 +6,7 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import { ReplaceCommand, ReplaceCommandWithoutChangingPosition, ReplaceCommandWithOffsetCursorState } from 'vs/editor/common/commands/replaceCommand'; -import { SingleCursorState, CursorColumns, CursorConfiguration, ICursorSimpleModel, EditOperationResult } from 'vs/editor/common/controller/cursorCommon'; +import { CursorColumns, CursorConfiguration, ICursorSimpleModel, EditOperationResult } from 'vs/editor/common/controller/cursorCommon'; import { Range } from 'vs/editor/common/core/range'; import { ICommand, ITokenizedModel } from 'vs/editor/common/editorCommon'; import * as strings from 'vs/base/common/strings'; @@ -21,11 +21,10 @@ import { CursorChangeReason } from "vs/editor/common/controller/cursorEvents"; export class TypeOperations { - public static indent(config: CursorConfiguration, model: ICursorSimpleModel, cursors: Selection[]): ICommand[] { + public static indent(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - commands[i] = new ShiftCommand(cursor, { + for (let i = 0, len = selections.length; i < len; i++) { + commands[i] = new ShiftCommand(selections[i], { isUnshift: false, tabSize: config.tabSize, oneIndent: config.oneIndent, @@ -35,11 +34,10 @@ export class TypeOperations { return commands; } - public static outdent(config: CursorConfiguration, model: ICursorSimpleModel, cursors: Selection[]): ICommand[] { + public static outdent(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - commands[i] = new ShiftCommand(cursor, { + for (let i = 0, len = selections.length; i < len; i++) { + commands[i] = new ShiftCommand(selections[i], { isUnshift: true, tabSize: config.tabSize, oneIndent: config.oneIndent, @@ -71,12 +69,10 @@ export class TypeOperations { return newIndentation; } - public static distributedPaste(config: CursorConfiguration, model: ICursorSimpleModel, cursors: SingleCursorState[], text: string[]): EditOperationResult { + public static distributedPaste(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[], text: string[]): EditOperationResult { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - let selection = cursor.selection; - commands[i] = new ReplaceCommand(selection, text[i]); + for (let i = 0, len = selections.length; i < len; i++) { + commands[i] = new ReplaceCommand(selections[i], text[i]); } return new EditOperationResult(commands, { shouldPushStackElementBefore: true, @@ -85,12 +81,11 @@ export class TypeOperations { }); } - public static paste(config: CursorConfiguration, model: ICursorSimpleModel, cursors: SingleCursorState[], text: string, pasteOnNewLine: boolean): EditOperationResult { + public static paste(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[], text: string, pasteOnNewLine: boolean): EditOperationResult { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - let position = cursor.position; - let selection = cursor.selection; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; + let position = selection.getPosition(); if (pasteOnNewLine && text.indexOf('\n') !== text.length - 1) { pasteOnNewLine = false; @@ -166,10 +161,10 @@ export class TypeOperations { return new ReplaceCommand(selection, typeText, insertsAutoWhitespace); } - public static tab(config: CursorConfiguration, model: ITokenizedModel, cursors: Selection[]): ICommand[] { + public static tab(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const selection = cursors[i]; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; if (selection.isEmpty()) { @@ -207,18 +202,18 @@ export class TypeOperations { return commands; } - public static replacePreviousChar(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], txt: string, replaceCharCnt: number): EditOperationResult { + public static replacePreviousChar(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], txt: string, replaceCharCnt: number): EditOperationResult { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - if (!cursor.selection.isEmpty()) { + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; + if (!selection.isEmpty()) { // looks like https://github.com/Microsoft/vscode/issues/2773 // where a cursor operation occured before a canceled composition // => ignore composition commands[i] = null; continue; } - let pos = cursor.position; + let pos = selection.getPosition(); let startColumn = Math.max(1, pos.column - replaceCharCnt); let range = new Range(pos.lineNumber, startColumn, pos.lineNumber, pos.column); commands[i] = new ReplaceCommand(range, txt); @@ -294,20 +289,19 @@ export class TypeOperations { return null; } - private static _isAutoClosingCloseCharType(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], ch: string): boolean { + private static _isAutoClosingCloseCharType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): boolean { if (!config.autoClosingBrackets || !config.autoClosingPairsClose.hasOwnProperty(ch)) { return false; } - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - const selection = cursor.selection; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; if (!selection.isEmpty()) { return false; } - const position = cursor.position; + const position = selection.getPosition(); const lineText = model.getLineContent(position.lineNumber); const afterCharacter = lineText.charAt(position.column - 1); @@ -319,11 +313,11 @@ export class TypeOperations { return true; } - private static _runAutoClosingCloseCharType(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], ch: string): EditOperationResult { + private static _runAutoClosingCloseCharType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): EditOperationResult { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - const position = cursor.position; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; + const position = selection.getPosition(); const typeSelection = new Range(position.lineNumber, position.column, position.lineNumber, position.column + 1); commands[i] = new ReplaceCommand(typeSelection, ch); } @@ -333,19 +327,18 @@ export class TypeOperations { }); } - private static _isAutoClosingOpenCharType(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], ch: string): boolean { + private static _isAutoClosingOpenCharType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): boolean { if (!config.autoClosingBrackets || !config.autoClosingPairsOpen.hasOwnProperty(ch)) { return false; } - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - const selection = cursor.selection; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; if (!selection.isEmpty()) { return false; } - const position = cursor.position; + const position = selection.getPosition(); const lineText = model.getLineContent(position.lineNumber); // Do not auto-close ' or " after a word character @@ -397,11 +390,10 @@ export class TypeOperations { return true; } - private static _runAutoClosingOpenCharType(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], ch: string): EditOperationResult { + private static _runAutoClosingOpenCharType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): EditOperationResult { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - const selection = cursor.selection; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; const closeCharacter = config.autoClosingPairsOpen[ch]; commands[i] = new ReplaceCommandWithOffsetCursorState(selection, ch + closeCharacter, 0, -closeCharacter.length); } @@ -411,14 +403,13 @@ export class TypeOperations { }); } - private static _isSurroundSelectionType(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], ch: string): boolean { + private static _isSurroundSelectionType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): boolean { if (!config.autoClosingBrackets || !config.surroundingPairs.hasOwnProperty(ch)) { return false; } - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - const selection = cursor.selection; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; if (selection.isEmpty()) { return false; @@ -446,11 +437,10 @@ export class TypeOperations { return true; } - private static _runSurroundSelectionType(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], ch: string): EditOperationResult { + private static _runSurroundSelectionType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): EditOperationResult { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - const selection = cursor.selection; + for (let i = 0, len = selections.length; i < len; i++) { + const selection = selections[i]; const closeCharacter = config.surroundingPairs[ch]; commands[i] = new SurroundSelectionCommand(selection, ch, closeCharacter); } @@ -460,12 +450,12 @@ export class TypeOperations { }); } - private static _typeInterceptorElectricChar(config: CursorConfiguration, model: ITokenizedModel, cursor: SingleCursorState, ch: string): EditOperationResult { - if (!config.electricChars.hasOwnProperty(ch) || !cursor.selection.isEmpty()) { + private static _typeInterceptorElectricChar(config: CursorConfiguration, model: ITokenizedModel, selections: Selection, ch: string): EditOperationResult { + if (!config.electricChars.hasOwnProperty(ch) || !selections.isEmpty()) { return null; } - let position = cursor.position; + let position = selections.getPosition(); model.forceTokenization(position.lineNumber); let lineTokens = model.getLineTokens(position.lineNumber); @@ -481,7 +471,7 @@ export class TypeOperations { } if (electricAction.appendText) { - const command = new ReplaceCommandWithOffsetCursorState(cursor.selection, ch + electricAction.appendText, 0, -electricAction.appendText.length); + const command = new ReplaceCommandWithOffsetCursorState(selections, ch + electricAction.appendText, 0, -electricAction.appendText.length); return new EditOperationResult([command], { shouldPushStackElementBefore: false, shouldPushStackElementAfter: true @@ -523,12 +513,12 @@ export class TypeOperations { return null; } - public static typeWithInterceptors(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], ch: string): EditOperationResult { + public static typeWithInterceptors(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): EditOperationResult { if (ch === '\n') { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - commands[i] = TypeOperations._enter(config, model, false, cursors[i].selection); + for (let i = 0, len = selections.length; i < len; i++) { + commands[i] = TypeOperations._enter(config, model, false, selections[i]); } return new EditOperationResult(commands, { shouldPushStackElementBefore: true, @@ -536,35 +526,34 @@ export class TypeOperations { }); } - if (this._isAutoClosingCloseCharType(config, model, cursors, ch)) { - return this._runAutoClosingCloseCharType(config, model, cursors, ch); + if (this._isAutoClosingCloseCharType(config, model, selections, ch)) { + return this._runAutoClosingCloseCharType(config, model, selections, ch); } - if (this._isAutoClosingOpenCharType(config, model, cursors, ch)) { - return this._runAutoClosingOpenCharType(config, model, cursors, ch); + if (this._isAutoClosingOpenCharType(config, model, selections, ch)) { + return this._runAutoClosingOpenCharType(config, model, selections, ch); } - if (this._isSurroundSelectionType(config, model, cursors, ch)) { - return this._runSurroundSelectionType(config, model, cursors, ch); + if (this._isSurroundSelectionType(config, model, selections, ch)) { + return this._runSurroundSelectionType(config, model, selections, ch); } // Electric characters make sense only when dealing with a single cursor, // as multiple cursors typing brackets for example would interfer with bracket matching - if (cursors.length === 1) { - const r = this._typeInterceptorElectricChar(config, model, cursors[0], ch); + if (selections.length === 1) { + const r = this._typeInterceptorElectricChar(config, model, selections[0], ch); if (r) { return r; } } - return this.typeWithoutInterceptors(config, model, cursors, ch); + return this.typeWithoutInterceptors(config, model, selections, ch); } - public static typeWithoutInterceptors(config: CursorConfiguration, model: ITokenizedModel, cursors: SingleCursorState[], str: string): EditOperationResult { + public static typeWithoutInterceptors(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], str: string): EditOperationResult { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - commands[i] = new ReplaceCommand(cursor.selection, str); + for (let i = 0, len = selections.length; i < len; i++) { + commands[i] = new ReplaceCommand(selections[i], str); } return new EditOperationResult(commands, { shouldPushStackElementBefore: false, @@ -572,11 +561,10 @@ export class TypeOperations { }); } - public static lineInsertBefore(config: CursorConfiguration, model: ITokenizedModel, cursors: Selection[]): ICommand[] { + public static lineInsertBefore(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - let lineNumber = cursor.positionLineNumber; + for (let i = 0, len = selections.length; i < len; i++) { + let lineNumber = selections[i].positionLineNumber; if (lineNumber === 1) { commands[i] = new ReplaceCommandWithoutChangingPosition(new Range(1, 1, 1, 1), '\n'); @@ -590,22 +578,20 @@ export class TypeOperations { return commands; } - public static lineInsertAfter(config: CursorConfiguration, model: ITokenizedModel, cursors: Selection[]): ICommand[] { + public static lineInsertAfter(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - let lineNumber = cursor.positionLineNumber; + for (let i = 0, len = selections.length; i < len; i++) { + const lineNumber = selections[i].positionLineNumber; let column = model.getLineMaxColumn(lineNumber); commands[i] = this._enter(config, model, false, new Range(lineNumber, column, lineNumber, column)); } return commands; } - public static lineBreakInsert(config: CursorConfiguration, model: ITokenizedModel, cursors: Selection[]): ICommand[] { + public static lineBreakInsert(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; - for (let i = 0, len = cursors.length; i < len; i++) { - const cursor = cursors[i]; - commands[i] = this._enter(config, model, true, cursor); + for (let i = 0, len = selections.length; i < len; i++) { + commands[i] = this._enter(config, model, true, selections[i]); } return commands; } -- GitLab