zed/crates/gpui/src/keymap
Dong 74ad75843e
keymap_editor: Remove redundant parentheses when displaying keymap context (#50906)
Closes #34976

## Root Cause

The current implementation of `fmt::Display` in
`KeyBindingContextPredicate` hardcodes a parentheses around `And` and
`Or` cases. Causing the text displayed on the keymap editor to have
nested parentheses.

This PR refactors the display logic and make the parentheses added only
when there's nested operator.

## As is/ To be

As is | To be
--- | ---	
<img width="800" height="1101" alt="Screenshot 2026-03-06 at 15 07 10"
src="https://github.com/user-attachments/assets/33b4366d-4d16-48db-9cc6-b79d6cc7ddc7"
/> | <img width="800" height="977" alt="Screenshot 2026-03-06 at 14 54
57"
src="https://github.com/user-attachments/assets/3d5ed38d-949d-4265-8fad-e29250c3a285"
/>

## Test coverage

<img width="800" height="916" alt="Screenshot 2026-03-06 at 15 00 42"
src="https://github.com/user-attachments/assets/5846b908-5c86-48a7-919e-a7ae198484a8"
/>



Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- keymap_editor: Remove redundant parentheses when displaying keymap
context

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
2026-03-17 02:44:12 +00:00
..
binding.rs Refactor KeybindingKeystroke (#37065) 2025-08-28 08:40:43 +00:00
context.rs keymap_editor: Remove redundant parentheses when displaying keymap context (#50906) 2026-03-17 02:44:12 +00:00