Skip to content

Commit

Permalink
Merge pull request #961 from edm-opensource/master
Browse files Browse the repository at this point in the history
Implementation of issue #950
  • Loading branch information
alexdima committed Dec 7, 2015
2 parents 3b98b0f + ecaa12d commit cab3627
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vs/editor/common/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/vs/editor/common/controller/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
Expand Down
15 changes: 15 additions & 0 deletions src/vs/editor/common/controller/oneCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/vs/editor/common/editorCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3283,6 +3283,8 @@ export var Handler = {
CursorEnd: 'cursorEnd',
CursorEndSelect: 'cursorEndSelect',

ExpandLineSelection: 'expandLineSelection',

CursorTop: 'cursorTop',
CursorTopSelect: 'cursorTopSelect',
CursorBottom: 'cursorBottom',
Expand Down

0 comments on commit cab3627

Please sign in to comment.