@@ -8,11 +8,12 @@ import {
88} from "@t3tools/contracts" ;
99import {
1010 DEFAULT_RESOLVED_KEYBINDINGS ,
11+ parseKeybindingShortcut ,
1112 parseKeybindingWhenExpression ,
1213 US_SHIFTED_TO_UNSHIFTED_KEYS ,
1314} from "@t3tools/shared/keybindings" ;
1415
15- import { shortcutKeyFromEvent } from "../../keybindings" ;
16+ import { shortcutConflictKey , shortcutKeyFromEvent } from "../../keybindings" ;
1617import { isMacPlatform } from "../../lib/utils" ;
1718import { METRIC_OPTIONS , WINDOW_OPTIONS } from "../usage/usageShortcuts" ;
1819
@@ -180,13 +181,18 @@ function conflictsWithWhen(leftWhen: string, rightWhen: string): boolean {
180181export function keybindingConflictLabels (
181182 rows : ReadonlyArray < KeybindingRow > ,
182183 input : { readonly rowId : string ; readonly key : string ; readonly when : string } ,
184+ platform = navigator . platform ,
183185) : ReadonlyArray < string > {
184186 if ( input . key . trim ( ) . length === 0 ) return [ ] ;
187+ const shortcut = parseKeybindingShortcut ( input . key ) ;
188+ if ( ! shortcut ) return [ ] ;
189+ // Compare resolved chords so mod+k and ctrl+k collide where mod is Ctrl.
190+ const conflictKey = shortcutConflictKey ( shortcut , platform ) ;
185191 const conflicts : Array < string > = [ ] ;
186192 for ( const candidate of rows ) {
187193 if (
188194 candidate . id !== input . rowId &&
189- candidate . key === input . key &&
195+ shortcutConflictKey ( candidate . binding . shortcut , platform ) === conflictKey &&
190196 conflictsWithWhen ( candidate . when , input . when )
191197 ) {
192198 conflicts . push ( commandLabel ( candidate . command ) ) ;
@@ -242,6 +248,7 @@ export function groupKeybindingRows(
242248
243249export function buildKeybindingRows (
244250 keybindings : ResolvedKeybindingsConfig ,
251+ platform = navigator . platform ,
245252) : ReadonlyArray < KeybindingRow > {
246253 const rowsById = new Map < string , KeybindingRow > ( ) ;
247254 for ( const binding of keybindings ) {
@@ -264,11 +271,15 @@ export function buildKeybindingRows(
264271 const rows = [ ...rowsById . values ( ) ] ;
265272
266273 const rowsWithConflicts = rows . map ( ( row ) => {
267- const conflicts = keybindingConflictLabels ( rows , {
268- rowId : row . id ,
269- key : row . key ,
270- when : row . when ,
271- } ) ;
274+ const conflicts = keybindingConflictLabels (
275+ rows ,
276+ {
277+ rowId : row . id ,
278+ key : row . key ,
279+ when : row . when ,
280+ } ,
281+ platform ,
282+ ) ;
272283 return conflicts . length > 0
273284 ? Object . assign ( { } , row , { conflicts : [ ...new Set ( conflicts ) ] . toSorted ( ) } )
274285 : row ;
0 commit comments