Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #784 #814

Merged
merged 2 commits into from
Oct 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2599,10 +2599,16 @@ abstract class MoveByScreenLine extends BaseMovement {
* cursorMove command is handling the selection for us.
* So we are not following our design principal (do no real movement inside an action) here.
*/
return {
start: Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start),
stop: Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.end)
};

let start = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);
let stop = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.end);

// We want to swap the cursor start stop positions based on which direction we are moving, up or down
if (start.line < position.line) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do a swap like this: [a, b] = [b, a]

You could also write this whole block like this:

return { start: Position.earlierOf(start, stop), stop: Position.laterOf(start, stop) }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye, I will change it, this is where all readability goes away in my opinion. I can solve this by just not reading it again :)

[start, stop] = [stop, start];
}

return { start, stop };
}
}

Expand Down
7 changes: 7 additions & 0 deletions test/mode/modeVisual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ suite("Mode Visual", () => {
assertEqualLines(["wo three"]);
});

newTest({
title: "Can handle H key",
start: ['1', '2', '|3', '4', '5'],
keysPressed: 'vH',
end: ['|1', '2', '3', '4', '5']
});

test("handles case where we delete over a newline", async () => {
await modeHandler.handleMultipleKeyEvents("ione two\n\nthree four".split(""));
await modeHandler.handleMultipleKeyEvents([
Expand Down