Skip to content
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

Pressing backspace when passing None as Search Key prints the word backspace as regex. #41

Open
majezt1c opened this issue Oct 25, 2021 · 3 comments · May be fixed by #95
Open

Pressing backspace when passing None as Search Key prints the word backspace as regex. #41

majezt1c opened this issue Oct 25, 2021 · 3 comments · May be fixed by #95
Labels
bug Something isn't working

Comments

@majezt1c
Copy link

Pretty much the title. If you have passed None as search_key, if you are currently searching nothing and backspace is pressed, the search text becomes the literal word "backspace". I found this issue with other keys / combinations as well, like pressing º or ç (with the Spanish keyboard layout) makes the search text become the word italics.

@IngoMeyer441
Copy link
Owner

Thanks for your bug report! I already have an idea why this happens. 👍

@IngoMeyer441 IngoMeyer441 added the bug Something isn't working label Oct 27, 2021
@majezt1c
Copy link
Author

majezt1c commented Dec 15, 2021

I think it is related to this issue, so I'm posting it here: pressing the Left Arrow crashes the menu.

image

@anishsane
Copy link

anishsane commented Sep 4, 2024

Thanks for your bug report! I already have an idea why this happens. 👍

Is there any easy fix for this, or can you point to the erroneous code? I could attempt a PR if you have already identified the bug.

EDIT:
Oh, it is a simple fix:

                    self._search_key is None and next_key == DEFAULT_SEARCH_KEY
                ):
                    self._search.search_text = ""
-               elif self._search_key is None:
+               elif self._search_key is None and next_key not in ("backspace",):
                    self._search.search_text = next_key
            else:
                assert self._search.search_text is not None

anishsane added a commit to anishsane/simple-term-menu that referenced this issue Sep 19, 2024
When search_key=None, if we press backspace as the first character, the
word is entered literally ("backspace") as the search term.

If the search_key is None and backspace is pressed, do nothing. (Do not
set the search_key to "backspace".)

Partially resolves IngoMeyer441#41
(The issue with accented characters mentioned in the issue description is not
handled.)
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 a pull request may close this issue.

3 participants