mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2026-02-02 07:35:10 +01:00
fix: empty candidate
This commit is contained in:
parent
0177086dcc
commit
0e4e5d3714
2 changed files with 6 additions and 1 deletions
|
|
@ -69,10 +69,12 @@ replace,
|
||||||
pattern = [
|
pattern = [
|
||||||
"did not match any file"
|
"did not match any file"
|
||||||
]
|
]
|
||||||
|
# alternatively `git checkout {{typo[2]({{shell(git branch | sed 's/^*//')}})}}`
|
||||||
suggest = [
|
suggest = [
|
||||||
'''
|
'''
|
||||||
#[cmd_contains(checkout)]
|
#[cmd_contains(checkout)]
|
||||||
git checkout {{typo[2]({{shell(git branch)}})}} '''
|
git branch {{command[2]}} && \
|
||||||
|
git checkout {{command[2]}} '''
|
||||||
]
|
]
|
||||||
|
|
||||||
[[match_err]]
|
[[match_err]]
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,9 @@ pub fn find_similar(typo: &str, candidates: &Vec<String>) -> Option<String> {
|
||||||
let mut min_distance = 10;
|
let mut min_distance = 10;
|
||||||
let mut min_distance_index = None;
|
let mut min_distance_index = None;
|
||||||
for (i, candidate) in candidates.iter().enumerate() {
|
for (i, candidate) in candidates.iter().enumerate() {
|
||||||
|
if candidate.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let distance = compare_string(typo, candidate);
|
let distance = compare_string(typo, candidate);
|
||||||
if distance < min_distance {
|
if distance < min_distance {
|
||||||
min_distance = distance;
|
min_distance = distance;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue