diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index 2c4fff38..16b071d9 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -121,6 +121,15 @@ impl CommitList { ) } + pub fn copy_entry_hash(&self) -> Result<()> { + if let Some(e) = self.items.iter().nth( + self.selection.saturating_sub(self.items.index_offset()), + ) { + crate::clipboard::copy_string(&e.hash_short)?; + } + Ok(()) + } + fn move_selection(&mut self, scroll: ScrollType) -> Result { self.update_scroll_speed(); diff --git a/src/tabs/revlog.rs b/src/tabs/revlog.rs index f2bd3b42..d3184753 100644 --- a/src/tabs/revlog.rs +++ b/src/tabs/revlog.rs @@ -151,6 +151,11 @@ impl Revlog { self.list.selected_entry().map(|e| e.id) } + fn copy_commit_hash(&self) -> Result<()> { + self.list.copy_entry_hash()?; + Ok(()) + } + fn selected_commit_tags( &self, commit: &Option, @@ -204,6 +209,9 @@ impl Component for Revlog { self.commit_details.toggle_visible()?; self.update()?; return Ok(true); + } else if k == self.key_config.copy { + self.copy_commit_hash()?; + return Ok(true); } else if k == self.key_config.log_tag_commit { return self.selected_commit().map_or( Ok(false),