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

Smartbar copying/cutting doesn't fully copy long blocks of text #1146

Closed
klaurence opened this issue Aug 11, 2021 · 16 comments · Fixed by #1154
Closed

Smartbar copying/cutting doesn't fully copy long blocks of text #1146

klaurence opened this issue Aug 11, 2021 · 16 comments · Fixed by #1154
Labels
area: clipboard Internal clipboard / clipboard history bug A bug report needs investigation Issues which require a more detailed investigation priority: 2-medium Issues which affect a single feature

Comments

@klaurence
Copy link
Contributor

klaurence commented Aug 11, 2021

"Short" description

When copying or cutting long blocks of text using the smartbar's Copy or Cut button, only a short portion of the text block gets copied. However, when copying or cutting short blocks of text, the text block is fully copied.

Sometimes, though, the clipboard becomes empty instead. Pasting (whether using the device's builtin copying menu or the smartbar's Paste button), then, would paste nothing.

The debug artifact that the bug first occurs in is PR #966's artifact. The bug doesn't occur in PR #963's artifact.

The bug occurs regardless of the application used. I tested PR #966's artifact as well as PR #963's with three note-taking/text editing apps. In all three, the bug occurred for #966's artifact but didn't occur for #963's artifact. If the need for testing arises, I've listed the three apps below.

The bug also doesn't occur even if the smartbar's Select All or Paste button was used along with the device's builtin selection copying menu. The bug, then, seems to occur because of the copying/cutting mechanism of the keyboard itself and not because of its pasting or selecting-all mechanism.

I'm not certain whether this bug is the same bug as described in #1027 or #1083. However, there is past discussion of this bug in #1027, where @Glitchy-Tozier was unable to reproduce it in 0.3.13-beta06.

Long lorem ipsum (example long text block)
Est incidunt exercitationem reprehenderit ipsam expedita. Iusto aliquid ut quas inventore. Ex consequatur voluptatem quaerat quas dolor.

Et aut nobis laudantium explicabo aut ipsam quisquam debitis. Sint repellendus consequatur dicta est molestias fugit. Voluptatem quod velit est repellendus nobis rerum tempore. Expedita saepe non perferendis porro. Enim esse dicta velit. Dolores est tempora voluptas dolorem quis commodi distinctio assumenda.

A et at et. Dolore ad accusamus consequatur nihil debitis maxime animi. Ratione molestiae assumenda dolorem facere. Quae voluptatem quaerat magni et. Dolorem esse sed aut.

Voluptatem suscipit voluptatem mollitia officiis porro. Laudantium id dolorem molestias rem aperiam eos. Provident voluptas praesentium sunt reiciendis molestiae. Sint numquam similique earum animi dolorum eos. Eveniet dolorem natus est.

Vel omnis asperiores voluptatem enim eum ea quisquam. Numquam assumenda cupiditate sequi nostrum possimus blanditiis est. Explicabo necessitatibus sit rerum dignissimos voluptatem. Nemo maiores ipsa molestiae. Et non minus omnis esse facilis error doloribus sed. Quia modi harum omnis fugit expedita.

Molestiae qui officiis earum saepe ut. Assumenda et voluptas facere. Cupiditate dolores iste accusamus quia aliquam perferendis dolores beatae. Dolorem quo sint officia omnis. Magnam veritatis sit porro. Voluptatibus quos perspiciatis quam repellendus explicabo.

Ipsam repellendus deserunt in voluptas aut eveniet tempora omnis. Dolorum aut molestiae ut dolores quo officiis. Laboriosam autem dolorem est aut voluptatibus nihil. Quo fugit vero velit mollitia et rerum. Itaque et et pariatur impedit qui expedita tenetur ex. Autem nulla eum id aperiam architecto alias.

Similique quaerat molestias voluptatem cum. Inventore cum consequuntur dicta enim nobis eligendi facilis rerum. A praesentium delectus odio vero. Adipisci eos rerum doloribus quidem voluptate dolorem minus assumenda.

Reiciendis ut saepe quidem. Placeat dolor facilis neque aut voluptas. Commodi sit minima ex. Animi rerum ratione cupiditate consequuntur. Porro molestiae dolore deleniti. Sint praesentium cumque sunt ipsam amet voluptates ducimus.

Delectus omnis in nisi laborum saepe modi. Ad non sunt est rerum est. Illum itaque quae ipsam deleniti dolorem. Voluptas et libero optio eos ipsa. Sed possimus ut voluptate. Nihil perspiciatis nisi enim.
Remaining lorem ipsum portion after copy/cut and paste
 itaque quae ipsam deleniti dolorem. Voluptas et libero optio eos ipsa. Sed possimus ut voluptate. Nihil perspiciatis nisi enim.

(128 characters long, for some reason)

Apps used for testing

Steps to reproduce

  1. Go to a text box where typing is possible.
  2. Copy the example lorem ipsum text above and paste it into the text box using the device's builtin copying menu.
  3. Select all of the text box's text.
  4. Copy or cut the text using the keyboard's Copy or Cut button in the smartbar. (The bug occurs with either copying or cutting.)
  5. Paste the text. (Using the keyboard's Paste button is fine as it shouldn't influence the resulting pasted text.)

Environment information

@klaurence klaurence added the bug A bug report label Aug 11, 2021
@Glitchy-Tozier
Copy link
Collaborator

I love how well you put together your issues. :)

@GoRaN909
Copy link
Contributor

Yeah that's right the copy/cut and pasting function on the smartbar doesn't work correctly i always using the system copy and cut functions by long pressing of the text i wish that this annoying bug get fix on newer versions because i love this keyboard app don't wana change it to other keyboards.

@patrickgold
Copy link
Member

Thanks for your extensive bug report regarding this issue, I really appreciate the read!

The debug artifact that the bug first occurs in is PR #966's artifact. The bug doesn't occur in PR #963's artifact.

#966 was merged in-between beta02 and beta03, also in #1027 (comment) you mention the cut bug occurs in beta03. So I did compare the changes beta03 introduced (they mostly came from #966 anyways). Summarized: the internal editor instance was reworked, the keyboard state register introduced, updates to the UI redraw mechanism, service names surfacing the system were abstracted, etc., although nothing specific why the cut/copy feature is broken all of a sudden.

When copying or cutting long blocks of text using the smartbar's Copy or Cut button, only a short portion of the text block gets copied. However, when copying or cutting short blocks of text, the text block is fully copied.

Now before I can do more debugging and assumptions, it is important for me to know: do you use the internal clipboard or use the system clipboard as clip-data storage (Settings > Keyboard > Group clipboard)? Also if using the internal one, do you allow syncing from/to the system clipboard? The state of these preferences can decide if this or that logic is applied to copying and helps me a lot in setting up the exact environment to trace the faulty behavior.

I'm not certain whether this bug is the same bug as described in #1027 or #1083. However, there is past discussion of this bug in #1027, where @Glitchy-Tozier was unable to reproduce it in 0.3.13-beta06.

#1083 is definitely the same, #1027 also I think. As this issue provides the most info at once though, this is the issue I will use until the bug is resolved, the others will be closed with a reference to this one.

@patrickgold patrickgold added area: clipboard Internal clipboard / clipboard history needs investigation Issues which require a more detailed investigation priority: 2-medium Issues which affect a single feature labels Aug 13, 2021
@klaurence
Copy link
Contributor Author

Do you use the internal clipboard or use the system clipboard as clip-data storage? Also if using the internal one, do you allow syncing from/to the system clipboard?

When I wrote the initial issue, the "Use internal clipboard" option was turned off. Testing every combination of the "Use internal clipboard", "Sync from internal clipboard", and "Sync to internal clipboard" options, the bug still occurs.

@klaurence
Copy link
Contributor Author

klaurence commented Aug 13, 2021

Here is a video of the bug. Notice how the full example lorem ipsum text is pasted fully the first time. After copying and then pasting again, the text is incomplete.

Florisboard-copying_internal-clipboard-disabled.mp4

Here is also a video of the bug not occurring when the copied text is short.

Florisboard-copying_internal-clipboard-disabled-short-text-block.mp4

@patrickgold
Copy link
Member

Thanks for the screen shares! I played around on my device and got the copy bug immediately. It is the same across all apps, so it is a problem within FlorisBoard. One consistency the bug had was, that it always looked the same length when the cursor was at the end. So I copied some different long texts and noticed the hard limit of 128 characters before the cursor.

I searched the code base for 128 and immediately came across these two lines:

private const val CACHED_TEXT_N_CHARS_BEFORE_CURSOR: Int = 128
private const val CACHED_TEXT_N_CHARS_AFTER_CURSOR: Int = 48

which are used to limit the cached text to improve the performance. And looking at the limits these are also the limits for cut/copy. I am too tired now to do extensive debugging, but I guess the cut/copy use the cached input rather than the intended getSelectedText() method. Will look into possible fixes for the cut/copy bug tomorrow.

@klaurence
Copy link
Contributor Author

klaurence commented Aug 14, 2021

One consistency the bug had was, that it always looked the same length when the cursor was at the end. So I copied some different long texts and noticed the hard limit of 128 characters before the cursor.

I can also reproduce this with the cursor at the very end.

Further confirming its relation, I just tried on my phone putting the cursor in the middle of a long block of text and then pressing the smartbar's Select All button and then its Copy button. The keyboard copied 128 characters before the cursor (the same value as CACHED_TEXT_N_CHARS_BEFORE_CURSOR) and 48 characters after it (the same as CACHED_TEXT_N_CHARS_AFTER_CURSOR). Placing the cursor at the beginning only copied 48 characters. The videos I showed had the cursor at the very end so 128 characters before and none after it were copied.

Will look into possible fixes for the cut/copy bug tomorrow.

I see. I'll keep an eye out for it!

@patrickgold
Copy link
Member

Above PR #1154 should be a fix for the bug. I have just tested it out on my device and it seems to work. I will perform further testing though if it also works for some edge cases. @KLaurence or anyone interested: could you also try out the debug artifact if it works for you to confirm it's fixed?

@klaurence
Copy link
Contributor Author

klaurence commented Aug 14, 2021

Copying and cutting works properly for me in the debug artifact. I'll mention some people that might be interested (but don't hesitate to try out the artifact if I didn't mention you):

@GoRaN909, you've mentioned that copying and cutting also doesn't work for you. Can you check if PR #1154's debug artifact fixes the problem?

@Atrate, you've added a +1 reaction to the main comment. Assuming (purely based on that +1) that this problem also occurs for you, can you also check the debug artifact and see if your problem is also fixed?

@mistery, you created issues #1027 and #1083 which Patrick has closed in favor of this issue because of their similarity. Can you also check if the debug artifact fixes the problem for you?

(I have only known how to download artifacts recently, so, if anyone would also like to know, the debug artifact can be found at the PR's page > Checks > Artifacts.)

@patrickgold
Copy link
Member

Thanks for trying it out and confirming that it has been fixed! I will still wait at the responses of the mentioned users, but should nothing be mentioned until tomorrow I will merge the changes in, as I definitely want to have this fix in beta09 tomorrow.

@alensiljak
Copy link

Thanks everyone for the effort. I only have access to a phone for the next couple of days.
I'm not sure what the artifacts are. I don't see the Checks item on the (mobile) PRs page.
I'll be happy to get the new beta as soon as it is available for download.

@patrickgold
Copy link
Member

patrickgold commented Aug 14, 2021

Direct artifact link: https://github.com/florisboard/florisboard/suites/3498981713/artifacts/83372021

Edit: just tried out the link on mobile and it does not work, check out https://github.com/florisboard/florisboard/pull/1154/checks and then on the very-mobile friendly page Atrifacts > app-debug.apk

@alensiljak
Copy link

Thanks, Patrick. It worked when I clicked the link in the email. I can confirm that pasting seems to work fine now.

@GoRaN909
Copy link
Contributor

@GoRaN909, you've mentioned that copying and cutting also doesn't work for you. Can you check if PR #1154's debug artifact fixes the problem?

Yes the bug was fixed for me i tested the debug version now copy/cut is works using smartbar buttons also the copied text shows correctly on the clipboard manager it's not empty.

Thanks for both of you :)

@klaurence
Copy link
Contributor Author

klaurence commented Aug 14, 2021

Glad the problem's also fixed for both of you!

@patrickgold, thank you for fixing this bug! I'll keep the issue open in case something arises, but feel free to close it when you merge the PR into master.

@patrickgold
Copy link
Member

Thanks to all of you for testing out the fix, will merge them into master, so it is included in today's beta09 release.

I'll keep the issue open in case something arises, but feel free to close it when you merge the PR into master.

This issue is linked to the PR, means as soon as I merge the PR in GitHub will auto-close this issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: clipboard Internal clipboard / clipboard history bug A bug report needs investigation Issues which require a more detailed investigation priority: 2-medium Issues which affect a single feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants