From 0e04fff0ea80fa5cbe96b8354db38bd334aea83a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 16 Jul 2012 16:04:05 -0700 Subject: upgrade to codemirror 2.3 Signed-off-by: Ananya Sen Conflicts: js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css Signed-off-by: Ananya Sen --- imports/codemirror/mode/python/python.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'imports/codemirror/mode/python') diff --git a/imports/codemirror/mode/python/python.js b/imports/codemirror/mode/python/python.js index cfe8a774..d6888e8e 100644 --- a/imports/codemirror/mode/python/python.js +++ b/imports/codemirror/mode/python/python.js @@ -249,32 +249,30 @@ CodeMirror.defineMode("python", function(conf, parserConf) { // Handle '.' connected identifiers if (current === '.') { - style = state.tokenize(stream, state); - current = stream.current(); - if (style === 'variable' || style === 'builtin') { - return 'variable'; - } else { - return ERRORCLASS; + style = stream.match(identifiers, false) ? null : ERRORCLASS; + if (style === null && state.lastToken === 'meta') { + // Apply 'meta' style to '.' connected identifiers when + // appropriate. + style = 'meta'; } + return style; } // Handle decorators if (current === '@') { - style = state.tokenize(stream, state); - current = stream.current(); - if (style === 'variable' - || current === '@staticmethod' - || current === '@classmethod') { - return 'meta'; - } else { - return ERRORCLASS; - } + return stream.match(identifiers, false) ? 'meta' : ERRORCLASS; + } + + if ((style === 'variable' || style === 'builtin') + && state.lastToken === 'meta') { + style = 'meta'; } // Handle scope changes. if (current === 'pass' || current === 'return') { state.dedent += 1; } + if (current === 'lambda') state.lambda = true; if ((current === ':' && !state.lambda && state.scopes[0].type == 'py') || indentInfo === 'indent') { indent(stream, state); @@ -316,7 +314,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) { token: function(stream, state) { var style = tokenLexer(stream, state); - state.lastToken = {style:style, content: stream.current()}; + state.lastToken = style; if (stream.eol() && stream.lambda) { state.lambda = false; -- cgit v1.2.3