summaryrefslogtreecommitdiffstats
path: root/src/pattern
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-08-07 17:17:31 +0200
committerCanop <cano.petrole@gmail.com>2020-08-07 17:49:27 +0200
commit4d5b7e68d7d306ffb7018d7edd2e22adfc00d38d (patch)
tree007c3b617de45e9caa840c4c75ef3eed0cb15e6c /src/pattern
parenta71834bf89b22fa0a755cf51f261377db7fa1116 (diff)
fix possible crash/errors in fuzzy matches in file content previews
When displaying the matches, the name_match indexes were interpreted as byte indexes while they're char indexes
Diffstat (limited to 'src/pattern')
-rw-r--r--src/pattern/regex_patterns.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pattern/regex_patterns.rs b/src/pattern/regex_patterns.rs
index d32ea8d..e3bcf3b 100644
--- a/src/pattern/regex_patterns.rs
+++ b/src/pattern/regex_patterns.rs
@@ -40,7 +40,7 @@ impl RegexPattern {
flags: flags.to_string(),
})
}
- // return a match if the pattern can be found in the candidate string
+ /// return a match if the pattern can be found in the candidate string
pub fn find(&self, candidate: &str) -> Option<NameMatch> {
// note that there's no significative cost related to using
// find over is_match
@@ -52,10 +52,10 @@ impl RegexPattern {
super::NameMatch { score: 1, pos }
})
}
- // return the number of results we should find before starting to
- // sort them (unless time is runing out).
- // In the case of regexes, there's no need to find more results, as
- // their score is always 1
+ /// return the number of results we should find before starting to
+ /// sort them (unless time is runing out).
+ /// In the case of regexes, there's no need to find more results, as
+ /// their score is always 1
pub fn optimal_result_number(&self, targeted_size: usize) -> usize {
targeted_size
}