From 92d99c30bcfe451c39caf316e2d7ae736921bb3e Mon Sep 17 00:00:00 2001 From: Matt Harrison Date: Wed, 11 Dec 2019 12:12:40 -0500 Subject: [PATCH] preserve the current clipboard when using the Clipboard backend. Store the current clipboard and restore it after the expansion has been pasted. This prevents your current clipboard from being lost if using the Clipboard backend. --- src/engine.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine.rs b/src/engine.rs index 79f5e3d..151835d 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -205,8 +205,10 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa } }, BackendType::Clipboard => { + let previous_clipboard_content = self.clipboard_manager.get_clipboard().unwrap_or(String::from("")); self.clipboard_manager.set_clipboard(&target_string); self.keyboard_manager.trigger_paste(&config.paste_shortcut); + self.clipboard_manager.set_clipboard(&previous_clipboard_content); }, }