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 #937 #943

Merged
merged 1 commit into from
Oct 19, 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
6 changes: 3 additions & 3 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3258,8 +3258,8 @@ class MoveNonBlankLast extends BaseMovement {
export class MoveWordBegin extends BaseMovement {
keys = ["w"];

public async execAction(position: Position, vimState: VimState): Promise<Position> {
if (vimState.recordedState.operator instanceof ChangeOperator) {
public async execAction(position: Position, vimState: VimState, isLastIteration: boolean = false): Promise<Position> {
if (isLastIteration && vimState.recordedState.operator instanceof ChangeOperator) {
if (TextEditor.getLineAt(position).text.length < 1) {
return position;
}
Expand All @@ -3286,7 +3286,7 @@ export class MoveWordBegin extends BaseMovement {
}

public async execActionForOperator(position: Position, vimState: VimState): Promise<Position> {
const result = await this.execAction(position, vimState);
const result = await this.execAction(position, vimState, true);

/*
From the Vim documentation:
Expand Down
16 changes: 16 additions & 0 deletions test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@ suite("Mode Normal", () => {
endMode: ModeName.Insert
});

newTest({
title: "Can handle 'cw' without deleting following white spaces",
start: ['|const a = 1;'],
keysPressed: 'cw',
end: ['| a = 1;'],
endMode: ModeName.Insert
});

newTest({
title: "Can handle 'c2w'",
start: ['|const a = 1;'],
keysPressed: 'c2w',
end: ['| = 1;'],
endMode: ModeName.Insert
});

newTest({
title: "Can handle 'cw' without removing EOL",
start: ['|text;', 'text'],
Expand Down