-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Work even when typing in the wrong language in a multilingual keyboard #4461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This commit introduces a new feature that allows users to search for Hebrew strings using their QWERTY keyboard equivalents. This is useful for users who work with both Hebrew and English and may not always have their keyboard set to the correct language. The changes include: - A mapping from Hebrew characters to their corresponding QWERTY characters. - Modifications to the search pattern logic to generate a "keyboard converted" version of the search term. - Updates to the matching functions to check both the original and the converted search terms.
This commit refactors the keyboard layout mapping to be more modular and extensible. The hardcoded hebrew-to-qwerty mapping has been replaced with a generic Keymap structure that can support multiple languages. A new file, src/keymap.go, has been introduced to store the mappings, and the pattern matching logic has been updated to use the new structure. This change makes it easier to add support for new keyboard layouts in the future.
This commit further generalizes the keyboard layout conversion logic. - The `hasHebrew` variable in `src/pattern.go` has been renamed to `needsConversion` to reflect its broader applicability. - The `qwertyMapping` is now initialized by merging all language-specific keymaps from `src/keymap.go`, allowing for easy addition of new language layouts. - The explicit mention of "hebrew" has been removed from `src/pattern.go`, making the code more generic.
This commit introduces a new command-line argument `--keymap-convert` (short form `+C`) to control the keyboard layout conversion feature. - Added `KeymapConvert` field to `Options` struct in `src/options.go`. - Implemented parsing for `--keymap-convert` and `--no-keymap-convert` in `src/options.go`. - Modified `BuildPattern` function in `src/pattern.go` and its calls in `src/core.go` and `src/pattern_test.go` to pass the new argument. - Wrapped the keymap conversion logic in `src/pattern.go` with a conditional check for `keymapConvert`.
This commit addresses the build errors related to undefined variables `textRunes` and `keymapConvert` in `src/pattern.go`. - `textRunes` is now declared outside the conditional block in `BuildPattern` to ensure it's always in scope. - `keymapConvert` is now passed as a parameter to `extendedMatch` and stored in the `Pattern` struct, resolving its undefined status within the function.
This commit updates the help string in `src/options.go` to include the newly added `--keymap-convert` command-line option and its short forms (`+C` and `-C`).
maybe this be achieved by define a |
I ma not sure I understand, but this implementation is activated by a command line switch |
that's it. i wonder if it's technically possible to have a command to switch? ok.. in your case maybe it's a bit tricky since you have to talk with the keyboard rather than the os. (btw there are software level keyboards like kanata. off topic here but it's great if fzf is not the only case) |
As a user of multilingual keyboard, I sometimes search using fzf but forget to switch the keyboard language to English
This patch enables a mode where non-English characters are mapped to they keyboard equivalent English characters -- the English character sitting on the same key in the standard QWERTY keyboard, so even though you did not switch keyboard, you would get search results as though you were typing in English
A bit esoteric, but helps a bit ...
Includes implementation for Hebrew and Russian, easy to add more
90% written by gemini-cli