Skip to content

Add fine-grained equality methods for key bindings#916

Open
Kapparina wants to merge 7 commits intocharmbracelet:mainfrom
Kapparina:implement-keybinding-equality-interface
Open

Add fine-grained equality methods for key bindings#916
Kapparina wants to merge 7 commits intocharmbracelet:mainfrom
Kapparina:implement-keybinding-equality-interface

Conversation

@Kapparina
Copy link
Copy Markdown

@Kapparina Kapparina commented Mar 24, 2026

Description

This pull request introduces enhancements to the key package by implementing fine-grained equality methods for key bindings, improving clarity, and providing better comparison functionality.

Prerequisites

Changes

Changes include:

  • Addition of EqualKeys, EqualHelp, and EqualDisabled methods for specific equality checks.
  • Refactoring the Equal method to leverage fine-grained equality methods.
  • Implementation of unit tests to ensure robust equality logic for key bindings.
  • Style updates to comments for clarity and consistency.
  • Documentation updates in the upgrade guide and README for v2 changes, including typo fixes and enhancements.

Notes

This PR is an extension of PR #773, which was missed prior to the v2-to-main merge.

- Implement `Equal` method to check for equality of keys and help text.
- Import `slices` package to simplify key comparison logic.
# Conflicts:
#	go.mod
#	textarea/textarea.go
#	textarea/textarea_test.go
- Introduce `EqualKeys`, `EqualHelp`, and `EqualDisabled` methods.
- Refactor `Equal` to use the new fine-grained methods.
- Add unit tests to verify equality logic.
- Convert package-level comment to block style for better readability.
- Reformat function comments for improved line breaks and structure.
- Reformat `UPGRADE_GUIDE_V2.md` for improved readability and consistency.
- Update package import paths and migration tables for v2.
- Enhance `README.md` with alt text and fix typos.
- Verify equality logic between identical bindings.
- Test scenarios with differing enabled states and key sets.
- Ensure correct behaviour when comparing distinct bindings.
@Kapparina Kapparina marked this pull request as ready for review March 24, 2026 03:27
@Kapparina Kapparina requested a review from meowgorithm as a code owner March 24, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant