diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-04-30 13:30:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-30 13:30:46 +0000 |
commit | bc038f8295830cbd66851d308fd2963f2e0eb60c (patch) | |
tree | 66b51d3dd448fee837f3fa748d0587dab1597b4b | |
parent | 66fb7cb3275b9a9a8505a6919856bc110ed5a06c (diff) | |
download | alacritty-bc038f8295830cbd66851d308fd2963f2e0eb60c.tar.gz alacritty-bc038f8295830cbd66851d308fd2963f2e0eb60c.zip |
Remove clipboard loading error logging
On macOS the clipboard actually returns an error when loading it and it
is empty. However this is not an `Empty` error but all errors are simple
boxed Errors from std.
Since loading the clipboard data usually should not fail, we now do not
log it as error if it fails but just print it to the debug log instead.
This fixes #2389.
-rw-r--r-- | alacritty_terminal/src/clipboard.rs | 12 | ||||
-rw-r--r-- | alacritty_terminal/src/input.rs | 27 |
2 files changed, 17 insertions, 22 deletions
diff --git a/alacritty_terminal/src/clipboard.rs b/alacritty_terminal/src/clipboard.rs index ca70c3bf..a761dcb1 100644 --- a/alacritty_terminal/src/clipboard.rs +++ b/alacritty_terminal/src/clipboard.rs @@ -75,16 +75,22 @@ impl Clipboard { }; clipboard.set_contents(text.into()).unwrap_or_else(|err| { - warn!("Error storing selection to clipboard. {}", err); + warn!("Unable to store text in clipboard: {}", err); }); } - pub fn load(&mut self, ty: ClipboardType) -> Result<String, Box<std::error::Error>> { + pub fn load(&mut self, ty: ClipboardType) -> String { let clipboard = match (ty, &mut self.secondary) { (ClipboardType::Secondary, Some(provider)) => provider, _ => &mut self.primary, }; - clipboard.get_contents() + match clipboard.get_contents() { + Err(err) => { + debug!("Unable to load text from clipboard: {}", err); + String::new() + } + Ok(text) => text, + } } } diff --git a/alacritty_terminal/src/input.rs b/alacritty_terminal/src/input.rs index ddc71473..d3bbd74f 100644 --- a/alacritty_terminal/src/input.rs +++ b/alacritty_terminal/src/input.rs @@ -39,7 +39,6 @@ use crate::message_bar::{self, Message}; use crate::term::mode::TermMode; use crate::term::{Search, SizeInfo, Term}; use crate::url::Url; -use crate::util::fmt::Red; use crate::util::start_daemon; pub const FONT_SIZE_STEP: f32 = 0.5; @@ -282,36 +281,26 @@ impl Action { ctx.copy_selection(ClipboardType::Primary); }, Action::Paste => { - ctx.terminal_mut() + let text = ctx.terminal_mut() .clipboard() - .load(ClipboardType::Primary) - .map(|contents| self.paste(ctx, &contents)) - .unwrap_or_else(|err| { - error!("Error loading data from clipboard: {}", Red(err)); - }); + .load(ClipboardType::Primary); + self.paste(ctx, &text); }, Action::PasteSelection => { // Only paste if mouse events are not captured by an application if !mouse_mode { - ctx.terminal_mut() + let text = ctx.terminal_mut() .clipboard() - .load(ClipboardType::Secondary) - .map(|contents| self.paste(ctx, &contents)) - .unwrap_or_else(|err| { - error!("Error loading data from clipboard: {}", Red(err)); - }); + .load(ClipboardType::Secondary); + self.paste(ctx, &text); } }, Action::Command(ref program, ref args) => { trace!("Running command {} with args {:?}", program, args); match start_daemon(program, args) { - Ok(_) => { - debug!("Spawned new proc"); - }, - Err(err) => { - warn!("Couldn't run command {}", err); - }, + Ok(_) => debug!("Spawned new proc"), + Err(err) => warn!("Couldn't run command {}", err), } }, Action::ToggleFullscreen => { |