fix: don't try to open command palette if a dialog is already open (#9116)
This commit is contained in:
parent
eb968a6651
commit
5a199b04cb
1 changed files with 3 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import { createMemo, createSignal, onCleanup, onMount, type Accessor } from "solid-js"
|
import { createMemo, createSignal, onCleanup, onMount, type Accessor } from "solid-js"
|
||||||
import { createSimpleContext } from "@opencode-ai/ui/context"
|
import { createSimpleContext } from "@opencode-ai/ui/context"
|
||||||
|
import { useDialog } from "@opencode-ai/ui/context/dialog"
|
||||||
|
|
||||||
const IS_MAC = typeof navigator === "object" && /(Mac|iPod|iPhone|iPad)/.test(navigator.platform)
|
const IS_MAC = typeof navigator === "object" && /(Mac|iPod|iPhone|iPad)/.test(navigator.platform)
|
||||||
|
|
||||||
|
|
@ -122,6 +123,7 @@ export function formatKeybind(config: string): string {
|
||||||
export const { use: useCommand, provider: CommandProvider } = createSimpleContext({
|
export const { use: useCommand, provider: CommandProvider } = createSimpleContext({
|
||||||
name: "Command",
|
name: "Command",
|
||||||
init: () => {
|
init: () => {
|
||||||
|
const dialog = useDialog()
|
||||||
const [registrations, setRegistrations] = createSignal<Accessor<CommandOption[]>[]>([])
|
const [registrations, setRegistrations] = createSignal<Accessor<CommandOption[]>[]>([])
|
||||||
const [suspendCount, setSuspendCount] = createSignal(0)
|
const [suspendCount, setSuspendCount] = createSignal(0)
|
||||||
|
|
||||||
|
|
@ -165,7 +167,7 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContex
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleKeyDown = (event: KeyboardEvent) => {
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
if (suspended()) return
|
if (suspended() || dialog.active) return
|
||||||
|
|
||||||
const paletteKeybinds = parseKeybind("mod+shift+p")
|
const paletteKeybinds = parseKeybind("mod+shift+p")
|
||||||
if (matchKeybind(paletteKeybinds, event)) {
|
if (matchKeybind(paletteKeybinds, event)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue