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

Some visual block fixes #667

Merged
merged 5 commits into from
Sep 3, 2016
Merged
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: 9 additions & 5 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,11 @@ export class DeleteOperator extends BaseOperator {
// Vim does this weird thing where it allows you to select and delete
// the newline character, which it places 1 past the last character
// in the line. Here we interpret a character position 1 past the end
// as selecting the newline character.
if (end.character === TextEditor.getLineAt(end).text.length + 1) {
end = end.getDown(0);
// as selecting the newline character. Don't allow this in visual block mode
if (vimState.currentMode !== ModeName.VisualBlock) {
if (end.character === TextEditor.getLineAt(end).text.length + 1) {
end = end.getDown(0);
}
}

// If we delete linewise to the final line of the document, we expect the line
Expand Down Expand Up @@ -2756,12 +2758,14 @@ class ActionChangeInVisualBlockMode extends BaseCommand {
const deleteOperator = new DeleteOperator();

for (const { start, end } of Position.IterateLine(vimState)) {
await deleteOperator.delete(start, end, vimState.currentMode, vimState.effectiveRegisterMode(), vimState, true);
await deleteOperator.delete(start, end.getLeft(), vimState.currentMode, vimState.effectiveRegisterMode(), vimState, true);
}

vimState.currentMode = ModeName.VisualBlockInsertMode;
vimState.recordedState.visualBlockInsertionType = VisualBlockInsertionType.Insert;

vimState.cursorPosition = vimState.cursorPosition.getLeft();

return vimState;
}
}
Expand Down Expand Up @@ -2856,7 +2860,7 @@ class InsertInInsertVisualBlockMode extends BaseCommand {

posChange = -1;
} else {
await TextEditor.insert(this.keysPressed[0], insertPos.getLeft());
await TextEditor.insert(this.keysPressed[0], insertPos);

posChange = 1;
}
Expand Down