Skip to content

Commit 0263d25

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 0a09c13 commit 0263d25

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
@@ -147,6 +147,14 @@ impl CommitList {
147147
.saturating_sub(self.items.index_offset()),
148148
)
149149
.map(|e| e.id.to_string()),
150+
[latest, .., earliest]
151+
if self
152+
.marked()
153+
.windows(2)
154+
.all(|w| w[0].0 + 1 == w[1].0) =>
155+
{
156+
Some(format!("{}^..{}", earliest.1, latest.1))
157+
}
150158
marked => Some(
151159
marked
152160
.iter()
@@ -1052,12 +1060,7 @@ mod tests {
10521060
};
10531061
assert_eq!(
10541062
cl.concat_selected_commit_ids(),
1055-
Some(String::from(concat!(
1056-
"0000000000000000000000000000000000000002 ",
1057-
"0000000000000000000000000000000000000003 ",
1058-
"0000000000000000000000000000000000000004 ",
1059-
"0000000000000000000000000000000000000005"
1060-
)))
1063+
Some(String::from("0000000000000000000000000000000000000005^..0000000000000000000000000000000000000002"))
10611064
);
10621065
}
10631066

0 commit comments

Comments
 (0)