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

Fix for visual line behaving funky when going from bottom up #989

Merged
merged 2 commits into from
Oct 26, 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/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1362,13 +1362,19 @@ export class ModeHandler implements vscode.Disposable {

selections = [ new vscode.Selection(start, stop) ];
} else if (vimState.currentMode === ModeName.VisualLine) {
selections = [ new vscode.Selection(
selections = [new vscode.Selection(
Position.EarlierOf(start, stop).getLineBegin(),
Position.LaterOf(start, stop).getLineEnd()
) ];
vimState.cursorStartPosition = selections[0].start as Position;
vimState.cursorPosition = selections[0].end as Position;
)];

// Maintain cursor position based on which direction the selection is going
if (start.line <= stop.line) {
vimState.cursorStartPosition = selections[0].start as Position;
vimState.cursorPosition = selections[0].end as Position;
} else {
vimState.cursorStartPosition = selections[0].end as Position;
vimState.cursorPosition = selections[0].start as Position;
}
} else if (vimState.currentMode === ModeName.VisualBlock) {
selections = [];

Expand Down
8 changes: 8 additions & 0 deletions test/mode/modeVisualLine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ suite("Mode Visual", () => {
end: ["|11111111111111111111111", "11111111111111111111111"],
endMode: ModeName.Normal
});

newTestOnly({
title: "Can do a multi visual line replace from the bottom up",
start: ["test", "test", "test", "|test", "test"],
keysPressed: "Vkkr1",
end: ["test", "|1111", "1111", "1111", "test"],
endMode: ModeName.Normal
});
});

});