Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Oct 19, 2016
1 parent da8c437 commit 19553b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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

0 comments on commit 19553b5

Please sign in to comment.