search: Improve performance of replace_all (#13654)

Previously replace_all amounted to what could be achieved by repeatedly
mashing "Replace" button, which had a bunch of overhead related to
buffer state syncing. This commit gets rid of the automated button
mashing, processing all of the replacements in one go.

Fixes #13455



Release Notes:

- Improved performance of "replace all" in buffer search and project
search
This commit is contained in:
Piotr Osiewicz 2024-06-28 19:06:44 +02:00 committed by GitHub
parent b616f9c27f
commit 0761383752
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 58 additions and 6 deletions

View file

@ -1122,9 +1122,7 @@ impl BufferSearchBar {
.as_ref()
.clone()
.with_replacement(self.replacement(cx));
for m in matches {
searchable_item.replace(m, &query, cx);
}
searchable_item.replace_all(&mut matches.iter(), &query, cx);
}
}
}

View file

@ -591,9 +591,7 @@ impl ProjectSearchView {
}
self.results_editor.update(cx, |editor, cx| {
for item in &match_ranges {
editor.replace(item, &query, cx);
}
editor.replace_all(&mut match_ranges.iter(), &query, cx);
});
self.model.update(cx, |model, _cx| {