Skip to content
Permalink
Browse files

fix(Spell check): Fix spell checker to initialize without loaded dict…

…ionary
  • Loading branch information...
adlk committed Oct 2, 2019
1 parent a31566d commit 734732f1f901093ec78b166413aa3315f6f61248
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/webview/spellchecker.js
@@ -18,8 +18,8 @@ const DEFAULT_LOCALE = 'en-us';
async function loadDictionary(locale) {
try {
const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`);
await provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`));
debug('Loaded dictionary', locale, 'from', fileLocation);
return provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`));
} catch (err) {
console.error('Could not load dictionary', err);
}
@@ -44,8 +44,8 @@ export async function switchDict(locale = DEFAULT_LOCALE) {
if (currentDict) {
provider.unloadDictionary(locale);
}
loadDictionary(locale);
attached.switchLanguage(locale);
await loadDictionary(locale);
await attached.switchLanguage(locale);

debug('Switched dictionary to', locale);

@@ -77,9 +77,11 @@ export default async function initialize(languageCode = DEFAULT_LOCALE) {
debug('Attaching spellcheck provider');
attached = await attachSpellCheckProvider(provider);

debug('Available spellchecker dictionaries', provider.availableDictionaries);
const availableDictionaries = await provider.getAvailableDictionaries();

attached.switchLanguage(locale);
debug('Available spellchecker dictionaries', availableDictionaries);

await switchDict(locale);

return provider;
} catch (err) {

0 comments on commit 734732f

Please sign in to comment.
You can’t perform that action at this time.