Fixes for PR #961
This commit is contained in:
parent
cab36275c5
commit
942e9be7e4
|
@ -198,8 +198,7 @@ registerCoreCommand(H.CursorEndSelect, {
|
|||
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}
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_I
|
||||
});
|
||||
|
||||
registerCoreCommand(H.Tab, {
|
||||
|
|
|
@ -739,16 +739,26 @@ export class OneCursorOp {
|
|||
|
||||
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);
|
||||
let viewSel = cursor.getViewSelection();
|
||||
|
||||
let viewStartLineNumber = viewSel.startLineNumber;
|
||||
let viewStartColumn = viewSel.startColumn;
|
||||
let viewEndLineNumber = viewSel.endLineNumber;
|
||||
let viewEndColumn = viewSel.endColumn;
|
||||
|
||||
let viewEndMaxColumn = cursor.getViewLineMaxColumn(viewEndLineNumber);
|
||||
if (viewStartColumn !== 1 || viewEndColumn !== viewEndMaxColumn) {
|
||||
viewStartColumn = 1;
|
||||
viewEndColumn = viewEndMaxColumn;
|
||||
} else {
|
||||
cursor.setSelection(expandedSelection);
|
||||
// Expand selection with one more line down
|
||||
let moveResult = cursor.getViewPositionDown(viewEndLineNumber, viewEndColumn, 0, 1);
|
||||
viewEndLineNumber = moveResult.lineNumber;
|
||||
viewEndColumn = cursor.getViewLineMaxColumn(viewEndLineNumber);
|
||||
}
|
||||
|
||||
cursor.moveViewPosition(false, viewStartLineNumber, viewStartColumn, 0, true);
|
||||
cursor.moveViewPosition(true, viewEndLineNumber, viewEndColumn, 0, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -649,6 +649,45 @@ suite('Editor Controller - Cursor', () => {
|
|||
cursorEqual(thisCursor, 5, LINE5.length + 1, 1, 1);
|
||||
});
|
||||
|
||||
test('expandLineSelection', () => {
|
||||
// 0 1 2
|
||||
// 01234 56789012345678 0
|
||||
// var LINE1 = ' \tMy First Line\t ';
|
||||
moveTo(thisCursor, 1, 1);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 1, LINE1.length + 1, 1, 1);
|
||||
|
||||
moveTo(thisCursor, 1, 2);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 1, LINE1.length + 1, 1, 1);
|
||||
|
||||
moveTo(thisCursor, 1, 5);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 1, LINE1.length + 1, 1, 1);
|
||||
|
||||
moveTo(thisCursor, 1, 19);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 1, LINE1.length + 1, 1, 1);
|
||||
|
||||
moveTo(thisCursor, 1, 20);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 1, LINE1.length + 1, 1, 1);
|
||||
|
||||
moveTo(thisCursor, 1, 21);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 1, LINE1.length + 1, 1, 1);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 2, LINE2.length + 1, 1, 1);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 3, LINE3.length + 1, 1, 1);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 4, LINE4.length + 1, 1, 1);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 5, LINE5.length + 1, 1, 1);
|
||||
cursorCommand(thisCursor, H.ExpandLineSelection);
|
||||
cursorEqual(thisCursor, 5, LINE5.length + 1, 1, 1);
|
||||
});
|
||||
|
||||
// --------- eventing
|
||||
|
||||
test('no move doesn\'t trigger event', () => {
|
||||
|
|
Loading…
Reference in a new issue