Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Don't keep the text selected after it's copied. #2342

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ public void onAction(String action) {
} else if (action.equals(GeckoSession.SelectionActionDelegate.ACTION_COPY) && selectionValid) {
String selectedText = mBinding.urlEditText.getText().toString().substring(startSelection, endSelection);
clipboard.setPrimaryClip(ClipData.newPlainText("text", selectedText));
mBinding.urlEditText.setSelection(endSelection);
} else if (action.equals(GeckoSession.SelectionActionDelegate.ACTION_PASTE) && clipboard.hasPrimaryClip()) {
ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
if (selectionValid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,11 @@ public void onAction(String action) {
if (aSelection.isActionAvailable(action)) {
aSelection.execute(action);
}
if (GeckoSession.SelectionActionDelegate.ACTION_COPY.equals(action) &&
aSelection.isActionAvailable(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT)) {
// Don't keep the text selected after it's copied.
aSelection.execute(GeckoSession.SelectionActionDelegate.ACTION_UNSELECT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing we can do in a follow up is use the shorthand calls, so You can just call aSelection.unselect() instead of calling the more verbose execute(). The fact that you have to check if the action is available sort of sucks though.

}
}

@Override
Expand Down