diff --git a/src/vs/editor/common/config/config.ts b/src/vs/editor/common/config/config.ts index 0d9e02fe0ddcd67ad7d32417abd1b711d13f2b42..6c6805b5698e46cb2fd940b723d73980cddbe1a4 100644 --- a/src/vs/editor/common/config/config.ts +++ b/src/vs/editor/common/config/config.ts @@ -168,6 +168,7 @@ registerCoreCommand(H.CursorDownSelect, { mac: { primary: KeyMod.Shift | KeyCode.DownArrow }, linux: { primary: KeyMod.Shift | KeyCode.DownArrow } }); + registerCoreCommand(H.CursorPageUp, { primary: KeyCode.PageUp }); @@ -196,6 +197,10 @@ registerCoreCommand(H.CursorEndSelect, { primary: KeyMod.Shift | KeyCode.End, mac: { primary: KeyMod.Shift | KeyCode.End, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow] } }); +registerCoreCommand(H.ExpandLineSelection, { + primary: KeyMod.CtrlCmd | KeyCode.KEY_I, + mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_I} +}); registerCoreCommand(H.Tab, { primary: KeyCode.Tab diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index 829791450d04b05b39ee356084bd00f1bf60f999..1f96031bfc6a61f9aee9a6921408240951051c13 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -966,6 +966,8 @@ export class Cursor extends EventEmitter { handlersMap[H.DeleteAllRight] = (ctx:IMultipleCursorOperationContext) => this._deleteAllRight(ctx); handlersMap[H.Cut] = (ctx:IMultipleCursorOperationContext) => this._cut(ctx); + handlersMap[H.ExpandLineSelection] = (ctx:IMultipleCursorOperationContext) => this._expandLineSelection(ctx); + handlersMap[H.Undo] = (ctx:IMultipleCursorOperationContext) => this._undo(ctx); handlersMap[H.CursorUndo] = (ctx:IMultipleCursorOperationContext) => this._cursorUndo(ctx); handlersMap[H.Redo] = (ctx:IMultipleCursorOperationContext) => this._redo(ctx); @@ -1187,6 +1189,10 @@ export class Cursor extends EventEmitter { return true; } + private _expandLineSelection(ctx: IMultipleCursorOperationContext): boolean { + return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.expandLineSelection(oneCursor, oneCtx)); + } + private _lineInsertBefore(ctx: IMultipleCursorOperationContext): boolean { return this._invokeForAll(ctx, (cursorIndex: number, oneCursor: OneCursor, oneCtx: IOneCursorOperationContext) => OneCursorOp.lineInsertBefore(oneCursor, oneCtx)); } diff --git a/src/vs/editor/common/controller/oneCursor.ts b/src/vs/editor/common/controller/oneCursor.ts index 83b4fa21cae3ce996c173b75111a5a5ece6ec31e..b8f82f67d5f6ab10eed45cb9b9da8330ce5c5b73 100644 --- a/src/vs/editor/common/controller/oneCursor.ts +++ b/src/vs/editor/common/controller/oneCursor.ts @@ -737,6 +737,21 @@ export class OneCursorOp { return true; } + public static expandLineSelection(cursor:OneCursor, ctx: IOneCursorOperationContext): boolean { + ctx.cursorPositionChangeReason = 'explicit'; + var currentSelection = cursor.getSelection(); + var lastColumn = cursor.getColumnAtEndOfViewLine(currentSelection.endLineNumber, currentSelection.endColumn); + var expandedSelection = new Selection(currentSelection.startLineNumber,1,currentSelection.endLineNumber,lastColumn); + if (currentSelection.equalsSelection(expandedSelection)){ + lastColumn = cursor.getColumnAtEndOfViewLine(currentSelection.endLineNumber+1, currentSelection.endColumn+1); + expandedSelection = new Selection(currentSelection.startLineNumber,1,currentSelection.endLineNumber+1,lastColumn); + cursor.setSelection(expandedSelection); + } else { + cursor.setSelection(expandedSelection); + } + return true; + } + public static moveToBeginningOfBuffer(cursor:OneCursor, inSelectionMode: boolean, ctx: IOneCursorOperationContext): boolean { ctx.cursorPositionChangeReason = 'explicit'; cursor.moveModelPosition(inSelectionMode, 1, 1, 0, true); diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 1c9e3a50597837a23ef173d70db81628ad43e4b0..da54897c2e23917697ea46f8d03f5b23ba371294 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -3283,6 +3283,8 @@ export var Handler = { CursorEnd: 'cursorEnd', CursorEndSelect: 'cursorEndSelect', + ExpandLineSelection: 'expandLineSelection', + CursorTop: 'cursorTop', CursorTopSelect: 'cursorTopSelect', CursorBottom: 'cursorBottom',