internal which-key plugin, inactive by default (#26337)

This commit is contained in:
Sebastian
2026-05-08 13:55:49 +02:00
committed by GitHub
parent 4a737493ac
commit 19da27e1cb
34 changed files with 908 additions and 63 deletions

View File

@@ -243,6 +243,8 @@ function AutoMethod(props: AutoMethodProps) {
bindings: [
{
key: "c",
desc: "Copy provider code",
group: "Dialog",
cmd: () => {
const code =
props.authorization.instructions.match(/[A-Z0-9]{4}-[A-Z0-9]{4,5}/)?.[0] ?? props.authorization.url

View File

@@ -48,18 +48,26 @@ export function DialogRetryAction(props: DialogRetryActionProps) {
bindings: [
{
key: "left",
desc: "Previous retry option",
group: "Dialog",
cmd: () => setSelected((value) => (value === "action" ? "dismiss" : "action")),
},
{
key: "right",
desc: "Next retry option",
group: "Dialog",
cmd: () => setSelected((value) => (value === "action" ? "dismiss" : "action")),
},
{
key: "tab",
desc: "Next retry option",
group: "Dialog",
cmd: () => setSelected((value) => (value === "action" ? "dismiss" : "action")),
},
{
key: "return",
desc: "Confirm retry option",
group: "Dialog",
cmd: () => {
if (selected() === "action") runAction(props, dialog)
else dismiss(props, dialog)

View File

@@ -42,11 +42,11 @@ export function DialogSessionDeleteFailed(props: {
useBindings(() => ({
bindings: [
{ key: "return", cmd: () => void confirm() },
{ key: "left", cmd: () => setStore("active", "delete") },
{ key: "up", cmd: () => setStore("active", "delete") },
{ key: "right", cmd: () => setStore("active", "restore") },
{ key: "down", cmd: () => setStore("active", "restore") },
{ key: "return", desc: "Confirm recovery option", group: "Dialog", cmd: () => void confirm() },
{ key: "left", desc: "Delete broken session", group: "Dialog", cmd: () => setStore("active", "delete") },
{ key: "up", desc: "Delete broken session", group: "Dialog", cmd: () => setStore("active", "delete") },
{ key: "right", desc: "Restore broken session", group: "Dialog", cmd: () => setStore("active", "restore") },
{ key: "down", desc: "Restore broken session", group: "Dialog", cmd: () => setStore("active", "restore") },
],
}))

View File

@@ -25,9 +25,9 @@ export function DialogWorkspaceUnavailable(props: { onRestore?: () => boolean |
useBindings(() => ({
bindings: [
{ key: "return", cmd: () => void confirm() },
{ key: "left", cmd: () => setStore("active", "cancel") },
{ key: "right", cmd: () => setStore("active", "restore") },
{ key: "return", desc: "Confirm workspace option", group: "Dialog", cmd: () => void confirm() },
{ key: "left", desc: "Cancel workspace restore", group: "Dialog", cmd: () => setStore("active", "cancel") },
{ key: "right", desc: "Restore workspace", group: "Dialog", cmd: () => setStore("active", "restore") },
],
}))

View File

@@ -528,6 +528,8 @@ export function Autocomplete(props: {
commands: [
{
name: "prompt.autocomplete.prev",
title: "Previous autocomplete item",
category: "Autocomplete",
run() {
setStore("input", "keyboard")
move(-1)
@@ -535,6 +537,8 @@ export function Autocomplete(props: {
},
{
name: "prompt.autocomplete.next",
title: "Next autocomplete item",
category: "Autocomplete",
run() {
setStore("input", "keyboard")
move(1)
@@ -542,18 +546,24 @@ export function Autocomplete(props: {
},
{
name: "prompt.autocomplete.hide",
title: "Hide autocomplete",
category: "Autocomplete",
run() {
hide()
},
},
{
name: "prompt.autocomplete.select",
title: "Select autocomplete item",
category: "Autocomplete",
run() {
select()
},
},
{
name: "prompt.autocomplete.complete",
title: "Complete autocomplete item",
category: "Autocomplete",
run() {
const selected = options()[store.selected]
if (selected?.isDirectory) {

View File

@@ -892,6 +892,8 @@ export function Prompt(props: PromptProps) {
bindings: [
{
key: "!",
desc: "Shell mode",
group: "Prompt",
cmd: () => {
setStore("placeholder", randomIndex(shell().length))
setStore("mode", "shell")
@@ -905,7 +907,7 @@ export function Prompt(props: PromptProps) {
return {
target: inputTarget,
enabled: inputTarget() !== undefined && store.mode === "shell",
bindings: [{ key: "escape", cmd: () => setStore("mode", "normal") }],
bindings: [{ key: "escape", desc: "Exit shell mode", group: "Prompt", cmd: () => setStore("mode", "normal") }],
}
})
@@ -916,7 +918,7 @@ export function Prompt(props: PromptProps) {
cursorVersion()
return inputTarget() !== undefined && store.mode === "shell" && input?.visualCursor.offset === 0
})(),
bindings: [{ key: "backspace", cmd: () => setStore("mode", "normal") }],
bindings: [{ key: "backspace", desc: "Exit shell mode", group: "Prompt", cmd: () => setStore("mode", "normal") }],
}
})
@@ -936,6 +938,8 @@ export function Prompt(props: PromptProps) {
commands: [
{
name: "prompt.history.previous",
title: "Previous prompt history",
category: "Prompt",
run() {
if (input.cursorOffset !== 0) {
input.cursorOffset = 0
@@ -972,6 +976,8 @@ export function Prompt(props: PromptProps) {
commands: [
{
name: "prompt.history.next",
title: "Next prompt history",
category: "Prompt",
run() {
if (input.cursorOffset !== input.plainText.length) {
input.cursorOffset = input.plainText.length