Skip to content

Commit

Permalink
fixes #888 (#902)
Browse files Browse the repository at this point in the history
* fixes #888

* Change the way we handle replace on last character
  • Loading branch information
xconverge authored and johnfn committed Oct 12, 2016
1 parent c845e04 commit c567194
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3532,11 +3532,23 @@ class ActionReplaceCharacter extends BaseCommand {
return vimState;
}

let endPos = new Position(position.line, position.character + timesToRepeat);

// Return if tried to repeat longer than linelength
if (endPos.character > TextEditor.getLineAt(endPos).text.length) {
return vimState;
}

// If last char (not EOL char), add 1 so that replace selection is complete
if (endPos.character > TextEditor.getLineAt(endPos).text.length) {
endPos = new Position(endPos.line, endPos.character + 1);
}

vimState.recordedState.transformations.push({
type : "replaceText",
text : toReplace.repeat(timesToRepeat),
start : position,
end : position.getRightByCount(timesToRepeat),
end : endPos,
diff : new PositionDiff(0, timesToRepeat - 1),
});

Expand Down

0 comments on commit c567194

Please sign in to comment.