Skip to content

fix(keymaps): keep chord separator when searching keybindings by key - #4776

Open
irontaek wants to merge 1 commit into
opensumi:mainfrom
irontaek:fix/keymaps-chord-search-render
Open

irontaek wants to merge 1 commit into
opensumi:mainfrom
irontaek:fix/keymaps-chord-search-render

Conversation

@irontaek

@irontaek irontaek commented Oct 9, 2026 •

Copy link
Copy Markdown

Types

  • 🐛 Bug Fixes

Background or solution

KeymapService.searchKeybindings() has a branch that renders per-key matches for chord keybindings (stored as '⌘+K ⌘+S', see acceleratorFor(kd, '+').join(' ')). That branch never took effect, for three reasons:

  1. spaceIndexArr.push(tKeys.length + spaceIndexArr[-1]) reads spaceIndexArr[-1], which is undefined, so every chord boundary index became NaN.
  2. chordRenderedResult was a const '' and String.prototype.concat() returns a new string, so the loop discarded every result.
  3. Right after, 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. searching S+K. In that case the chord ⌘+K ⌘+S was 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 to join('+') for non-chord keybindings.

I checked it with a standalone copy of the before/after logic and [email protected] (same pre/post options):

query keybinding before after
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> unchanged

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

  • 问题修复
    • 修复多段快捷键模糊匹配时的显示问题,确保各段及段内按键正确呈现。

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
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@opensumi opensumi Bot added the 🐞 bug Something isn't working label Oct 9, 2026
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c3662fba-39ae-4b22-a49a-cecc84316e66

📥 Commits

Reviewing files that changed from the base of the PR and between 9a7057a and f0e8ea0.


📒 Files selected for processing (1)
  • packages/keymaps/src/browser/keymaps.service.ts

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

修正 doSearchKeybindings 中组合键分段位置的累计计算,并调整匹配成功后的渲染:段内按 + 连接,多个段之间按空格连接。

Changes

快捷键搜索渲染

Layer / File(s) Summary
组合键匹配与渲染
packages/keymaps/src/browser/keymaps.service.ts
分段位置累计值改为基于 spaceIndexArr 的末项计算。多段快捷键按空格连接各段,段内按 + 连接;单段快捷键按 + 连接。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to f0e8e

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)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题“fix(keymaps): keep chord separator when searching keybindings by key”准确描述了主要变更:修复按键搜索结果中 chord 分隔符丢失的问题。标题简洁、具体,并与代码变更和 PR 目标一致。
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants