From 8b2a63192c968700485bb1be48d42b4eae156ffe Mon Sep 17 00:00:00 2001 From: The0x539 Date: Wed, 21 May 2025 11:54:00 -0500 Subject: [PATCH 1/3] feat: make `dance.openMenu` retain count/register state --- src/commands/README.md | 6 +++--- src/commands/index.ts | 13 +++++++++++-- src/commands/layouts/azerty.fr.md | 6 +++--- src/commands/layouts/qwerty.md | 6 +++--- src/commands/load-all.build.ts | 4 ++++ src/commands/load-all.ts | 2 +- src/commands/misc.ts | 1 + 7 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/commands/README.md b/src/commands/README.md index 68a8e0cc..27dcc5aa 100644 --- a/src/commands/README.md +++ b/src/commands/README.md @@ -860,7 +860,7 @@ This command: -### [`openMenu`](./misc.ts#L309-L331) +### [`openMenu`](./misc.ts#L309-L332) Open menu. @@ -884,7 +884,7 @@ This command: -### [`changeInput`](./misc.ts#L372-L386) +### [`changeInput`](./misc.ts#L373-L387) Change current input. @@ -901,7 +901,7 @@ This command: -### [`ifEmpty`](./misc.ts#L396-L407) +### [`ifEmpty`](./misc.ts#L397-L408) Executes one of the specified commands depending on whether the current selections are empty. diff --git a/src/commands/index.ts b/src/commands/index.ts index c72d20de..f917c137 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -54,6 +54,10 @@ export class CommandDescriptor -### [`openMenu`](../misc.ts#L309-L331) +### [`openMenu`](../misc.ts#L309-L332) Open menu. @@ -869,7 +869,7 @@ This command: -### [`changeInput`](../misc.ts#L372-L386) +### [`changeInput`](../misc.ts#L373-L387) Change current input. @@ -886,7 +886,7 @@ This command: -### [`ifEmpty`](../misc.ts#L396-L407) +### [`ifEmpty`](../misc.ts#L397-L408) Executes one of the specified commands depending on whether the current selections are empty. diff --git a/src/commands/layouts/qwerty.md b/src/commands/layouts/qwerty.md index fbd1064a..9fd5c309 100644 --- a/src/commands/layouts/qwerty.md +++ b/src/commands/layouts/qwerty.md @@ -845,7 +845,7 @@ This command: -### [`openMenu`](../misc.ts#L309-L331) +### [`openMenu`](../misc.ts#L309-L332) Open menu. @@ -869,7 +869,7 @@ This command: -### [`changeInput`](../misc.ts#L372-L386) +### [`changeInput`](../misc.ts#L373-L387) Change current input. @@ -886,7 +886,7 @@ This command: -### [`ifEmpty`](../misc.ts#L396-L407) +### [`ifEmpty`](../misc.ts#L397-L408) Executes one of the specified commands depending on whether the current selections are empty. diff --git a/src/commands/load-all.build.ts b/src/commands/load-all.build.ts index dd28d640..db7ba6e3 100644 --- a/src/commands/load-all.build.ts +++ b/src/commands/load-all.build.ts @@ -226,6 +226,10 @@ function determineFunctionFlags(f: Builder.ParsedFunction) { flags.push("DoNotReplay"); } + if ("keepephemeral" in f.properties) { + flags.push("KeepEphemeralState"); + } + if (flags.length === 0) { return "CommandDescriptor.Flags.None"; } diff --git a/src/commands/load-all.ts b/src/commands/load-all.ts index 89e96c90..c6859dcc 100644 --- a/src/commands/load-all.ts +++ b/src/commands/load-all.ts @@ -444,7 +444,7 @@ export const commands: Commands = function () { "dance.openMenu": new CommandDescriptor( "dance.openMenu", (_, argument) => _.runAsync(async (_) => await openMenu(_, getInputOr("menu", argument), argument["prefix"], argument["pass"], argument["locked"], argument["delay"], argument["title"])), - CommandDescriptor.Flags.DoNotReplay, + CommandDescriptor.Flags.DoNotReplay | CommandDescriptor.Flags.KeepEphemeralState, ), "dance.run": new CommandDescriptor( "dance.run", diff --git a/src/commands/misc.ts b/src/commands/misc.ts index dfee5eca..71808f91 100644 --- a/src/commands/misc.ts +++ b/src/commands/misc.ts @@ -318,6 +318,7 @@ const menuHistory: string[] = []; * like `jj`. * * @noreplay + * @keepephemeral */ export async function openMenu( _: Context.WithoutActiveEditor, From 7850ddbbd2b1ffdcc669f5bc5b970a4ee222e545 Mon Sep 17 00:00:00 2001 From: The0x539 Date: Wed, 21 May 2025 11:54:38 -0500 Subject: [PATCH 2/3] test: fix line ending behavior on Windows Before this change, many/most of the unit tests failed due to line ending discrepancies, irrespective of the line endings stored in the test suite source files. After the change, they all pass, again irrespective of the files' line endings. --- test/suite/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/suite/utils.ts b/test/suite/utils.ts index 29bd28d6..4c0aa00c 100644 --- a/test/suite/utils.ts +++ b/test/suite/utils.ts @@ -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) { From b6f9cb27cb0ebd5cdd78170d526df38545aa5b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Geis?= Date: Sun, 17 Aug 2025 13:16:05 +0900 Subject: [PATCH 3/3] keepephemeral -> keepcontext --- src/commands/index.ts | 10 +++++----- src/commands/load-all.build.ts | 4 ++-- src/commands/load-all.ts | 2 +- src/commands/misc.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/commands/index.ts b/src/commands/index.ts index f917c137..5345e8c3 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -54,8 +54,8 @@ export class CommandDescriptor _.runAsync(async (_) => await openMenu(_, getInputOr("menu", argument), argument["prefix"], argument["pass"], argument["locked"], argument["delay"], argument["title"])), - CommandDescriptor.Flags.DoNotReplay | CommandDescriptor.Flags.KeepEphemeralState, + CommandDescriptor.Flags.DoNotReplay | CommandDescriptor.Flags.KeepContext, ), "dance.run": new CommandDescriptor( "dance.run", diff --git a/src/commands/misc.ts b/src/commands/misc.ts index 71808f91..ce02915c 100644 --- a/src/commands/misc.ts +++ b/src/commands/misc.ts @@ -318,7 +318,7 @@ const menuHistory: string[] = []; * like `jj`. * * @noreplay - * @keepephemeral + * @keepcontext */ export async function openMenu( _: Context.WithoutActiveEditor,