refactor: fix first id match error issue

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