Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createMemo, createResource, createEffect, onMount, onCleanup, Index, Sh
import { createStore } from "solid-js/store"
import { useSDK } from "@tui/context/sdk"
import { useSync } from "@tui/context/sync"
import { useKeybind } from "@tui/context/keybind"
import { getScrollAcceleration } from "../../util/scroll"
import { useTuiConfig } from "../../context/tui-config"
import { useTheme, selectedForeground } from "@tui/context/theme"
Expand Down Expand Up @@ -79,6 +80,7 @@ export function Autocomplete(props: {
}) {
const sdk = useSDK()
const sync = useSync()
const keybind = useKeybind()
const command = useCommandDialog()
const { theme } = useTheme()
const dimensions = useTerminalDimensions()
Expand Down Expand Up @@ -567,7 +569,7 @@ export function Autocomplete(props: {
e.preventDefault()
return
}
if (name === "return") {
if (keybind.match("input_submit", e)) {
select()
e.preventDefault()
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,21 @@ export function useTextareaKeybindings() {
return createMemo(() => {
const keybinds = keybind.all

return [
{ name: "return", action: "submit" },
{ name: "return", meta: true, action: "newline" },
...TEXTAREA_ACTIONS.flatMap((action) => mapTextareaKeybindings(keybinds, action)),
] satisfies KeyBinding[]
// Get user-defined bindings first
const userBindings = TEXTAREA_ACTIONS.flatMap((action) =>
mapTextareaKeybindings(keybinds, action),
)

// Build defaults array, only adding defaults for unconfigured actions
const defaults: KeyBinding[] = []
if (!userBindings.some((b) => b.action === "submit")) {
defaults.push({ name: "return", action: "submit" })
}
if (!userBindings.some((b) => b.action === "newline")) {
defaults.push({ name: "return", meta: true, action: "newline" })
}

// User bindings come first so they take precedence over defaults
return [...userBindings, ...defaults] satisfies KeyBinding[]
})
}