Skip to content

Commit 734732f

Browse files
committed
fix(Spell check): Fix spell checker to initialize without loaded dictionary
1 parent a31566d commit 734732f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/webview/spellchecker.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const DEFAULT_LOCALE = 'en-us';
1818
async function loadDictionary(locale) {
1919
try {
2020
const fileLocation = path.join(DICTIONARY_PATH, `hunspell-dict-${locale}/${locale}`);
21-
await provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`));
2221
debug('Loaded dictionary', locale, 'from', fileLocation);
22+
return provider.loadDictionary(locale, readFileSync(`${fileLocation}.dic`), readFileSync(`${fileLocation}.aff`));
2323
} catch (err) {
2424
console.error('Could not load dictionary', err);
2525
}
@@ -44,8 +44,8 @@ export async function switchDict(locale = DEFAULT_LOCALE) {
4444
if (currentDict) {
4545
provider.unloadDictionary(locale);
4646
}
47-
loadDictionary(locale);
48-
attached.switchLanguage(locale);
47+
await loadDictionary(locale);
48+
await attached.switchLanguage(locale);
4949

5050
debug('Switched dictionary to', locale);
5151

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

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

82-
attached.switchLanguage(locale);
82+
debug('Available spellchecker dictionaries', availableDictionaries);
83+
84+
await switchDict(locale);
8385

8486
return provider;
8587
} catch (err) {

0 commit comments

Comments
 (0)