typo detection: only check fn variables in same or higher scope

pull/2049/head
joe-conigliaro 2019-09-20 19:23:43 +10:00 committed by Alexander Medvednikov
parent ba4ea351c7
commit f657d70a67
1 changed files with 3 additions and 0 deletions

View File

@ -1057,6 +1057,9 @@ fn (f &Fn) find_misspelled_local_var(name string, min_match f32) string {
mut closest := f32(0)
mut closest_var := ''
for var in f.local_vars {
if var.scope_level > f.scope_level {
continue
}
n := name.all_after('.')
if var.name == '' || (n.len - var.name.len > 2 || var.name.len - n.len > 2) { continue }
p := strings.dice_coefficient(var.name, n)