From 8b71734c1af4c10ad55ed0c0831dbfdda8859efa Mon Sep 17 00:00:00 2001 From: Peer Sommerlund Date: Tue, 29 Apr 2025 07:43:38 +0200 Subject: [PATCH 1/2] Document tuple used in CommitList.marked --- src/components/commitlist.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index dde38ba06e..f603007042 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -45,6 +45,9 @@ pub struct CommitList { items: ItemBatch, highlights: Option>>, commits: IndexSet, + /// The marked commits. + /// `self.marked[].0` holds the commit index into `self.items.items` - used for ordering the list. + /// `self.marked[].1` is the commit id of the marked commit. marked: Vec<(usize, CommitId)>, scroll_state: (Instant, f32), tags: Option, From e695b0d77828835ddaa7c80e4d50ecedb8db7796 Mon Sep 17 00:00:00 2001 From: Peer Sommerlund Date: Wed, 16 Apr 2025 07:53:09 +0200 Subject: [PATCH 2/2] Remove CommitList::marked() to avoid exposing internal structure --- src/components/commitlist.rs | 9 --------- src/tabs/revlog.rs | 8 ++++---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index f603007042..06c48e751b 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -117,15 +117,6 @@ impl CommitList { self.marked.len() } - /// - #[expect( - clippy::missing_const_for_fn, - reason = "as of 1.86.0 clippy wants this to be const even though that breaks" - )] - pub fn marked(&self) -> &[(usize, CommitId)] { - &self.marked - } - /// pub fn clear_marked(&mut self) { self.marked.clear(); diff --git a/src/tabs/revlog.rs b/src/tabs/revlog.rs index ff4f9a0f95..74f7d1b0cc 100644 --- a/src/tabs/revlog.rs +++ b/src/tabs/revlog.rs @@ -586,19 +586,19 @@ impl Component for Revlog { self.queue.push(InternalEvent::OpenPopup( StackablePopupOpen::CompareCommits( InspectCommitOpen::new( - self.list.marked()[0].1, + self.list.marked_commits()[0], ), ), )); return Ok(EventState::Consumed); } else if self.list.marked_count() == 2 { //compare two marked commits - let marked = self.list.marked(); + let marked = self.list.marked_commits(); self.queue.push(InternalEvent::OpenPopup( StackablePopupOpen::CompareCommits( InspectCommitOpen { - commit_id: marked[0].1, - compare_id: Some(marked[1].1), + commit_id: marked[0], + compare_id: Some(marked[1]), tags: None, }, ),