From 734732f1f901093ec78b166413aa3315f6f61248 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 2 Oct 2019 10:45:25 +0200 Subject: fix(Spell check): Fix spell checker to initialize without loaded dictionary --- src/webview/spellchecker.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/webview/spellchecker.js') diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js index d7bb983dc..06cbd283a 100644 --- a/src/webview/spellchecker.js +++ b/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) { -- cgit v1.2.3-54-g00ecf