11import {
22 STATIC_KEYBINDING_COMMANDS ,
3+ type ClientSettings ,
34 type KeybindingCommand ,
45 type KeybindingShortcut ,
56 type KeybindingWhenNode ,
@@ -13,7 +14,7 @@ import {
1314 US_SHIFTED_TO_UNSHIFTED_KEYS ,
1415} from "@t3tools/shared/keybindings" ;
1516
16- import { shortcutConflictKey , shortcutKeyFromEvent } from "../../keybindings" ;
17+ import { shortcutConflictKey , shortcutForContext , shortcutKeyFromEvent } from "../../keybindings" ;
1718import { isMacPlatform } from "../../lib/utils" ;
1819import { METRIC_OPTIONS , WINDOW_OPTIONS } from "../usage/usageShortcuts" ;
1920
@@ -250,23 +251,37 @@ export function groupKeybindingRows(
250251export function buildKeybindingRows (
251252 keybindings : ResolvedKeybindingsConfig ,
252253 platform = navigator . platform ,
254+ sendShortcut : ClientSettings [ "sendShortcut" ] = "enter" ,
253255) : ReadonlyArray < KeybindingRow > {
254- const lastBindingIndex = new Map < string , number > ( ) ;
255- for ( const [ index , binding ] of keybindings . entries ( ) ) {
256- const key = shortcutConflictKey ( binding . shortcut , platform ) ;
257- lastBindingIndex . set ( `${ key } :${ whenAstToExpression ( binding . whenAst ) } ` , index ) ;
258- }
256+ // Multiline sending can use either shortcut; settings have no active composer prompt.
257+ const modifierModes =
258+ sendShortcut === "mod-enter-multiline" ? [ false , true ] : [ sendShortcut === "mod-enter" ] ;
259+ const conflictKeys = modifierModes . map ( ( composerRequiresModifier ) =>
260+ keybindings . map ( ( binding ) =>
261+ shortcutConflictKey ( shortcutForContext ( binding , { composerRequiresModifier } ) , platform ) ,
262+ ) ,
263+ ) ;
264+ const lastBindingIndices = conflictKeys . map ( ( keys ) => {
265+ const indices = new Map < string , number > ( ) ;
266+ for ( const [ index , binding ] of keybindings . entries ( ) ) {
267+ indices . set ( `${ keys [ index ] } :${ whenAstToExpression ( binding . whenAst ) } ` , index ) ;
268+ }
269+ return indices ;
270+ } ) ;
259271 const rowsById = new Map < string , KeybindingRow > ( ) ;
260272 for ( const [ index , binding ] of keybindings . entries ( ) ) {
261273 const defaultBinding = defaultBindingForBinding ( binding ) ;
262274 const key = shortcutToKeybindingInput ( binding . shortcut ) ;
263275 const when = whenAstToExpression ( binding . whenAst ) ;
264276 const id = keybindingRowId ( binding . command , key , when ) ;
265- const conflictKey = shortcutConflictKey ( binding . shortcut , platform ) ;
266277 // Only discard proven shadows; distinct conditions may apply in other focus contexts.
267- const isShadowed =
268- ( lastBindingIndex . get ( `${ conflictKey } :` ) ?? - 1 ) > index ||
269- ( lastBindingIndex . get ( `${ conflictKey } :${ when } ` ) ?? - 1 ) > index ;
278+ const isShadowed = lastBindingIndices . every ( ( indices , mode ) => {
279+ const conflictKey = conflictKeys [ mode ] ?. [ index ] ;
280+ return (
281+ ( indices . get ( `${ conflictKey } :` ) ?? - 1 ) > index ||
282+ ( indices . get ( `${ conflictKey } :${ when } ` ) ?? - 1 ) > index
283+ ) ;
284+ } ) ;
270285 rowsById . set ( id , {
271286 id,
272287 command : binding . command ,
0 commit comments