Skip to content

Commit

Permalink
[FIX] Multiple language selection on spellchecking (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan authored Apr 16, 2019
1 parent 1897d47 commit f85bdd4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/preload/spellchecking.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ class SpellCheck {
}
}

filterDictionaries(...dictionaries) {
return dictionaries.map((dictionary) => {
const matches = /^(\w+?)[-_](\w+)$/.exec(dictionary);

const dictionaries = matches ?
[`${ matches[1] }_${ matches[2] }`, `${ matches[1] }-${ matches[2] }`, matches[1]] :
[dictionary];

return dictionaries.find((dictionary) => this.dictionaries.includes(dictionary));
}).filter(Boolean);
filterDictionaries(dictionaries) {
return dictionaries
.flatMap((dictionary) => {
const matches = /^(\w+?)[-_](\w+)$/.exec(dictionary);
return matches ?
[`${ matches[1] }_${ matches[2] }`, `${ matches[1] }-${ matches[2] }`, matches[1]] :
[dictionary];
})
.filter((dictionary) => this.dictionaries.includes(dictionary));
}

enable(...dictionaries) {
Expand Down Expand Up @@ -130,7 +129,7 @@ class SpellCheck {
);

this.checker = mem(
((dictionaries, text) => dictionaries.every((dictionary) => singleDictionaryChecker(dictionary, text)))
((dictionaries, text) => dictionaries.some((dictionary) => singleDictionaryChecker(dictionary, text)))
.bind(null, this.enabledDictionaries)
);
} finally {
Expand Down

0 comments on commit f85bdd4

Please sign in to comment.