Skip to content
Open
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 shouldResetEphemeralState() {
return (this.flags & CommandDescriptor.Flags.KeepEphemeralState) === 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.shouldResetEphemeralState) {
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 ephemeral state (selected count/register). */
KeepEphemeralState = 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 ("keepephemeral" in f.properties) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"keepephemeral" has the same casing as other JSDoc tags but is pretty hard to read IMO (especially because of all these p's and e's close together). A couple of alternative ideas: keepcontext, preserve, preservecontext, noreset, noresetstate. I have a slight preference for keepcontext as my brain can easily separate both words, but don't have a strong opinion.

flags.push("KeepEphemeralState");
}

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
* @keepephemeral
*/
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