From a91faaf55cf2184d13930938aeb5289a9e2f1c16 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 12 Mar 2015 12:33:45 +0000 Subject: [PATCH] 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 --- .../spelling/app/coffee/ASpellWorker.coffee | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/services/spelling/app/coffee/ASpellWorker.coffee b/services/spelling/app/coffee/ASpellWorker.coffee index 29e7491fad..e8b3aadb78 100644 --- a/services/spelling/app/coffee/ASpellWorker.coffee +++ b/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("!")