Refactor input handling and validation with new tests#2
Refactor input handling and validation with new tests#2hthienloc wants to merge 2 commits intoLotusInputMethod:masterfrom
Conversation
… update module path, and include new tests.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors input handling, particularly for backspace and shortcuts, and adds corresponding tests. The refactoring improves code structure, but I've identified a potential logic issue in the backspace handling that leads to unintuitive behavior. The new test case for backspace seems to confirm this incorrect behavior. I've also suggested a small improvement to the new applyUIShortcuts function for better clarity and efficiency. The module path update and other new tests look good.
This pull request refactors the backspace (removal) logic in the Bamboo input engine, unifying and simplifying how backspace is handled, and updates related tests to match the new behavior. It also introduces new tests for edge cases and updates the module path.
Backspace handling and composition management:
handleBackspacemethod inbamboo.go, which now removes the last transformation and any trailing virtual transformations with aRule.Keyof 0. TheRemoveLastCharmethod now delegates to this new method, and the logic for refreshing the last tone has been simplified. (bamboo.go)ProcessKeyto handle backspace keys (\bor 0x7f) directly in Vietnamese mode, calling the newhandleBackspacemethod and returning early. (bamboo.go`)Rule application and shortcut handling:
getApplicableRulesto returnnilif the key cannot be processed, preventing unnecessary rule lookups for invalid keys. (bamboo.go)applyUowShortcutwith a newapplyUIShortcutshelper, which returns a slice of transformations and is more extensible. (bamboo.go) [1] [2]Testing improvements and coverage:
bamboo_test.goto reflect the new backspace/removal behavior, ensuring the processed string matches the expected output after removals. (bamboo_test.go) [1] [2] [3] [4] [5] [6]getApplicableRules, and theCanProcessKeymethod, improving coverage for edge cases. (bamboo_test.go)Project maintenance:
github.com/BambooEngine/bamboo-coretogithub.com/LotusInputMethod/bamboo-coreingo.mod. (go.mod)