Use node-nsspellchecker to replace $native's spell checker.

This commit is contained in:
Cheng Zhao
2013-03-24 15:45:15 +08:00
parent 142824ec01
commit 3ed35574d4
4 changed files with 7 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
{View} = require 'space-pen'
Range = require 'range'
CorrectionsView = require './corrections-view'
NSSpellChecker = require 'nsspellchecker'
module.exports =
class MisspellingView extends View
@@ -30,7 +31,7 @@ class MisspellingView extends View
screenRange = @getScreenRange()
misspelling = @editor.getTextInRange(@editor.bufferRangeForScreenRange(screenRange))
corrections = $native.getCorrectionsForMisspelling(misspelling)
corrections = NSSpellChecker.getCorrectionsForMisspelling(misspelling)
@correctionsView?.remove()
@correctionsView = new CorrectionsView(@editor, corrections, screenRange)

View File

@@ -1,3 +1,5 @@
NSSpellChecker = require 'nsspellchecker'
module.exports =
findMisspellings: (text) ->
wordRegex = /(?:^|[\s\[\]])([a-zA-Z']+)(?=[\s\.\[\]]|$)/g
@@ -6,7 +8,7 @@ module.exports =
for line in text.split('\n')
while matches = wordRegex.exec(line)
word = matches[1]
continue unless $native.isMisspelled(word)
continue unless NSSpellChecker.isMisspelled(word)
startColumn = matches.index + matches[0].length - word.length
endColumn = startColumn + word.length
misspellings.push([[row, startColumn], [row, endColumn]])