From 3f603deb4a933e93aaea272a3d06ed2a096706b0 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Tue, 16 Apr 2019 15:41:47 -0300 Subject: [PATCH] Apply fixes to multiple language spellchecking --- src/preload/spellchecking.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/preload/spellchecking.js b/src/preload/spellchecking.js index 8df2b7c857..6f79f2366a 100644 --- a/src/preload/spellchecking.js +++ b/src/preload/spellchecking.js @@ -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) { @@ -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 {