Jump to content

SOLVED: Prevent snippets from overwriting the clipboard when pasting


Recommended Posts

I start with something in my clipboard. I use one of my snippets in Alfred that utilizes the {clipboard} keyword to take what's currently in my clipboard and injects it into the snippet text then pastes it.

 

When I execute the snippet presumably, it copies the snippet into the system clipboard then pastes it into the foreground application.

 

The issue I face is that my clipboard is now overwritten with the snippet text, not my original text. I'm not able to quickly reuse my snippet again, since the initial text is now different. When I execute the snippet in this state I get compounded recursive text pasted and ever expanding clipboard contents whet the snippet is used repeatedly.

 

Example: I start with the text "watermelon" in my clipboard. My snippet is: "My favorite fruit is {clipboard}." When I execute the snippet, it's pasted as intended, but the clipboard now contains the text: "My favorite fruit is watermelon." When I execute the snippet again, the text pasted is: "My favorite fruit is My favorite fruit is watermelon.."

 

I recommend an option (checkbox) be added to the bottom of the edit snippet screen that says, "Preserve initial clipboard contents" or "Do not write to clipboard" or "Prevent overwriting clipboard" or something to that effect, like so:

1056535807_ScreenShot2021-03-15at1_52_14PM.thumb.png.293f4f5bda284079b45a6a0a204f63b4.png

Edited by sudopeople
Link to comment
Share on other sites

22 minutes ago, sudopeople said:

I recommend an option (checkbox) be added to the bottom of the edit snippet screen that says, "Preserve initial clipboard contents" or "Do not write to clipboard" or "Prevent overwriting clipboard" or something to that effect, like so:

 

Alfred already restores the clipboard. You're almost certainly having a timing issue. Try adjusting "Restore after" in "Auto Expansion Options":

alfred-clipboard-tweaks.thumb.png.d3c0acdda7f73f58637f4102383ca8e0.png

Link to comment
Share on other sites

Quote

Alfred already restores the clipboard. You're almost certainly having a timing issue. Try adjusting "Restore after" in "Auto Expansion Options"

 

Ahh, I don't use Auto Expansion, so I never thought to look in its options. So (even without "Automatically expand snippets by keyword" enabled) I was indeed able to get the behavior I described above by checking "Restore clipboard contents: After Snippets Viewer or Keyword" in the Auto Expand Options configuration pane, pictured below:

1144188620_ScreenShot2021-03-15at4_29_28PM.thumb.png.d28f55ac93a49cbed5b36d04af09fd5f.png

 

Thanks very much, @deanishe

Link to comment
Share on other sites

  • sudopeople changed the title to SOLVED: Prevent snippets from overwriting the clipboard when pasting

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...