mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-02 19:17:03 +00:00
fix(proofing): stop flagging bare URLs as misspelled on macOS
NSSpellChecker's implicit URL handling is unreliable for URLs alone on a line (a bookmark list), flagging the whole URL as one misspelling. Request the link checking type alongside spelling so the data detector claims URL ranges, then keep only spelling results. Real misspellings are unaffected.
This commit is contained in:
1 parent
af389c7097
commit
20365dd02d
1 file changed
+4
-1
@@ -33,7 +33,7 @@ pub fn check(text: &str, custom: &HashSet<String>) -> Vec<MacIssue> {
|
||||
checker.checkString_range_types_options_inSpellDocumentWithTag_orthography_wordCount(
|
||||
&ns,
|
||||
NSRange { location: 0, length: len },
|
||||
NSTextCheckingType::Spelling.bits(),
|
||||
(NSTextCheckingType::Spelling | NSTextCheckingType::Link).bits(),
|
||||
None,
|
||||
0,
|
||||
None,
|
||||
@@ -45,6 +45,9 @@ pub fn check(text: &str, custom: &HashSet<String>) -> Vec<MacIssue> {
|
||||
let chars: Vec<char> = text.chars().collect();
|
||||
let mut issues = Vec::new();
|
||||
for result in results.iter() {
|
||||
if result.resultType() != NSTextCheckingType::Spelling {
|
||||
continue;
|
||||
}
|
||||
let range = result.range();
|
||||
let start = map[range.location.min(len)];
|
||||
let end = map[(range.location + range.length).min(len)];
|
||||
|
||||
Reference in new issue
Block a user