ソースを参照

use the language code $$l as the end of stream marker

cannot use a custom word in the session dictionary due to language
restrictions on allowed characters, e.g. armenian 'hy' does not allow
latin characters
Brian Gough 11 年 前
親
コミット
a91faaf55c
1 ファイル変更、7 行追加、11 行削除
  1. 7 11
      services/spelling/app/coffee/ASpellWorker.coffee

+ 7 - 11
services/spelling/app/coffee/ASpellWorker.coffee

@@ -27,10 +27,11 @@ class ASpellWorker
 				@callback err, []
 
 		output = ""
+		endMarker = new RegExp("^(#{language}|Error)$", "m")
 		@pipe.stdout.on "data", (chunk) =>
 			output = output + chunk
-			# We receive a single "*" from Aspell as the end of data marker
-			if chunk.toString().match(/^\*$/m)
+			# We receive the language code from Aspell as the end of data marker
+			if chunk.toString().match(endMarker)
 				@callback(null, output.slice())
 				@state = 'ready'
 				output = ""
@@ -52,7 +53,6 @@ class ASpellWorker
 		# receive the end of data marker
 		@state = 'busy'
 		@callback = callback
-		@setEndOfStreamMarker()
 		@setTerseMode()
 		@write(words)
 		@flush()
@@ -67,9 +67,10 @@ class ASpellWorker
 
 	flush: () ->
 		# get aspell to send an end of data marker "*" when ready
-		@sendCommand("%")		# take the aspell pipe out of terse mode so we can look for a '*'
-		@sendCommand("^ENDOFSTREAMMARKER") # send our marker which will generate a '*'
-		@sendCommand("!")		# go back into terse mode
+		#@sendCommand("%")		# take the aspell pipe out of terse mode so we can look for a '*'
+		#@sendCommand("^ENDOFSTREAMMARKER") # send our marker which will generate a '*'
+		#@sendCommand("!")		# go back into terse mode
+		@sendCommand("$$l")
 
 	shutdown: (reason) ->
 		logger.log process: @pipe.pid, reason: reason, 'shutting down'
@@ -81,11 +82,6 @@ class ASpellWorker
 		return if @state == 'killed'
 		@pipe.kill('SIGKILL')
 
-	setEndOfStreamMarker: () ->
-		return if @setup
-		@sendCommand("@ENDOFSTREAMMARKER") # make this string a valid word
-		@setup = true
-
 	setTerseMode: () ->
 		@sendCommand("!")