Skip to content

Commit

Permalink
spellcheck: show disabled "no languages" menu item if list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiry committed Jun 2, 2019
1 parent 9e59686 commit 20e479f
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/electron-main/spell-check/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,30 @@ export function buildSpellCheckSettingsMenuItems(
},
];

if (checkSpelling && detectedLocales.length) {
menuItems.push({
label: "Languages",
submenu: detectedLocales.map((detectedLocale) => {
return {
label: detectedLocale,
type: "radio",
enabled: checkSpelling,
checked: detectedLocale === currentLocale,
click() {
onChangeLocale(detectedLocale);
},
} as const;
}),
});
if (!checkSpelling) {
return menuItems;
}

return menuItems;
return [
...menuItems,
detectedLocales.length
? {
label: "Languages",
submenu: detectedLocales.map((detectedLocale) => {
return {
label: detectedLocale,
type: "radio",
enabled: checkSpelling,
checked: detectedLocale === currentLocale,
click() {
onChangeLocale(detectedLocale);
},
} as const;
}),
}
: {
label: "(No Languages)",
enabled: false,
},
];
}

0 comments on commit 20e479f

Please sign in to comment.