chore: Use aho-corasick 1.1 in direct dependencies (#2983)

Nothing too fancy, we've depended indirectly on 1.0/1.1 already, so this
is essentially bookkeeping.

Release Notes:
- N/A
This commit is contained in:
Piotr Osiewicz 2023-09-18 17:01:08 +02:00 committed by GitHub
parent 5c22e40e99
commit 616d328f3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 99 additions and 67 deletions

View file

@ -35,7 +35,7 @@ impl SearchInputs {
#[derive(Clone, Debug)]
pub enum SearchQuery {
Text {
search: Arc<AhoCorasick<usize>>,
search: Arc<AhoCorasick>,
replacement: Option<String>,
whole_word: bool,
case_sensitive: bool,
@ -84,24 +84,23 @@ impl SearchQuery {
case_sensitive: bool,
files_to_include: Vec<PathMatcher>,
files_to_exclude: Vec<PathMatcher>,
) -> Self {
) -> Result<Self> {
let query = query.to_string();
let search = AhoCorasickBuilder::new()
.auto_configure(&[&query])
.ascii_case_insensitive(!case_sensitive)
.build(&[&query]);
.build(&[&query])?;
let inner = SearchInputs {
query: query.into(),
files_to_exclude,
files_to_include,
};
Self::Text {
Ok(Self::Text {
search: Arc::new(search),
replacement: None,
whole_word,
case_sensitive,
inner,
}
})
}
pub fn regex(
@ -151,13 +150,13 @@ impl SearchQuery {
deserialize_path_matches(&message.files_to_exclude)?,
)
} else {
Ok(Self::text(
Self::text(
message.query,
message.whole_word,
message.case_sensitive,
deserialize_path_matches(&message.files_to_include)?,
deserialize_path_matches(&message.files_to_exclude)?,
))
)
}
}
pub fn with_replacement(mut self, new_replacement: Option<String>) -> Self {