feat(spelling): save typos to custom dictionaries with a default dictionary setting (#5466)

Co-authored-by: muutot <[email protected]>
Цей коміт міститься в:
Muuтаmuutot authored and GitHub committed 2026-11-24 06:01:01 +08:00
1 джерело ea7ec41064
коміт bd0f28cd3b
16 files changed
+441 -22

No files matched your search

+4 -1
Переглянути файл
@@ -160,6 +160,8 @@ export interface SpellingValid {
ideWords: string[];
projectWords: string[];
customDictionaries: string[];
/** Where "Save '…' to dictionary" writes; empty means project (application without a project). */
defaultDictionary: string;
}
const stringList = (v: unknown): string[] =>
@@ -171,6 +173,7 @@ function validateSpelling(raw: unknown): SpellingValid {
ideWords: stringList(r.ideWords),
projectWords: stringList(r.projectWords),
customDictionaries: stringList(r.customDictionaries),
defaultDictionary: typeof r.defaultDictionary === "string" ? r.defaultDictionary : "",
};
}
@@ -226,7 +229,7 @@ export const DEFAULT_SETTINGS: ValidSettings = {
cmake: {},
projectStructure: DEFAULT_PROJECT_STRUCTURE,
inspections: DEFAULT_INSPECTIONS,
spelling: { ideWords: [], projectWords: [], customDictionaries: [] },
spelling: { ideWords: [], projectWords: [], customDictionaries: [], defaultDictionary: "" },
tools: {},
languageServers: {},
agents: {
+23 -1
Переглянути файл
@@ -9,7 +9,8 @@ import { useSettingsDialog } from "../../model/staging";
import { useSetting } from "../../components/context";
import { GlobListEditor, Row, SearchLabel, Section } from "../../components/Form";
import { useProject } from "@/platform/project";
import { T, Tabs } from "@/ui";
import { Select, T, Tabs } from "@/ui";
import type { SelectOption } from "@/ui";
import type { PageSpec } from "../spec";
import formStyles from "../../components/Form.module.css";
import styles from "./Spelling.module.css";
@@ -101,8 +102,29 @@ function AcceptedWords() {
function SpellingPage() {
const [dictionaries, setDictionaries] = useSetting<string[]>("spelling.customDictionaries", "global");
const [defaultDictionary, setDefaultDictionary] = useSetting<string>("spelling.defaultDictionary", "global");
const newProjects = useSettingsDialog((s) => s.newProjects);
const hasProject = useProject((s) => !!s.project) && !newProjects;
const fallback = hasProject ? "project" : "application";
const options: SelectOption<string>[] = [
...(hasProject ? [{ value: "project", label: "Project dictionary" }] : []),
{ value: "application", label: "Application dictionary" },
...words(dictionaries ?? [])
.filter((d) => d !== "project" && d !== "application")
.map((d) => ({ value: d, label: d, verbatim: true })),
];
return (
<div className={styles.spelling}>
<Section stackFields>
<Row label="Default dictionary" hint="The dictionary the editor's Save '…' to dictionary quick fix writes to.">
<Select
value={options.some((option) => option.value === defaultDictionary) ? defaultDictionary : fallback}
options={options}
onChange={(v) => setDefaultDictionary(v)}
aria-label="Default dictionary"
/>
</Row>
</Section>
<Section title="Custom dictionaries">
<Row
label="Dictionary files"