Skip to content

Commit 3a861dc

Browse files
committed
fix: Reverse commit range before yanking
Produce `<oldest>^..<newest>` when yanking consecutive range. Now, given consecutive marked selection, gitui's selection matches `git log`'s output in commit range.
1 parent 809cb41 commit 3a861dc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/commitlist.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ impl CommitList {
134134

135135
///
136136
pub fn copy_commit_hash(&self) -> Result<()> {
137-
let marked = self.marked.as_slice();
137+
let marked = self.marked.iter().rev().cloned().collect_vec();
138+
let marked = marked.as_slice();
139+
138140
let yank: Option<String> = match marked {
139141
[] => self
140142
.items
@@ -147,7 +149,7 @@ impl CommitList {
147149
[(_idx, commit)] => Some(commit.to_string()),
148150
[first, .., last] => {
149151
let marked_consecutive =
150-
marked.windows(2).all(|w| w[0].0 + 1 == w[1].0);
152+
marked.windows(2).all(|w| w[0].0 - 1 == w[1].0);
151153

152154
let yank = if marked_consecutive {
153155
format!("{}^..{}", first.1, last.1)

0 commit comments

Comments
 (0)