Repository navigation
Conversation
searchKeybindings() renders per-key matches for chords like '⌘+K ⌘+S',
but the chord branch never took effect: spaceIndexArr used
spaceIndexArr[-1] (undefined, so every index was NaN), the
String.prototype.concat() results were discarded, and the value was
then overwritten with renderedResult.join('+'). Searching 'S+K' showed
'⌘+K+⌘+S' instead of '⌘+K ⌘+S'.
Claude-Session: https://claude.ai/code/session_01W9Mk18mBNfkPfgg3hYweKq
|
|
1 similar comment
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. Walkthrough修正 Changes快捷键搜索渲染
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Ordinary chord searches retain their separators, and single-group results remain unchanged. No material merge-blocking risk is established. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Types
Background or solution
KeymapService.searchKeybindings()has a branch that renders per-key matches for chord keybindings (stored as'⌘+K ⌘+S', seeacceleratorFor(kd, '+').join(' ')). That branch never took effect, for three reasons:spaceIndexArr.push(tKeys.length + spaceIndexArr[-1])readsspaceIndexArr[-1], which isundefined, so every chord boundary index becameNaN.chordRenderedResultwas aconst ''andString.prototype.concat()returns a new string, so the loop discarded every result.item[key] = renderedResult.join('+')overwrote the value anyway.The per-key branch runs when the whole query does not fuzzy-match the keybinding but each
+-separated part matches a key, e.g. searchingS+K. In that case the chord⌘+K ⌘+Swas shown as⌘+K+⌘+S, losing the boundary between the two key presses.Fix: take the last element (
spaceIndexArr[spaceIndexArr.length - 1]), accumulate with+=, and only fall back tojoin('+')for non-chord keybindings.I checked it with a standalone copy of the before/after logic and
[email protected](samepre/postoptions):S+K⌘+K ⌘+S⌘+<match>K</match>+⌘+<match>S</match>⌘+<match>K</match> ⌘+<match>S</match>D+K⌘+K ⌘+⇧+D⌘+<match>K</match>+⌘+⇧+<match>D</match>⌘+<match>K</match> ⌘+⇧+<match>D</match>S+⌘⌘+⇧+S(no chord)<match>⌘</match>+⇧+<match>S</match>I did not run the repo's jest suite locally (dependencies not installed); only the file parse and the standalone check above.
Changelog
Fix chord keybindings losing the space between key presses in keymap search results.
https://claude.ai/code/session_01W9Mk18mBNfkPfgg3hYweKq
Summary by CodeRabbit