From c1950f087ec24e947ce739875e181ca2ff69f21e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 5 Sep 2016 02:58:10 -0400 Subject: ClipboardStore: Rename "last", only set it on first run * Rename `last` to `original` because we only want to set it the first time we set the clipboard. Subsequent times we set the clipboard contents should not affect this saved value. * Only set `original` on first run of the clipboard `set_contents` function. --- src/clipboard_store.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/clipboard_store.rs b/src/clipboard_store.rs index 61f53b3..d334dd6 100644 --- a/src/clipboard_store.rs +++ b/src/clipboard_store.rs @@ -6,7 +6,7 @@ use clipboard::ClipboardContext; pub struct ClipboardStore { context: ClipboardContext, - last: String, + original: String, } impl ClipboardStore { @@ -16,15 +16,15 @@ impl ClipboardStore { return Ok( ClipboardStore { context: context, - last: String::new(), + original: String::new(), } ) } pub fn set_contents(&mut self, data: String) -> Result<(), Box> { - // Save last value - self.last = try!(self.context.get_contents()); - println!("last: {}", self.last); + if self.original.is_empty() { + self.original = try!(self.context.get_contents()) + } // Set new clipboard contents // self.context.set_contents(data) -- cgit v1.2.3