Skip to content

Commit

Permalink
misc: use dance.inPrompt instead of !textInputFocus
Browse files Browse the repository at this point in the history
`textInputFocus` doesn't seem to exist, but until recently this wasn't a
problem.

In Insiders 1.90, `!textInputFocus` evaluates to true in quick-open boxes, so
arrow keys no longer work in these input boxes because of Dance. This change
adds a custom Dance context key, `dance.inPrompt`, to only enable input box
keybindings in prompts created by Dance.
  • Loading branch information
71 committed May 11, 2024
1 parent 822dc5b commit d20be49
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ export function parseKeys(keys: string) {
case "prompt":
assert(!negate);
whenClauses.splice(whenClauses.indexOf("editorTextFocus"), 1);
whenClauses.push("inputFocus && !textInputFocus");
whenClauses.push("inputFocus && dance.inPrompt");
break;

default: {
Expand Down
2 changes: 1 addition & 1 deletion package.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const selectionDecorationType = {
// ============================================================================

const version = "0.5.14",
preRelease = 2;
preRelease = 3;

export const pkg = (modules: Builder.ParsedModule[]) => ({

Expand Down
8 changes: 4 additions & 4 deletions package.json

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

7 changes: 7 additions & 0 deletions src/api/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export function prompt(
});
}

const contextKey = "dance.inPrompt";
const setContextPromise = vscode.commands.executeCommand("setContext", contextKey, true);

const disposables = [
inputBox,
inputBox.onDidChangeValue(updateAndValidateValue),
Expand Down Expand Up @@ -100,6 +103,10 @@ export function prompt(
inputBox.onDidHide(() => {
disposables.forEach((d) => d.dispose());

setContextPromise.then(() =>
vscode.commands.executeCommand("setContext", contextKey, false),
);

const reason = context.cancellationToken?.isCancellationRequested
? CancellationError.Reason.CancellationToken
: CancellationError.Reason.PressedEscape;
Expand Down

0 comments on commit d20be49

Please sign in to comment.