Skip to content

Commit 0b6fb22

Browse files
committed
Check if we can instantiate ClipboardContext
1 parent 36ede22 commit 0b6fb22

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/interface/handler.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
3535
if let Some(selected) = app.table.state.selected(){
3636
if let Some(element) = app.table.items.get(selected){
3737
if let Some(otp_code) = element.get(3){
38-
let mut ctx = ClipboardContext::new().unwrap();
39-
ctx.set_contents(otp_code.to_owned()).unwrap();
38+
// in some occasions we can't copy contents to clipboard, so let's check for a good result
39+
if let Ok(mut ctx) = ClipboardContext::new(){
40+
ctx.set_contents(otp_code.to_owned()).unwrap();
41+
}
4042
}
4143
}
4244
}

0 commit comments

Comments
 (0)