fix(spellcheck): let win < 8 fallback to hunspell

This commit is contained in:
Evan Morikawa 2015-12-11 16:41:41 -05:00
parent 8fe4a7a02f
commit 1d7f9f6cac
2 changed files with 16 additions and 21 deletions

View file

@ -48,9 +48,9 @@ describe "NylasSpellchecker", ->
expect(nodeSpellchecker.setDictionary.calls[0].args[0]).toBe "en_US"
dict = nodeSpellchecker.setDictionary.calls[0].args[1]
if process.platform is "darwin"
expect(dict.length).toBe 0
expect(dict.length).toBeGreaterThan 0
else if process.platform is "win32"
expect(dict.length).toBe 0
expect(dict.length).toBeGreaterThan 0
else if process.platform is "linux"
expect(dict.length).toBeGreaterThan 0

View file

@ -16,7 +16,7 @@ class NylasSpellchecker
isSpelledCorrectly: (args...) => not @isMisspelled(args...)
setLanguage: (lang="", dict="") ->
setLanguage: (lang="", dict=@_getHunspellDictionary()) ->
@languageAvailable = @isLanguageAvailable(lang)
if @languageAvailable
spellCheck = @isSpelledCorrectly
@ -29,24 +29,19 @@ class NylasSpellchecker
@_setWebframeSpellchecker(lang, spellCheck)
if process.platform is "linux"
dictionaryPath = @_getHunspellDictionary()
else
# On Mac we defer to NSSpellChecker
# On Windows we use the Windows Spell Check API
#
# Both of those automatically provide a set of dictionaries based on
# the language string.
#
# On Windows 10 you can see the dictionaries that are available by
# looking in: C:\Users\YourName\AppData\Roaming\Microsoft\Spelling
#
# The `dictionaryPath` parameter is ignored on Mac & Windows by
# node-spellchecker
dictionaryPath = ""
if dict.length is 0 then dict = dictionaryPath
# On Mac we defer to NSSpellChecker
# On Windows we use the Windows Spell Check API
#
# Both of those automatically provide a set of dictionaries based on
# the language string.
#
# On Windows 10 you can see the dictionaries that are available by
# looking in: C:\Users\YourName\AppData\Roaming\Microsoft\Spelling
#
# The `dict` parameter is ignored by node-spellchecker
#
# On Linux and old versions of windows we default back to the hunspell
# dictionary
spellchecker.setDictionary(lang, dict)
# Separate method for testing