From 48611012cdf8b1ac4f752f3565fb447c6d6393e3 Mon Sep 17 00:00:00 2001 From: Davis Silverman Date: Thu, 20 Nov 2014 04:32:55 -0500 Subject: [PATCH] stopped variable shadowing, multiple misspellings per attr --- src/spellck/visitor.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/spellck/visitor.rs b/src/spellck/visitor.rs index 0286837..355f6c0 100644 --- a/src/spellck/visitor.rs +++ b/src/spellck/visitor.rs @@ -97,17 +97,17 @@ impl<'a> SpellingVisitor<'a> { fn check_subwords(&mut self, whole: &str, mut pos: Position) { for w in words::subwords(whole) { if !self.raw_word_is_correct(w) { - let w = w.to_string(); + let ws = w.into_string(); + let amt = whole.subslice_offset(w); + pos.span.lo = pos.span.lo + BytePos(amt as u32); + pos.span.hi = pos.span.lo + BytePos(amt as u32 + w.len() as u32); + if let Some(v) = self.misspellings.get_mut(&pos) { - v.push(w); + v.push(ws); continue } - if let Some(amt) = whole.find_str(w.as_slice()) { - pos.span.lo = pos.span.lo + BytePos(amt as u32); - pos.span.hi = pos.span.lo + BytePos(w.len() as u32); - } - self.misspellings.insert(pos, vec![w]); + self.misspellings.insert(pos, vec![ws]); } } }