Skip to content

Commit

Permalink
Merge pull request #428 from rebornix/Fix#369
Browse files Browse the repository at this point in the history
Fix#369. `dw` eats EOF.
  • Loading branch information
johnfn authored Jul 12, 2016
2 parents 1bc94f4 + 4aa1c55 commit c2ff2fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,8 @@ export class MoveWordBegin extends BaseMovement {
next line.
*/

if (result.isLineBeginning()) {
return result.getLeftThroughLineBreaks();
if (result.line > position.line + 1 || (result.line === position.line + 1 && result.isFirstWordOfLine())) {
return position.getLineEnd();
}

if (result.isLineEnd()) {
Expand Down
4 changes: 4 additions & 0 deletions src/motion/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ export class Position extends vscode.Position {
return this.character >= Position.getLineLength(this.line);
}

public isFirstWordOfLine(): boolean {
return Position.getFirstNonBlankCharAtLine(this.line) === this.character;
}

public isAtDocumentEnd(): boolean {
return this.line === TextEditor.getLineCount() - 1 && this.isLineEnd();
}
Expand Down
14 changes: 14 additions & 0 deletions test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ suite("Mode Normal", () => {
end: ["one| "],
});

newTest({
title: "Can handle dw across lines",
start: ['one |two', ' three'],
keysPressed: 'dw',
end: ["one| ", " three"]
});

newTest({
title: "Can handle dw across lines",
start: ['one |two', '', 'three'],
keysPressed: 'dw',
end: ["one| ", "", "three"]
});

newTest({
title: "Can handle dd last line",
start: ['one', '|two'],
Expand Down

0 comments on commit c2ff2fb

Please sign in to comment.