Skip to content

Commit

Permalink
reword misspelled spans to only the word. closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
sinistersnare committed Nov 20, 2014
1 parent dcdf383 commit ca044f6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/spellck/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,20 @@ impl<'a> SpellingVisitor<'a> {
/// and `FooBar` into `foo` & `bar` and `Foo` & `Bar`
/// respectively. This inserts any incorrect word(s) into the
/// misspelling map.
fn check_subwords(&mut self, w: &str, pos: Position) {
for w in words::subwords(w) {
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();
match self.misspellings.get_mut(&pos) {
Some(v) => {
v.push(w);
continue
}
None => {}
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(w.len() as u32);

if let Some(v) = self.misspellings.get_mut(&pos) {
v.push(ws);
continue
}
self.misspellings.insert(pos, vec![w]);

self.misspellings.insert(pos, vec![ws]);
}
}
}
Expand Down

0 comments on commit ca044f6

Please sign in to comment.