diff options
| -rw-r--r-- | background_scripts/bg_utils.coffee | 14 | ||||
| -rw-r--r-- | background_scripts/commands.coffee | 2 | ||||
| -rw-r--r-- | tests/unit_tests/commands_test.coffee | 1 | 
3 files changed, 16 insertions, 1 deletions
| diff --git a/background_scripts/bg_utils.coffee b/background_scripts/bg_utils.coffee index ea54c900..27ecb0cc 100644 --- a/background_scripts/bg_utils.coffee +++ b/background_scripts/bg_utils.coffee @@ -77,4 +77,18 @@ BgUtils =              logElement.value += "#{dateString}: #{message}\n"              logElement.scrollTop = 2000000000 +  # Remove comments from a list of lines and merge lines where the last character on the preceding line is "\". +  parseLines: (lines) -> +    previousText = [] +    for line in lines +      line = line.replace /^\s+/g, '' +      continue if line.length == 0 +      continue if line[0] in '#"' +      if line[line.length-1] == "\\" +        previousText.push line[...line.length-1] +        continue +      line = previousText.join(" ") + line +      previousText = [] +      line +  root.BgUtils = BgUtils diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index d12b704d..d24bdb05 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -61,7 +61,7 @@ Commands =          [key[0], @parseKeySequence(key[1..])...]    parseCustomKeyMappings: (customKeyMappings) -> -    for line in customKeyMappings.split "\n" +    for line in BgUtils.parseLines customKeyMappings.split "\n"        unless  line[0] == "\"" or line[0] == "#"          tokens = line.replace(/\s+$/, "").split /\s+/          switch tokens[0] diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee index 2c2e9542..12f4496a 100644 --- a/tests/unit_tests/commands_test.coffee +++ b/tests/unit_tests/commands_test.coffee @@ -1,5 +1,6 @@  require "./test_helper.js"  extend global, require "./test_chrome_stubs.js" +extend global, require "../../background_scripts/bg_utils.js"  global.Settings = {postUpdateHooks: {}, get: (-> ""), set: ->}  {Commands} = require "../../background_scripts/commands.js" | 
