Skip to content

Commit

Permalink
Deduplicate regexes in search_selection command (helix-editor#3941)
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Walrus authored and Shekhinah Memmel committed Dec 11, 2022
1 parent a7969ae commit 1801863
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,8 @@ fn search_selection(cx: &mut Context) {
.selection(view.id)
.iter()
.map(|selection| regex::escape(&selection.fragment(contents)))
.collect::<HashSet<_>>() // Collect into hashset to deduplicate identical regexes
.into_iter()
.collect::<Vec<_>>()
.join("|");

Expand Down

0 comments on commit 1801863

Please sign in to comment.