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

Stop erasing the copy buffer if copying empty editor selections #1847

Merged
merged 2 commits into from
Jan 21, 2020

Conversation

dmsnell
Copy link
Member

@dmsnell dmsnell commented Jan 17, 2020

Resolves #1843

Previously it has been the case that if you attempt to copy something in
the note editor but there is no selection then it will wipe out the
system's copy buffer. This is because we implement our own copy handler
which strips away the visual formatting of elements in the note editor.

  1. Copy anything in any app, suppose you copy "test"
  2. Paste that "test" anywhere, it pastes
  3. Click in the note editor but don't select anything.
  4. "Copy" by hitting the copy shortcut or by using a menu option
  5. Paste anywhere

Although we'd expect that "test" is still in our copy buffer we get the
empty string pasted in and "test" is gone.

While not really wrong or broken this is a bit jarring and it's
probably better in most cases to preserve the previous copy buffer if
we're not copying anything. We've turned the copy command into a "clear
the copy buffer" command if there's no content.

In this patch we're aborting the copy if our selection is empty and that
will preserve the existing buffer and the expected behavior.

Testing

Follow the procedure above before and after applying this patch.

Before

copyBroken mov

After

copyWorking mov

Resolves #1843

Previously it has been the case that if you attempt to copy something in
the note editor but there is no selection then it will wipe out the
system's copy buffer. This is because we implement our own copy handler
which strips away the visual formatting of elements in the note editor.

 1. Copy anything in any app, suppose you copy "test"
 2. Paste that "test" anywhere, it pastes
 3. Click in the note editor but don't select anything.
 4. "Copy" by hitting the copy shortcut or by using a menu option
 5. Paste anywhere

Although we'd expect that "test" is still in our copy buffer we get the
empty string pasted in and "test" is gone.

While not really _wrong_ or _broken_ this is a bit jarring and it's
probably better in most cases to preserve the previous copy buffer if
we're not copying anything. We've turned the copy command into a "clear
the copy buffer" command if there's no content.

In this patch we're aborting the copy if our selection is empty and that
will preserve the existing buffer and the expected behavior.
@dmsnell dmsnell added the enhancement Improve existing functionality label Jan 17, 2020
@dmsnell dmsnell requested a review from a team January 17, 2020 22:29
Copy link
Contributor

@belcherj belcherj left a comment

Choose a reason for hiding this comment

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

Great change. I always dislike when this happens in editors

@dmsnell dmsnell merged commit 29c30c2 into develop Jan 21, 2020
@dmsnell dmsnell deleted the fix/only-copy-non-empty-selections branch January 21, 2020 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eliminate copy/cut no word
2 participants