Skip to content

Commit 92756f3

Browse files
committed
Remove dependency on itertools
1 parent 627031e commit 92756f3

File tree

3 files changed

+11
-35
lines changed

3 files changed

+11
-35
lines changed

Cargo.lock

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helix-term/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ helix-loader = { version = "0.6", path = "../helix-loader" }
3333

3434
anyhow = "1"
3535
once_cell = "1.16"
36-
itertools = "0.10.5"
3736

3837
which = "4.2"
3938

helix-term/src/commands.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ use serde::de::{self, Deserialize, Deserializer};
6868
use grep_regex::RegexMatcherBuilder;
6969
use grep_searcher::{sinks, BinaryDetection, SearcherBuilder};
7070
use ignore::{DirEntry, WalkBuilder, WalkState};
71-
use itertools::FoldWhile::{Continue, Done};
72-
use itertools::Itertools;
7371
use tokio_stream::wrappers::UnboundedReceiverStream;
7472

7573
pub struct Context<'a> {
@@ -5042,30 +5040,19 @@ fn move_selection(cx: &mut Context, direction: MoveSelection) {
50425040
// which would make the transaction to panic.
50435041
// Conflicts are resolved by picking only the top change in such case.
50445042
fn remove_conflicts(changes: Vec<Change>) -> Vec<Change> {
5045-
if changes.len() > 2 {
5046-
changes
5047-
.into_iter()
5048-
.fold_while(vec![], |mut acc: Vec<Change>, change| {
5049-
if let Some(last_change) = acc.pop() {
5050-
if last_change.0 >= change.0 || last_change.1 >= change.1 {
5051-
acc.push(last_change);
5052-
Done(acc)
5053-
} else {
5054-
acc.push(last_change);
5055-
acc.push(change);
5056-
Continue(acc)
5057-
}
5058-
} else {
5059-
acc.push(change);
5060-
Continue(acc)
5061-
}
5062-
})
5063-
.into_inner()
5064-
} else {
5065-
changes
5043+
let mut new_changes: Vec<Change> = Vec::new();
5044+
for change in changes {
5045+
match new_changes.last() {
5046+
Some(last_change) if last_change.0 >= change.0 || last_change.1 >= change.1 => {
5047+
return new_changes;
5048+
}
5049+
_ => new_changes.push(change.clone()),
5050+
}
50665051
}
5052+
5053+
new_changes
50675054
}
5068-
let flat: Vec<Change> = all_changes.into_iter().flatten().unique().collect();
5055+
let flat: Vec<Change> = all_changes.into_iter().flatten().collect();
50695056
let filtered = remove_conflicts(flat);
50705057

50715058
let new_selection = selection.clone().transform(|range| {

0 commit comments

Comments
 (0)