Skip to content
Draft
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
6 changes: 3 additions & 3 deletions src/commands/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export class CommandDescriptor<Flags extends CommandDescriptor.Flags = CommandDe
return (this.flags & CommandDescriptor.Flags.DoNotReplay) === 0;
}

public get shouldResetContext() {
return (this.flags & CommandDescriptor.Flags.KeepContext) === 0;
}

public constructor(
/**
* The unique identifier of the command.
Expand Down Expand Up @@ -104,8 +108,10 @@ export class CommandDescriptor<Flags extends CommandDescriptor.Flags = CommandDe
context.doNotRecord();
}

extension.currentCount = 0;
extension.currentRegister = undefined;
if (this.shouldResetContext) {
extension.currentCount = 0;
extension.currentRegister = undefined;
}

let result: unknown;

Expand Down Expand Up @@ -168,6 +174,9 @@ export /* enum */ namespace CommandDescriptor {

/** The command should not be replayed in macros and repeats. */
DoNotReplay = 0b0010,

/** The command should not reset context (selected count/register). */
KeepContext = 0b0100,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/layouts/azerty.fr.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/commands/layouts/qwerty.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/commands/load-all.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ function determineFunctionFlags(f: Builder.ParsedFunction) {
flags.push("DoNotReplay");
}

if ("keepcontext" in f.properties) {
flags.push("KeepContext");
}

if (flags.length === 0) {
return "CommandDescriptor.Flags.None";
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/load-all.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/commands/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ const menuHistory: string[] = [];
* like `jj`.
*
* @noreplay
* @keepcontext
*/
export async function openMenu(
_: Context.WithoutActiveEditor,
Expand Down
1 change: 1 addition & 0 deletions test/suite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ export class ExpectedDocument {
end = editor.document.lineAt(editor.document.lineCount - 1).rangeIncludingLineBreak.end;

builder.replace(new vscode.Range(start, end), this.text);
builder.setEndOfLine(vscode.EndOfLine.LF);
});

if (this.selections.length > 0) {
Expand Down