Skip to content

Commit

Permalink
↗ fix selectable in empty secret list bug
Browse files Browse the repository at this point in the history
  • Loading branch information
f91og committed Nov 14, 2023
1 parent 5c7e830 commit 05fbb0f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/keymaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ use clipboard::{ClipboardContext, ClipboardProvider};
pub fn pressed_enter(app: &mut App) {
let secrets_panel = app.panels.get(&PanelName::Secrets).unwrap();
let selected_index = secrets_panel.index;
let secret_name = &secrets_panel.content[selected_index];
let secret = utils::get_secret(&secret_name, &utils::get_secret_file_path()).unwrap();
// 复制到剪贴板
let mut clipboard = ClipboardContext::new().unwrap();
clipboard.set_contents(secret).unwrap();
if secrets_panel.content.len() > 0 {
let secret_name = &secrets_panel.content[selected_index];
let secret = utils::get_secret(&secret_name, &utils::get_secret_file_path()).unwrap();
// 复制到剪贴板
let mut clipboard = ClipboardContext::new().unwrap();
clipboard.set_contents(secret).unwrap();
}
}

pub fn move_cursor_vertical(app: &mut App, step: i8) {
Expand All @@ -41,4 +43,4 @@ pub fn move_cursor_vertical(app: &mut App, step: i8) {
} else if step == -1 && secrets_panel.index > 0 {
secrets_panel.index -= 1;
}
}
}

0 comments on commit 05fbb0f

Please sign in to comment.