refactor: fix first id match error issue

上级 f8241d7c
...@@ -97,12 +97,16 @@ impl Scanner { ...@@ -97,12 +97,16 @@ impl Scanner {
if all_results.len() > 0 { if all_results.len() > 0 {
let mut best_match = all_results[0].clone(); let mut best_match = all_results[0].clone();
for x in all_results { if all_results.len() > 1 {
// todo: maybe have multiple captures best_match = all_results[1].clone();
if x.capture_indices[0].start <= best_match.capture_indices[0].start { for i in 1..all_results.len().clone() {
best_match = x; let current = all_results[i].capture_indices[0].clone();
if current.start <= best_match.capture_indices[0].start {
best_match = all_results[i].clone();
}
} }
} }
Some(best_match.clone()) Some(best_match.clone())
} else { } else {
None None
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册