False positive: 'PR' and username '@xxx' flagged
Description
Example:
Thank you for the PR @hippietrail
Both PR and the username are flagged. I would expect that:
PRis being recognised as a valid abbreviation (both Pull Request and Public Relations are common)- whatever comes in a single token starting with @ is not being checked for correctness
Screenshots
PR is definitely in the dictionary. It's one of a few words that for some reason get marked as spelling mistakes despite being in the dictionary. I suspect it's a side-effect of how the dictionary conflated as case-variants into a single entry but I've never dug into it. I'll be on the road for a week so probably won't have time to investigate it.
I'm pretty sure @ is treated as its own token and hippietrail wouldn't be in the dictionary. Are you saying @ followed by anything wordish should be exempted from spellcheck? That's certainly possible.
@elijah-potter Do you have insights on the former and opinions on the latter?
Exactly, my personal preference would be that if a word starts with @, it is treated as an internal reference and therefore whatever directly follows in this single word should be exempted from spellcheck.
Exactly, my personal preference would be that if a word starts with
@, it is treated as an internal reference and therefore whatever directly follows in this single word should be exempted from spellcheck.
If somebody wants to try to code this up and make a PR they should mimic my code for condense_filename_extensions() in document.rs but this one would be a bit simpler. It should probably be called condense_mentions() or condense_at_mentions()
There are probably other things with @ that are not springing to mind so it should be behind a preference. I don't think such prefs are easy to make as of yet?
PRis definitely in the dictionary. It's one of a few words that for some reason get marked as spelling mistakes despite being in the dictionary. I suspect it's a side-effect of how the dictionary conflated as case-variants into a single entry but I've never dug into it.
Debugging indicates that the issue relates to this code block here, at linting/spell_check.rs:76:
if let Some(word_metadata) = word.kind.as_word().unwrap() {
if word_metadata.dialects.is_dialect_enabled(self.dialect)
&& (self.dictionary.contains_exact_word(word_chars)
|| self.dictionary.contains_exact_word(&word_chars.to_lower()))
{
continue;
}
};
The word the dictionary pulls for 'PR' is 'Pr' (a different entry in the dictionary). Then, with the two calls to contains_exact_word(), it checks whether 'PR' or 'pr' match the canonical spelling of the entry 'Pr'. This check fails, the continue is skipped, and the word gets marked as a spelling error.
More concisely, I think you could say the issue lies in contains_exact_word() searching for words case-insensitively, but then comparing the word it finds case-sensitively.
PRis definitely in the dictionary. It's one of a few words that for some reason get marked as spelling mistakes despite being in the dictionary. I suspect it's a side-effect of how the dictionary conflated as case-variants into a single entry but I've never dug into it.Debugging indicates that the issue relates to this code block here, at
linting/spell_check.rs:76:if let Some(word_metadata) = word.kind.as_word().unwrap() { if word_metadata.dialects.is_dialect_enabled(self.dialect) && (self.dictionary.contains_exact_word(word_chars) || self.dictionary.contains_exact_word(&word_chars.to_lower())) { continue; } }; The word the dictionary pulls for 'PR' is 'Pr' (a different entry in the dictionary). Then, with the two calls to
contains_exact_word(), it checks whether 'PR' or 'pr' match the canonical spelling of the entry 'Pr'. This check fails, thecontinueis skipped, and the word gets marked as a spelling error.More concisely, I think you could say the issue lies in
contains_exact_word()searching for words case-insensitively, but then comparing the word it finds case-sensitively.
Ah that makes sense. A word in the dictionary is case-folded when it's "compiled". So the source file dictionary.dict might have pr, Pr, PR, and pR. (In fact it has Pr and PR. The former is probably the symbol for the element praseodymium since I know the symbols of the elements are all in there.) So each of those would be canonical if they were different words but there's not a way to extract them. I just added flags so you can know if there are lowercase, titlecase, all caps, PascalCase and lowerCamel, which would probably be enough for 2-letter worfds, but not enough to fully reconstruct longer words. I'm only vaguely familiar with contains_exact_word() but it seems to me it would not be able to fully reconstruct the case folded entries either so probably only one of the variants would be there. This is just thinking out loud though, not from analysing the code.
See also #939 and #1419