Skip to content

Commit d57558a

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 fd46b9a commit d57558a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/components/commitlist.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ impl CommitList {
141141
.saturating_sub(self.items.index_offset()),
142142
)
143143
.map(|e| e.id.to_string()),
144+
[latest, .., earliest]
145+
if self
146+
.marked()
147+
.windows(2)
148+
.all(|w| w[0].0 + 1 == w[1].0) =>
149+
{
150+
Some(format!("{}^..{}", earliest.1, latest.1))
151+
}
144152
marked => Some(
145153
marked
146154
.iter()
@@ -1046,12 +1054,7 @@ mod tests {
10461054
};
10471055
assert_eq!(
10481056
cl.concat_selected_commit_ids(),
1049-
Some(String::from(concat!(
1050-
"0000000000000000000000000000000000000002 ",
1051-
"0000000000000000000000000000000000000003 ",
1052-
"0000000000000000000000000000000000000004 ",
1053-
"0000000000000000000000000000000000000005"
1054-
)))
1057+
Some(String::from("0000000000000000000000000000000000000005^..0000000000000000000000000000000000000002"))
10551058
);
10561059
}
10571060

0 commit comments

Comments
 (0)