copy commit hash

This commit is contained in:
Antonio Yang 2020-12-10 22:20:39 +08:00 committed by Stephan Dilly
parent 587acf219e
commit 3101f7b104
2 changed files with 17 additions and 0 deletions

View file

@ -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<bool> { fn move_selection(&mut self, scroll: ScrollType) -> Result<bool> {
self.update_scroll_speed(); self.update_scroll_speed();

View file

@ -151,6 +151,11 @@ impl Revlog {
self.list.selected_entry().map(|e| e.id) self.list.selected_entry().map(|e| e.id)
} }
fn copy_commit_hash(&self) -> Result<()> {
self.list.copy_entry_hash()?;
Ok(())
}
fn selected_commit_tags( fn selected_commit_tags(
&self, &self,
commit: &Option<CommitId>, commit: &Option<CommitId>,
@ -204,6 +209,9 @@ impl Component for Revlog {
self.commit_details.toggle_visible()?; self.commit_details.toggle_visible()?;
self.update()?; self.update()?;
return Ok(true); 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 { } else if k == self.key_config.log_tag_commit {
return self.selected_commit().map_or( return self.selected_commit().map_or(
Ok(false), Ok(false),