forked from 1b-agent/opencadstudio-upstream
fix(spellcheck): Linux wordlist flags unknown words; only hunspell counts as CLI
- check_word returned "valid" for a word missing from a loaded wordlist (!words.is_empty() && !contains, with contains already false), so the wordlist backend never flagged anything. - aspell on PATH counted as a CLI speller, but only hunspell is invoked, so on a machine with aspell and no hunspell every CLI check silently failed. - A bare wordlist offers no suggestions; the test no longer demands them from the linux_system backend. Unused PathBuf import dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
60e23a43a6
commit
ab0682153d
2 files changed
+10
-5
No files matched your search
@@ -819,7 +819,9 @@ fn text_audit_system_spellcheck_flags_misspelled_words() {
|
|||||||
flagged
|
flagged
|
||||||
);
|
);
|
||||||
|
|
||||||
// At least one flagged word should have suggestions
|
// At least one flagged word should have suggestions — except from a
|
||||||
|
// bare Linux wordlist, which can tell a word is unknown but has no
|
||||||
|
// way to suggest one without the hunspell CLI.
|
||||||
let has_suggestions = words.iter().any(|w| {
|
let has_suggestions = words.iter().any(|w| {
|
||||||
w["suggestions"]
|
w["suggestions"]
|
||||||
.as_array()
|
.as_array()
|
||||||
@@ -827,7 +829,7 @@ fn text_audit_system_spellcheck_flags_misspelled_words() {
|
|||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
});
|
});
|
||||||
assert!(
|
assert!(
|
||||||
has_suggestions,
|
has_suggestions || sp["backend"] == "linux_system",
|
||||||
"expected at least one word to have suggestions"
|
"expected at least one word to have suggestions"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ pub(crate) mod linux_impl {
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::Path;
|
||||||
|
|
||||||
const LINUX_DICT_DIRS: &[&str] = &[
|
const LINUX_DICT_DIRS: &[&str] = &[
|
||||||
"/usr/share/hunspell",
|
"/usr/share/hunspell",
|
||||||
@@ -645,7 +645,8 @@ pub(crate) mod linux_impl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let has_cli = is_command_in_path("hunspell") || is_command_in_path("aspell");
|
// Only hunspell is ever invoked (`check_via_cli`), so only it counts.
|
||||||
|
let has_cli = is_command_in_path("hunspell");
|
||||||
|
|
||||||
if !found_any && !has_cli {
|
if !found_any && !has_cli {
|
||||||
return None;
|
return None;
|
||||||
@@ -683,7 +684,9 @@ pub(crate) mod linux_impl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(!self.words.is_empty() && !self.words.contains(&clean), Vec::new())
|
// Not in the wordlist and no CLI answer: misspelled when there is
|
||||||
|
// a wordlist to judge by, unjudged (accepted) when there is none.
|
||||||
|
(self.words.is_empty(), Vec::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user