From 407283ee3c6849467ad9f328960f090a80ad04c6 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 23 Jun 2017 09:14:39 +0100 Subject: [PATCH] Fix a daft mistake, blank out whitelisted words, rather than remove This had caused an issue whereby spelling-mistakes would be highlighted on the wrong word in the client. This was a function of how many whitelisted words had already occured in the sequence. An off-by-n error. --- services/spelling/app/coffee/SpellingAPIManager.coffee | 8 ++++++-- .../test/unit/coffee/SpellingAPIManagerTests.coffee | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/services/spelling/app/coffee/SpellingAPIManager.coffee b/services/spelling/app/coffee/SpellingAPIManager.coffee index 3a0f68d81b..b8a7f10072 100644 --- a/services/spelling/app/coffee/SpellingAPIManager.coffee +++ b/services/spelling/app/coffee/SpellingAPIManager.coffee @@ -23,8 +23,12 @@ module.exports = SpellingAPIManager = ASpell.checkWords lang, words, (error, misspellings) -> callback error, misspellings: misspellings - wordsToCheck = (request.words || []).filter (word) -> - SpellingAPIManager.wordWhitelist.indexOf(word) == -1 + wordsToCheck = (request.words || []).map (word) -> + # blank out whitelisted words + if SpellingAPIManager.wordWhitelist.indexOf(word) == -1 + word + else + '...' if token? LearnedWordsManager.getLearnedWords token, (error, learnedWords) -> diff --git a/services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee b/services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee index 7f92f92fe0..1394a68c9d 100644 --- a/services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee +++ b/services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee @@ -89,7 +89,7 @@ describe "SpellingAPIManager", -> @SpellingAPIManager.runRequest @token, words: @words, (error, @result) => done() it 'should ignore the white-listed word', -> - expect(@ASpell.checkWords.lastCall.args[1]).to.deep.equal ["One", "Two"] + expect(@ASpell.checkWords.lastCall.args[1]).to.deep.equal ["One", "...", "Two"] describe "learnWord", -> describe "without a token", ->