fix(spelling): merge the two dictionary saves into one row (#1833)

A typo listed "Save to project-level dictionary" and "Save to
application-level dictionary" as two rows, each with the same →
submenu of both again — four ways to trigger two actions. The popup
now shows one "Save 'word' to dictionary" row that saves to the
project dictionary (application-level without a project); its →
submenu still offers each level, then the inspection controls.

Fixes #1832
Цей коміт міститься в:
arookieofc authored and GitHub committed 2026-11-06 22:10:48 +08:00
1 джерело 798da979a1
коміт 58f567c954
8 files changed
+22 -32

No files matched your search

+4 -8
Переглянути файл
@@ -77,15 +77,11 @@ describe("Typo inspection", () => {
expect(diagnosticMarks(lint)).toEqual([]);
view.dispatch({ selection: { anchor: 5 } });
expect(spellingIntentions(view).map((i) => i.label)).toEqual([
"Typo: Change to…",
"Save 'mesage' to project-level dictionary",
"Save 'mesage' to application-level dictionary",
]);
// IDEA's → menu: the dictionaries and the inspection's controls.
expect(spellingIntentions(view).map((i) => i.label)).toEqual(["Typo: Change to…", "Save 'mesage' to dictionary"]);
// IDEA's → menu: each dictionary level and the inspection's controls.
expect(spellingIntentions(view)[0]!.submenu?.map((i) => ("label" in i ? i.label : "-"))).toEqual([
"Save 'mesage' to project-level dictionary",
"Save 'mesage' to application-level dictionary",
"Save to project-level dictionary",
"Save to application-level dictionary",
"-",
"Edit inspection profile setting",
"Disable inspection",
+15 -12
Переглянути файл
@@ -142,26 +142,23 @@ export function spellingIntentions(view: EditorView): ListPopupItem[] {
const typo = typoAt(view.state, sel.head);
if (!typo) return [];
const hasProject = !!useProject.getState().project;
const saves: ListPopupItem[] = [
// One row saves to the project dictionary (application-level without a project);
// its submenu still offers each level, then the inspection controls.
const saveSubmenu: MenuItem[] = [
...(hasProject
? [
{
id: "spelling.saveProject",
label: tx`Save '${typo.word}' to project-level dictionary`,
icon: "bulb-fix",
run: () => saveToDictionary(typo.word, "project"),
label: "Save to project-level dictionary",
run: () => void saveToDictionary(typo.word, "project"),
},
]
: []),
{
id: "spelling.saveIde",
label: tx`Save '${typo.word}' to application-level dictionary`,
icon: "bulb-fix",
run: () => saveToDictionary(typo.word, "ide"),
label: "Save to application-level dictionary",
run: () => void saveToDictionary(typo.word, "ide"),
},
];
const submenu: MenuItem[] = [
...saves.map((s) => ({ id: s.id, label: s.label, verbatim: true, run: () => void s.run() })),
{ kind: "separator" },
...intentionControls({ id: SPELLING_INSPECTION, name: "Typo" }),
];
@@ -172,9 +169,15 @@ export function spellingIntentions(view: EditorView): ListPopupItem[] {
icon: "bulb-fix",
emphasis: true,
run: () => changeTo(view, typo),
submenu,
submenu: saveSubmenu,
},
{
id: "spelling.save",
label: tx`Save '${typo.word}' to dictionary`,
icon: "bulb-fix",
run: () => saveToDictionary(typo.word, hasProject ? "project" : "ide"),
submenu: saveSubmenu,
},
...saves.map((s) => ({ ...s, submenu })),
];
}
-2
Переглянути файл
@@ -3966,8 +3966,6 @@
"Rename '{name}'": "Renombrar '{name}'",
"Change '{word}' to": "Cambiar '{word}' a",
"Rename '{word}' to": "Renombrar '{word}' a",
"Save '{word}' to project-level dictionary": "Guardar '{word}' en el diccionario del proyecto",
"Save '{word}' to application-level dictionary": "Guardar '{word}' en el diccionario de la aplicación",
"Typo: In word '{word}'": "Error tipográfico: en la palabra '{word}'",
"Choose Super Class or Interface ({count} found)": "Elegir superclase o interfaz ({count} encontradas)",
"Choose Super Method of {name} ({count} found)": "Elegir supermétodo de {name} ({count} encontrados)",
-2
Переглянути файл
@@ -3826,8 +3826,6 @@
"Rename '{name}'": "Renommer '{name}'",
"Change '{word}' to": "Remplacer '{word}' par",
"Rename '{word}' to": "Renommer '{word}' en",
"Save '{word}' to project-level dictionary": "Enregistrer '{word}' dans le dictionnaire du projet",
"Save '{word}' to application-level dictionary": "Enregistrer '{word}' dans le dictionnaire de l'application",
"Typo: In word '{word}'": "Faute de frappe : dans le mot '{word}'",
"Choose Super Class or Interface ({count} found)": "Choisir la classe parente ou l'interface ({count} trouvées)",
"Choose Super Method of {name} ({count} found)": "Choisir la méthode parente de {name} ({count} trouvées)",
-2
Переглянути файл
@@ -3935,8 +3935,6 @@
"Rename '{name}'": "'{name}' 이름 변경",
"Change '{word}' to": "'{word}'을(를) 다음으로 변경",
"Rename '{word}' to": "'{word}'의 이름을 다음으로 변경",
"Save '{word}' to project-level dictionary": "'{word}'을(를) 프로젝트 수준 사전에 저장",
"Save '{word}' to application-level dictionary": "'{word}'을(를) 애플리케이션 수준 사전에 저장",
"Typo: In word '{word}'": "오타: 단어 '{word}'",
"Choose Super Class or Interface ({count} found)": "슈퍼 클래스 또는 인터페이스 선택({count}개 찾음)",
"Choose Super Method of {name} ({count} found)": "{name}의 슈퍼 메서드 선택({count}개 찾음)",
-2
Переглянути файл
@@ -3926,8 +3926,6 @@
"Rename '{name}'": "Zmień nazwę '{name}'",
"Change '{word}' to": "Zmień '{word}' na",
"Rename '{word}' to": "Zmień nazwę '{word}' na",
"Save '{word}' to project-level dictionary": "Zapisz '{word}' w słowniku poziomu projektu",
"Save '{word}' to application-level dictionary": "Zapisz '{word}' w słowniku poziomu aplikacji",
"Typo: In word '{word}'": "Literówka: w słowie '{word}'",
"Choose Super Class or Interface ({count} found)": "Wybierz nadklasę lub interfejs (znaleziono: {count})",
"Choose Super Method of {name} ({count} found)": "Wybierz nadrzędną metodę dla {name} (znaleziono: {count})",
-2
Переглянути файл
@@ -3932,8 +3932,6 @@
"Rename '{name}'": "Renomear '{name}'",
"Change '{word}' to": "Alterar '{word}' para",
"Rename '{word}' to": "Renomear '{word}' para",
"Save '{word}' to project-level dictionary": "Salvar '{word}' no dicionário do projeto",
"Save '{word}' to application-level dictionary": "Salvar '{word}' no dicionário do aplicativo",
"Typo: In word '{word}'": "Erro de digitação: na palavra '{word}'",
"Choose Super Class or Interface ({count} found)": "Escolher superclasse ou interface ({count} encontradas)",
"Choose Super Method of {name} ({count} found)": "Escolher supermétodo de {name} ({count} encontrados)",
+3 -2
Переглянути файл
@@ -4052,8 +4052,9 @@
"Rename '{name}'": "重命名 '{name}'",
"Change '{word}' to": "将 '{word}' 更改为",
"Rename '{word}' to": "将 '{word}' 重命名为",
"Save '{word}' to project-level dictionary": "将 '{word}' 保存到项目级词典",
"Save '{word}' to application-level dictionary": "将 '{word}' 保存到应用程序级词典",
"Save '{word}' to dictionary": "将 '{word}' 保存到词典",
"Save to project-level dictionary": "保存到项目级词典",
"Save to application-level dictionary": "保存到应用程序级词典",
"Typo: In word '{word}'": "拼写错误:单词 '{word}'",
"Choose Super Class or Interface ({count} found)": "选择超类或接口(找到 {count} 个)",
"Choose Super Method of {name} ({count} found)": "选择 {name} 的超方法(找到 {count} 个)",