From 671d2b94996ac71d56b2d05d5fe694ed7d84fa59 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 4 Apr 2012 12:27:35 -0700 Subject: upgrading to CodeMirror 2.23, since it has an important fix to Not close Ninja, if backspace is pressed while autocomplete dropdown is open. Signed-off-by: Ananya Sen --- imports/codemirror/mode/properties/properties.js | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'imports/codemirror/mode/properties/properties.js') diff --git a/imports/codemirror/mode/properties/properties.js b/imports/codemirror/mode/properties/properties.js index 2529505b..d3a13c76 100755 --- a/imports/codemirror/mode/properties/properties.js +++ b/imports/codemirror/mode/properties/properties.js @@ -1,21 +1,23 @@ CodeMirror.defineMode("properties", function() { return { token: function(stream, state) { - var sol = stream.sol(); + var sol = stream.sol() || state.afterSection; var eol = stream.eol(); + state.afterSection = false; + if (sol) { if (state.nextMultiline) { state.inMultiline = true; state.nextMultiline = false; } else { - state.position = "key"; + state.position = "def"; } } if (eol && ! state.nextMultiline) { state.inMultiline = false; - state.position = "key"; + state.position = "def"; } if (sol) { @@ -24,16 +26,18 @@ CodeMirror.defineMode("properties", function() { var ch = stream.next(); - if (sol && (ch === "#" || ch === "!")) { + if (sol && (ch === "#" || ch === "!" || ch === ";")) { state.position = "comment"; stream.skipToEnd(); return "comment"; - + } else if (sol && ch === "[") { + state.afterSection = true; + stream.skipTo("]"); stream.eat("]"); + return "header"; } else if (ch === "=" || ch === ":") { - state.position = "value"; - return "equals"; - - } else if (ch === "\\" && state.position === "value") { + state.position = "quote"; + return null; + } else if (ch === "\\" && state.position === "quote") { if (stream.next() !== "u") { // u = Unicode sequence \u1234 // Multiline value state.nextMultiline = true; @@ -45,9 +49,10 @@ CodeMirror.defineMode("properties", function() { startState: function() { return { - position : "key", // Current position, "key", "value" or "comment" + position : "def", // Current position, "def", "quote" or "comment" nextMultiline : false, // Is the next line multiline value - inMultiline : false // Is the current line a multiline value + inMultiline : false, // Is the current line a multiline value + afterSection : false // Did we just open a section }; } @@ -55,3 +60,4 @@ CodeMirror.defineMode("properties", function() { }); CodeMirror.defineMIME("text/x-properties", "properties"); +CodeMirror.defineMIME("text/x-ini", "properties"); -- cgit v1.2.3