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

Fixed numbered registered macros from overwriting themselves #1362

Merged
merged 4 commits into from
Mar 10, 2017
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
5 changes: 5 additions & 0 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export class VimState {
public cursorPositionJustBeforeAnythingHappened = [ new Position(0, 0) ];

public isRecordingMacro: boolean = false;
public isReplayingMacro: boolean = false;

public replaceState: ReplaceState | undefined = undefined;

Expand Down Expand Up @@ -1383,6 +1384,8 @@ export class ModeHandler implements vscode.Disposable {
case "macro":
let recordedMacro = (await Register.getByKey(command.register)).text as RecordedState;

vimState.isReplayingMacro = true;

if (command.replay === "contentChange") {
vimState = await this.runMacro(vimState, recordedMacro);
} else {
Expand All @@ -1394,6 +1397,7 @@ export class ModeHandler implements vscode.Disposable {
await this.handleMultipleKeyEvents(keyStrokes);
}

vimState.isReplayingMacro = false;
vimState.historyTracker.lastInvokedMacro = recordedMacro;

if (vimState.lastMovementFailed) {
Expand All @@ -1402,6 +1406,7 @@ export class ModeHandler implements vscode.Disposable {
vimState.lastMovementFailed = false;
return vimState;
}

break;
case "tab":
await vscode.commands.executeCommand('tab');
Expand Down
2 changes: 1 addition & 1 deletion src/register/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class Register {
Register.registers['0'].text = content;
Register.registers['0'].registerMode = vimState.effectiveRegisterMode();
}
} else if (baseOperator instanceof DeleteOperator) {
} else if (baseOperator instanceof DeleteOperator && !(vimState.isRecordingMacro || vimState.isReplayingMacro)) {
// shift 'delete-history' register
for (let index = 9; index > 1; index--) {
Register.registers[String(index)].text = Register.registers[String(index - 1)].text;
Expand Down