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

Delete whole word #398

Closed
Vander567321 opened this issue Sep 10, 2023 · 9 comments
Closed

Delete whole word #398

Vander567321 opened this issue Sep 10, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@Vander567321
Copy link

Thumb-Key Version
1.14

Describe the bug
Dosnt work as expected.

To Reproduce
Steps to reproduce the behavior:

  1. insert for example 'https://user-images.githubusercontent.com/43177940/265277149-d45d35c2-3e29-4896-a078-e8c44c928550.gif'
  2. swipe left on backspace key
  3. the first letter still remains

Seems the IMO expected logic (delete everything, from cursor to the left, including the first {group} of whitespaces) is not applied here?

@Vander567321 Vander567321 added the bug Something isn't working label Sep 10, 2023
@dessalines
Copy link
Owner

I can't really tell what's going on because that gif is really long. Could you either create a shorter gif or write how to re-create this?

@nejni-marji
Copy link
Contributor

https://github.com/dessalines/thumb-key/assets/10968473/38029d27-3fb9-4c3c-b4b2-f913a162e715
(this is my debug app, but it's recently rebased and i only changed a keyboard layout)

@dessalines
Copy link
Owner

I can't verify this, its probably an issue with an incorrect rebasing. You'll need to test with this codebase.

@nejni-marji
Copy link
Contributor

screen-20230910-102640.mp4

@dessalines
Copy link
Owner

We're on 1.14.0, so you're not using the current codebase. You need to test this with this codebase.

@Vander567321
Copy link
Author

@dessalines To answer your first comment, I paste the link by mistake in a text instead of the broxsers adress bar. When I tried to get rid of by word delete swipe I noted this unexpected behavior.
I tried to make a shorter example but failed to find one. Than I assumed the logic behind is somewhat easier to figure out from the source or by debugging.

@sslater11
Copy link
Contributor

sslater11 commented Sep 12, 2023

It's nothing to do with the paste key. There seems to be a limit of how far the backspace key will delete.

This is the max word size we can delete properly:
a123456789b123456789aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrrrrggggggggggggggmaxwordsize

Now if we add any extra letters to the end of that, the string will leave a few letters at the start.

Steps to reproduce:
Type or paste this: a123456789b123456789aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrrrrggggggggggggggmaxwordsizeOhNoExtraLetters
Swipe on the backspace key to delete whole word and we are left with
a123456789b12345

Example 2:
a123456789b123456789aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrrrrggggggggggggggmaxwordsizeABC
Swiping the delete key leaves us with:
a12

Example 3:
a123456789b123456789aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrrrrggggggggggggggmaxwordsizeABCDEFGHI
Swiping the delete key leaves us with:
a12345678

EDIT: Just tested, the bug is in the current git version.

@sslater11
Copy link
Contributor

sslater11 commented Sep 12, 2023

Found the bug + potential fix

Utils.kt
line 473
    val lastWords = ime.currentInputConnection.getTextBeforeCursor(100, 0)

As you can see the limit is hardcoded as 100 characters, so we could fix it by changing it to 9999. This seems to be the best solution so far.

There's another solution on stack overflow, but it's not great... https://stackoverflow.com/questions/7440269/better-way-to-get-all-the-text-in-an-edittext-from-an-inputconnection

// This won't work for some apps, so it's not perfect.
CharSequence currentText = inputConnection.getExtractedText(new ExtractedTextRequest(), 0).text;

@dessalines
Copy link
Owner

As you can see the limit is hardcoded as 100 characters, so we could fix it by changing it to 9999. This seems to be the best solution so far.

Ah okay, yeah that seems simple enough.

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

No branches or pull requests

4 participants