From bc2f5e0f52179e915ed7a439fc6bfa03525156ee Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 17 Oct 2016 08:02:20 +0100 Subject: Better line parsing. 1. Explicitly remove comments. 2. A trailing backslash means the current line continues on the next line. E.g. a \ b \ c is a single line `a b c`. This helps alleviate the fact that configuration lines can be very long, whereas the *Custom key mappings* input is quite narrow. TODO: We should use the same line parser in the custom-search-engines input. --- background_scripts/bg_utils.coffee | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'background_scripts/bg_utils.coffee') 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 -- cgit v1.2.3