Skip to content

Commit

Permalink
Ctrl+a and Ctrl+x now create undo points correctly and can be repeate… (
Browse files Browse the repository at this point in the history
#636)

* Ctrl+a and Ctrl+x now create undo points correctly and can be repeated with .

* Changed increment/decrement numbers to be a command instead of a movement
  • Loading branch information
xconverge authored and johnfn committed Aug 24, 2016
1 parent 10d6f1a commit bb788a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3552,14 +3552,13 @@ class ToggleCaseAndMoveForward extends BaseMovement {
}
}

abstract class IncrementDecrementNumberAction extends BaseMovement {
abstract class IncrementDecrementNumberAction extends BaseCommand {
modes = [ModeName.Normal];
canBePrefixedWithCount = true;
canBeRepeatedWithDot = true;

offset: number;

public async execActionWithCount(position: Position, vimState: VimState, count: number): Promise<Position> {
count = count || 1;
public async exec(position: Position, vimState: VimState): Promise<VimState> {
const text = TextEditor.getLineAt(position).text;

for (let { start, end, word } of Position.IterateWords(position.getWordLeft(true))) {
Expand All @@ -3572,11 +3571,12 @@ abstract class IncrementDecrementNumberAction extends BaseMovement {
const num = NumericString.parse(word);

if (num !== null) {
return this.replaceNum(num, this.offset * count, start, end);
vimState.cursorPosition = await this.replaceNum(num, this.offset * (vimState.recordedState.count || 1), start, end);
return vimState;
}
}
// No usable numbers, return the original position
return position;
return vimState;
}

public async replaceNum(start: NumericString, offset: number, startPos: Position, endPos: Position): Promise<Position> {
Expand Down
1 change: 0 additions & 1 deletion src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,6 @@ export class ModeHandler implements vscode.Disposable {

if (action instanceof BaseMovement) {
({ vimState, recordedState } = await this.executeMovement(vimState, action));

ranAction = true;
}

Expand Down

0 comments on commit bb788a5

Please sign in to comment.