Skip to content

Commit

Permalink
commands: fix esc, s-q not stopping recording (fixes 71#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
71 committed Mar 8, 2022
1 parent 4332956 commit ff1df1c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
15 changes: 10 additions & 5 deletions meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,20 +434,25 @@ export function parseKeys(keys: string) {
const remainingKeybinding = keybinding.replace(/[csa]-/g, ""),
whenClauses = ["editorTextFocus"];

for (const tag of match[3].split(", ")) {
for (let tag of match[3].split(", ")) {
const negate = tag.startsWith("!");
if (negate) {
tag = tag.slice(1);
}
switch (tag) {
case "normal":
case "insert":
case "input":
whenClauses.push(`dance.mode == '${tag}'`);
whenClauses.push(`dance.mode ${negate ? "!=" : "=="} '${tag}'`);
break;

case "recording":
whenClauses.push("dance.isRecording");
whenClauses.push(`${negate ? "!" : ""}dance.isRecording`);
break;

case "prompt":
whenClauses.shift(); // Remove "editorTextFocus" clause.
assert(!negate);
whenClauses.splice(whenClauses.indexOf("editorTextFocus"), 1);
whenClauses.push("inputFocus && !textInputFocus");
break;

Expand All @@ -458,7 +463,7 @@ export function parseKeys(keys: string) {
throw new Error("unknown keybinding tag " + tag);
}

whenClauses.push(match[1]);
whenClauses.push((negate ? "!" : "") + match[1]);
break;
}
}
Expand Down
10 changes: 8 additions & 2 deletions package.json

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

10 changes: 8 additions & 2 deletions src/api/keybindings/built-in.ts

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

12 changes: 6 additions & 6 deletions src/commands/README.md

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

4 changes: 2 additions & 2 deletions src/commands/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const recordingPerRegister = new WeakMap<Register, ActiveRecording>();
/**
* Start recording.
*
* @keys `s-q` (normal)
* @keys `s-q` (normal, !recording)
* @noreplay
*/
export function recording_start(
Expand All @@ -187,7 +187,7 @@ export function recording_start(
/**
* Stop recording.
*
* @keys `escape` (normal, recording)
* @keys `escape` (normal, recording), `s-q` (normal, recording)
* @noreplay
*/
export function recording_stop(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare module "./misc";
/**
* Cancel Dance operation.
*
* @keys `escape` (normal, "!markersNavigationVisible"), `escape` (input)
* @keys `escape` (normal, !recording, "!markersNavigationVisible"), `escape` (input)
*/
export function cancel(extension: Extension) {
// Calling a new command resets pending operations, so we don't need to do
Expand Down

0 comments on commit ff1df1c

Please sign in to comment.