Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework misspelled spans to only the word. #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should checked after adjusting the span.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Although I actually think it could be removed, since this new system of spans should mean that there's never any repeats: each word has a unique span.)

v.push(ws);
continue
}
self.misspellings.insert(pos, vec![w]);

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