diff options
author | 2019-10-02 10:45:25 +0200 | |
---|---|---|
committer | 2019-10-02 10:45:25 +0200 | |
commit | 734732f1f901093ec78b166413aa3315f6f61248 (patch) | |
tree | c602b2d4226a105d105bb476ef299b2a6e797472 /src/webview | |
parent | fix(Settings): Fix cache size calculation after clearing cache (diff) | |
download | ferdium-app-734732f1f901093ec78b166413aa3315f6f61248.tar.gz ferdium-app-734732f1f901093ec78b166413aa3315f6f61248.tar.zst ferdium-app-734732f1f901093ec78b166413aa3315f6f61248.zip |
fix(Spell check): Fix spell checker to initialize without loaded dictionary
Diffstat (limited to 'src/webview')
-rw-r--r-- | src/webview/spellchecker.js | 12 |
1 files changed, 7 insertions, 5 deletions
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'; | |||
18 | async function loadDictionary(locale) { | 18 | async function loadDictionary(locale) { |
19 | try { | 19 | try { |
20 | const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`); | 20 | const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`); |
21 | await provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`)); | ||
22 | debug('Loaded dictionary', locale, 'from', fileLocation); | 21 | debug('Loaded dictionary', locale, 'from', fileLocation); |
22 | return provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`)); | ||
23 | } catch (err) { | 23 | } catch (err) { |
24 | console.error('Could not load dictionary', err); | 24 | console.error('Could not load dictionary', err); |
25 | } | 25 | } |
@@ -44,8 +44,8 @@ export async function switchDict(locale = DEFAULT_LOCALE) { | |||
44 | if (currentDict) { | 44 | if (currentDict) { |
45 | provider.unloadDictionary(locale); | 45 | provider.unloadDictionary(locale); |
46 | } | 46 | } |
47 | loadDictionary(locale); | 47 | await loadDictionary(locale); |
48 | attached.switchLanguage(locale); | 48 | await attached.switchLanguage(locale); |
49 | 49 | ||
50 | debug('Switched dictionary to', locale); | 50 | debug('Switched dictionary to', locale); |
51 | 51 | ||
@@ -77,9 +77,11 @@ export default async function initialize(languageCode = DEFAULT_LOCALE) { | |||
77 | debug('Attaching spellcheck provider'); | 77 | debug('Attaching spellcheck provider'); |
78 | attached = await attachSpellCheckProvider(provider); | 78 | attached = await attachSpellCheckProvider(provider); |
79 | 79 | ||
80 | debug('Available spellchecker dictionaries', provider.availableDictionaries); | 80 | const availableDictionaries = await provider.getAvailableDictionaries(); |
81 | 81 | ||
82 | attached.switchLanguage(locale); | 82 | debug('Available spellchecker dictionaries', availableDictionaries); |
83 | |||
84 | await switchDict(locale); | ||
83 | 85 | ||
84 | return provider; | 86 | return provider; |
85 | } catch (err) { | 87 | } catch (err) { |