Deduplicate regexes in search_selection command (#3941)

This commit is contained in:
A-Walrus 2022-09-22 18:33:30 +03:00 committed by GitHub
parent e621848d07
commit eb6fd283dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1760,6 +1760,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("|");