codemirror
Advanced tools
Comparing version 3.15.0 to 3.16.0
@@ -7,3 +7,3 @@ CodeMirror.registerHelper("fold", "brace", function(cm, start) { | ||
for (var at = start.ch, pass = 0;;) { | ||
var found = lineText.lastIndexOf(openCh, at - 1); | ||
var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1); | ||
if (found == -1) { | ||
@@ -16,3 +16,3 @@ if (pass == 1) break; | ||
if (pass == 1 && found < start.ch) break; | ||
tokenType = cm.getTokenAt(CodeMirror.Pos(line, found + 1)).type; | ||
tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)); | ||
if (!/^(comment|string)/.test(tokenType)) return found + 1; | ||
@@ -39,3 +39,3 @@ at = found - 1; | ||
if (pos == text.length) break; | ||
if (cm.getTokenAt(CodeMirror.Pos(i, pos + 1)).type == tokenType) { | ||
if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) { | ||
if (pos == nextOpen) ++count; | ||
@@ -42,0 +42,0 @@ else if (!--count) { end = i; endCh = pos; break outer; } |
@@ -70,11 +70,7 @@ (function() { | ||
completion.cm.off("cursorActivity", activity); | ||
CodeMirror.signal(data, "close"); | ||
if (data) CodeMirror.signal(data, "close"); | ||
} | ||
function isDone() { | ||
if (finished) return true; | ||
if (!completion.widget) { done(); return true; } | ||
} | ||
function update() { | ||
if (isDone()) return; | ||
if (finished) return; | ||
CodeMirror.signal(data, "update"); | ||
@@ -88,5 +84,4 @@ if (completion.options.async) | ||
data = data_; | ||
if (isDone()) return; | ||
if (finished) return; | ||
if (!data || !data.list.length) return done(); | ||
completion.widget.close(); | ||
completion.widget = new Widget(completion, data); | ||
@@ -100,6 +95,8 @@ } | ||
pos.ch < startPos.ch || completion.cm.somethingSelected() || | ||
(pos.ch && closeOn.test(line.charAt(pos.ch - 1)))) | ||
(pos.ch && closeOn.test(line.charAt(pos.ch - 1)))) { | ||
completion.close(); | ||
else | ||
} else { | ||
debounce = setTimeout(update, 170); | ||
if (completion.widget) completion.widget.close(); | ||
} | ||
} | ||
@@ -106,0 +103,0 @@ this.cm.on("cursorActivity", activity); |
@@ -18,2 +18,3 @@ // Highlighting text that matches the selection | ||
var DEFAULT_TOKEN_STYLE = "matchhighlight"; | ||
var DEFAULT_DELAY = 100; | ||
@@ -25,5 +26,7 @@ function State(options) { | ||
this.showToken = options.showToken; | ||
this.delay = options.delay; | ||
} | ||
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE; | ||
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS; | ||
if (this.delay == null) this.delay = DEFAULT_DELAY; | ||
this.overlay = this.timeout = null; | ||
@@ -50,3 +53,3 @@ } | ||
clearTimeout(state.timeout); | ||
state.timeout = setTimeout(function() {highlightMatches(cm);}, 100); | ||
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay); | ||
} | ||
@@ -53,0 +56,0 @@ |
{ | ||
"name": "CodeMirror", | ||
"version": "3.15.0", | ||
"version": "3.16.0", | ||
"main": ["lib/codemirror.js", "lib/codemirror.css"], | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -369,4 +369,4 @@ CodeMirror.defineMode("css", function(config) { | ||
"flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", | ||
"float", "float-offset", "font", "font-feature-settings", "font-family", | ||
"font-kerning", "font-language-override", "font-size", "font-size-adjust", | ||
"float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings", | ||
"font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust", | ||
"font-stretch", "font-style", "font-synthesis", "font-variant", | ||
@@ -395,6 +395,8 @@ "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", | ||
"perspective-origin", "pitch", "pitch-range", "play-during", "position", | ||
"presentation-level", "punctuation-trim", "quotes", "rendering-intent", | ||
"resize", "rest", "rest-after", "rest-before", "richness", "right", | ||
"rotation", "rotation-point", "ruby-align", "ruby-overhang", | ||
"ruby-position", "ruby-span", "size", "speak", "speak-as", "speak-header", | ||
"presentation-level", "punctuation-trim", "quotes", "region-break-after", | ||
"region-break-before", "region-break-inside", "region-fragment", | ||
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness", | ||
"right", "rotation", "rotation-point", "ruby-align", "ruby-overhang", | ||
"ruby-position", "ruby-span", "shape-inside", "shape-outside", "size", | ||
"speak", "speak-as", "speak-header", | ||
"speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", | ||
@@ -437,3 +439,3 @@ "tab-size", "table-layout", "target", "target-name", "target-new", | ||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", | ||
"gold", "goldenrod", "gray", "green", "greenyellow", "honeydew", | ||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", | ||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", | ||
@@ -461,6 +463,6 @@ "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", | ||
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace", | ||
"arabic-indic", "armenian", "asterisks", "auto", "avoid", "background", | ||
"backwards", "baseline", "below", "bidi-override", "binary", "bengali", | ||
"blink", "block", "block-axis", "bold", "bolder", "border", "border-box", | ||
"both", "bottom", "break-all", "break-word", "button", "button-bevel", | ||
"arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page", | ||
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary", | ||
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box", | ||
"both", "bottom", "break", "break-all", "break-word", "button", "button-bevel", | ||
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian", | ||
@@ -470,3 +472,3 @@ "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", | ||
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", | ||
"col-resize", "collapse", "compact", "condensed", "contain", "content", | ||
"col-resize", "collapse", "column", "compact", "condensed", "contain", "content", | ||
"content-box", "context-menu", "continuous", "copy", "cover", "crop", | ||
@@ -478,3 +480,3 @@ "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal", | ||
"double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out", | ||
"element", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", | ||
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", | ||
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er", | ||
@@ -495,3 +497,3 @@ "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er", | ||
"inline-block", "inline-table", "inset", "inside", "intrinsic", "invert", | ||
"italic", "justify", "kannada", "katakana", "katakana-iroha", "khmer", | ||
"italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer", | ||
"landscape", "lao", "large", "larger", "left", "level", "lighter", | ||
@@ -515,7 +517,7 @@ "line-through", "linear", "lines", "list-item", "listbox", "listitem", | ||
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", | ||
"outside", "overlay", "overline", "padding", "padding-box", "painted", | ||
"paused", "persian", "plus-darker", "plus-lighter", "pointer", "portrait", | ||
"pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", | ||
"radio", "read-only", "read-write", "read-write-plaintext-only", "relative", | ||
"repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba", | ||
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box", | ||
"painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer", | ||
"polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", | ||
"radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", | ||
"relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba", | ||
"ridge", "right", "round", "row-resize", "rtl", "run-in", "running", | ||
@@ -522,0 +524,0 @@ "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield", |
@@ -14,14 +14,6 @@ // block; "begin", "case", "fun", "if", "receive", "try": closed by "end" | ||
function rval(state,stream,type) { | ||
function rval(state,_stream,type) { | ||
// distinguish between "." as terminator and record field operator | ||
if (type == "record") { | ||
state.context = "record"; | ||
}else{ | ||
state.context = false; | ||
} | ||
state.in_record = (type == "record"); | ||
// remember last significant bit on last line for indenting | ||
if (type != "whitespace" && type != "comment") { | ||
state.lastToken = stream.current(); | ||
} | ||
// erlang -> CodeMirror tag | ||
@@ -31,2 +23,3 @@ switch (type) { | ||
case "attribute": return "attribute"; | ||
case "boolean": return "special"; | ||
case "builtin": return "builtin"; | ||
@@ -60,2 +53,3 @@ case "comment": return "comment"; | ||
var separatorRE = /[\->\.,:;]/; | ||
var separatorWords = [ | ||
@@ -68,8 +62,11 @@ "->",";",":",".",","]; | ||
var symbolRE = /[\+\-\*\/<>=\|:!]/; | ||
var symbolWords = [ | ||
"+","-","*","/",">",">=","<","=<","=:=","==","=/=","/=","||","<-"]; | ||
"+","-","*","/",">",">=","<","=<","=:=","==","=/=","/=","||","<-","!"]; | ||
var openParenRE = /[<\(\[\{]/; | ||
var openParenWords = [ | ||
"<<","(","[","{"]; | ||
var closeParenRE = /[>\)\]\}]/; | ||
var closeParenWords = [ | ||
@@ -109,33 +106,23 @@ "}","]",")",">>"]; | ||
// ignored for indenting purposes | ||
var ignoreWords = [ | ||
",", ":", "catch", "after", "of", "cond", "let", "query"]; | ||
// [Ø-Þ] [À-Ö] | ||
// [ß-ö] [ø-ÿ] | ||
var anumRE = /[\w@Ø-ÞÀ-Öß-öø-ÿ]/; | ||
var escapesRE = | ||
/[0-7]{1,3}|[bdefnrstv\\"']|\^[a-zA-Z]|x[0-9a-zA-Z]{2}|x{[0-9a-zA-Z]+}/; | ||
function tokenize(stream, state) { | ||
var smallRE = /[a-z_]/; | ||
var largeRE = /[A-Z_]/; | ||
var digitRE = /[0-9]/; | ||
var octitRE = /[0-7]/; | ||
var anumRE = /[a-z_A-Z0-9]/; | ||
var symbolRE = /[\+\-\*\/<>=\|:]/; | ||
var openParenRE = /[<\(\[\{]/; | ||
var closeParenRE = /[>\)\]\}]/; | ||
var sepRE = /[\->\.,:;]/; | ||
// in multi-line string | ||
if (state.in_string) { | ||
state.in_string = (!doubleQuote(stream)); | ||
return rval(state,stream,"string"); | ||
} | ||
function isMember(element,list) { | ||
return (-1 < list.indexOf(element)); | ||
} | ||
function isPrev(stream,string) { | ||
var start = stream.start; | ||
var len = string.length; | ||
if (len <= start) { | ||
var word = stream.string.slice(start-len,start); | ||
return word == string; | ||
}else{ | ||
return false; | ||
// in multi-line atom | ||
if (state.in_atom) { | ||
state.in_atom = (!singleQuote(stream)); | ||
return rval(state,stream,"atom"); | ||
} | ||
} | ||
function tokenize(stream, state) { | ||
// whitespace | ||
if (stream.eatSpace()) { | ||
@@ -146,13 +133,9 @@ return rval(state,stream,"whitespace"); | ||
// attributes and type specs | ||
if ((peekToken(state).token == "" || peekToken(state).token == ".") && | ||
stream.peek() == '-') { | ||
stream.next(); | ||
if (stream.eat(smallRE) && stream.eatWhile(anumRE)) { | ||
if (isMember(stream.current(),typeWords)) { | ||
return rval(state,stream,"type"); | ||
}else{ | ||
return rval(state,stream,"attribute"); | ||
} | ||
if ((peekToken(state).token == "") && | ||
stream.match(/-\s*[a-zß-öø-ÿ][\wØ-ÞÀ-Öß-öø-ÿ]*/)) { | ||
if (isMember(stream.current(),typeWords)) { | ||
return rval(state,stream,"type"); | ||
}else{ | ||
return rval(state,stream,"attribute"); | ||
} | ||
stream.backUp(1); | ||
} | ||
@@ -175,3 +158,3 @@ | ||
// record | ||
if ( ch == "#") { | ||
if (ch == "#") { | ||
stream.eatWhile(anumRE); | ||
@@ -181,10 +164,8 @@ return rval(state,stream,"record"); | ||
// char | ||
if ( ch == "$") { | ||
if (stream.next() == "\\") { | ||
if (!stream.eatWhile(octitRE)) { | ||
stream.next(); | ||
} | ||
// dollar escape | ||
if ( ch == "$" ) { | ||
if (stream.next() == "\\" && !stream.match(escapesRE)) { | ||
return rval(state,stream,"error"); | ||
} | ||
return rval(state,stream,"string"); | ||
return rval(state,stream,"number"); | ||
} | ||
@@ -194,7 +175,13 @@ | ||
if (ch == '\'') { | ||
if (singleQuote(stream)) { | ||
return rval(state,stream,"atom"); | ||
}else{ | ||
return rval(state,stream,"error"); | ||
if (!(state.in_atom = (!singleQuote(stream)))) { | ||
if (stream.match(/\s*\/\s*[0-9]/,false)) { | ||
stream.match(/\s*\/\s*[0-9]/,true); | ||
popToken(state); | ||
return rval(state,stream,"fun"); // 'f'/0 style fun | ||
} | ||
if (stream.match(/\s*\(/,false) || stream.match(/\s*:/,false)) { | ||
return rval(state,stream,"function"); | ||
} | ||
} | ||
return rval(state,stream,"atom"); | ||
} | ||
@@ -204,11 +191,8 @@ | ||
if (ch == '"') { | ||
if (doubleQuote(stream)) { | ||
return rval(state,stream,"string"); | ||
}else{ | ||
return rval(state,stream,"error"); | ||
} | ||
state.in_string = (!doubleQuote(stream)); | ||
return rval(state,stream,"string"); | ||
} | ||
// variable | ||
if (largeRE.test(ch)) { | ||
if (/[A-Z_Ø-ÞÀ-Ö]/.test(ch)) { | ||
stream.eatWhile(anumRE); | ||
@@ -219,13 +203,9 @@ return rval(state,stream,"variable"); | ||
// atom/keyword/BIF/function | ||
if (smallRE.test(ch)) { | ||
if (/[a-z_ß-öø-ÿ]/.test(ch)) { | ||
stream.eatWhile(anumRE); | ||
if (stream.peek() == "/") { | ||
stream.next(); | ||
if (stream.eatWhile(digitRE)) { | ||
return rval(state,stream,"fun"); // f/0 style fun | ||
}else{ | ||
stream.backUp(1); | ||
return rval(state,stream,"atom"); | ||
} | ||
if (stream.match(/\s*\/\s*[0-9]/,false)) { | ||
stream.match(/\s*\/\s*[0-9]/,true); | ||
popToken(state); | ||
return rval(state,stream,"fun"); // f/0 style fun | ||
} | ||
@@ -238,4 +218,3 @@ | ||
return rval(state,stream,"keyword"); | ||
} | ||
if (stream.peek() == "(") { | ||
}else if (stream.match(/\s*\(/,false)) { | ||
// 'put' and 'erlang:put' are bifs, 'foo:put' is not | ||
@@ -245,13 +224,10 @@ if (isMember(w,bifWords) && | ||
return rval(state,stream,"builtin"); | ||
}else if (isMember(w,guardWords)) { | ||
return rval(state,stream,"guard"); | ||
}else{ | ||
return rval(state,stream,"function"); | ||
} | ||
} | ||
if (isMember(w,guardWords)) { | ||
return rval(state,stream,"guard"); | ||
} | ||
if (isMember(w,operatorWords)) { | ||
}else if (isMember(w,operatorWords)) { | ||
return rval(state,stream,"operator"); | ||
} | ||
if (stream.peek() == ":") { | ||
}else if (stream.match(/\s*:/,false)) { | ||
if (w == "erlang") { | ||
@@ -262,11 +238,16 @@ return rval(state,stream,"builtin"); | ||
} | ||
}else if (isMember(w,["true","false"])) { | ||
return rval(state,stream,"boolean"); | ||
}else{ | ||
return rval(state,stream,"atom"); | ||
} | ||
return rval(state,stream,"atom"); | ||
} | ||
// number | ||
var digitRE = /[0-9]/; | ||
var radixRE = /[0-9a-zA-Z]/; // 36#zZ style int | ||
if (digitRE.test(ch)) { | ||
stream.eatWhile(digitRE); | ||
if (stream.eat('#')) { | ||
stream.eatWhile(digitRE); // 16#10 style integer | ||
stream.eatWhile(radixRE); // 36#aZ style integer | ||
} else { | ||
@@ -297,5 +278,5 @@ if (stream.eat('.')) { // float | ||
// separators | ||
if (greedy(stream,sepRE,separatorWords)) { | ||
if (greedy(stream,separatorRE,separatorWords)) { | ||
// distinguish between "." as terminator and record field operator | ||
if (state.context == false) { | ||
if (!state.in_record) { | ||
pushToken(state,stream); | ||
@@ -314,2 +295,13 @@ } | ||
function isPrev(stream,string) { | ||
var start = stream.start; | ||
var len = string.length; | ||
if (len <= start) { | ||
var word = stream.string.slice(start-len,start); | ||
return word == string; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
function nongreedy(stream,re,words) { | ||
@@ -366,27 +358,33 @@ if (stream.current().length == 1 && re.test(stream.current())) { | ||
function Token(stream) { | ||
this.token = stream ? stream.current() : ""; | ||
this.column = stream ? stream.column() : 0; | ||
this.indent = stream ? stream.indentation() : 0; | ||
function isMember(element,list) { | ||
return (-1 < list.indexOf(element)); | ||
} | ||
///////////////////////////////////////////////////////////////////////////// | ||
function myIndent(state,textAfter) { | ||
var indent = cmCfg.indentUnit; | ||
var outdentWords = ["after","catch"]; | ||
var token = (peekToken(state)).token; | ||
var wordAfter = takewhile(textAfter,/[^a-z]/); | ||
if (isMember(token,openParenWords)) { | ||
if (state.in_string || state.in_atom) { | ||
return CodeMirror.Pass; | ||
}else if (token == "") { | ||
return 0; | ||
}else if (isMember(token,openParenWords)) { | ||
return (peekToken(state)).column+token.length; | ||
}else if (token == "." || token == ""){ | ||
return 0; | ||
}else if (token == "when") { | ||
return (peekToken(state)).column+token.length+1; | ||
}else if (token == "fun" && wordAfter == "") { | ||
return (peekToken(state)).column+token.length; | ||
}else if (token == "->") { | ||
if (wordAfter == "end") { | ||
if (isMember(wordAfter,["end","after","catch"])) { | ||
return peekToken(state,2).column; | ||
}else if (peekToken(state,2).token == "fun") { | ||
return peekToken(state,2).column+indent; | ||
}else if (peekToken(state,2).token == "") { | ||
return indent; | ||
}else{ | ||
return (peekToken(state)).indent+indent; | ||
} | ||
}else if (isMember(wordAfter,outdentWords)) { | ||
}else if (isMember(wordAfter,["after","catch","of"])) { | ||
return (peekToken(state)).indent; | ||
@@ -403,2 +401,8 @@ }else{ | ||
function Token(stream) { | ||
this.token = stream ? stream.current() : ""; | ||
this.column = stream ? stream.column() : 0; | ||
this.indent = stream ? stream.indentation() : 0; | ||
} | ||
function popToken(state) { | ||
@@ -421,4 +425,10 @@ return state.tokenStack.pop(); | ||
var prev_token = peekToken(state).token; | ||
if (isMember(token,ignoreWords)) { | ||
if (token == ".") { | ||
state.tokenStack = []; | ||
return false; | ||
}else if(isMember(token,[",", ":", "of", "cond", "let", "query"])) { | ||
return false; | ||
}else if (drop_last(prev_token,token)) { | ||
return false; | ||
}else if (drop_both(prev_token,token)) { | ||
@@ -430,2 +440,4 @@ popToken(state); | ||
return pushToken(state,stream); | ||
}else if (isMember(token,["after","catch"])) { | ||
return false; | ||
}else{ | ||
@@ -437,2 +449,9 @@ state.tokenStack.push(new Token(stream)); | ||
function drop_last(open, close) { | ||
switch(open+" "+close) { | ||
case "when ;": return true; | ||
default: return false; | ||
} | ||
} | ||
function drop_first(open, close) { | ||
@@ -442,4 +461,2 @@ switch (open+" "+close) { | ||
case "-> end": return true; | ||
case "-> .": return true; | ||
case ". .": return true; | ||
default: return false; | ||
@@ -461,2 +478,4 @@ } | ||
case "try end": return true; | ||
case "-> catch": return true; | ||
case "-> after": return true; | ||
case "-> ;": return true; | ||
@@ -471,4 +490,5 @@ default: return false; | ||
return {tokenStack: [], | ||
context: false, | ||
lastToken: null}; | ||
in_record: false, | ||
in_string: false, | ||
in_atom: false}; | ||
}, | ||
@@ -475,0 +495,0 @@ |
@@ -81,3 +81,2 @@ // TODO actually recognize syntax of TypeScript constructs | ||
} | ||
function jsTokenBase(stream, state) { | ||
@@ -87,2 +86,4 @@ var ch = stream.next(); | ||
return chain(stream, state, jsTokenString(ch)); | ||
else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) | ||
return ret("number", "number"); | ||
else if (/[\[\]{}\(\),;\:\.]/.test(ch)) | ||
@@ -94,3 +95,3 @@ return ret(ch); | ||
} | ||
else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) { | ||
else if (/\d/.test(ch)) { | ||
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); | ||
@@ -97,0 +98,0 @@ return ret("number", "number"); |
@@ -49,3 +49,3 @@ CodeMirror.modeInfo = [ | ||
{name: 'Plain Text', mime: 'text/plain', mode: 'null'}, | ||
{name: 'Properties files', mime: 'text/x-properties', mode: 'clike'}, | ||
{name: 'Properties files', mime: 'text/x-properties', mode: 'properties'}, | ||
{name: 'Python', mime: 'text/x-python', mode: 'python'}, | ||
@@ -52,0 +52,0 @@ {name: 'Cython', mime: 'text/x-cython', mode: 'python'}, |
@@ -154,2 +154,5 @@ CodeMirror.defineMode("python", function(conf, parserConf) { | ||
if (stream.match(identifiers)) { | ||
if (state.lastToken == 'def' || state.lastToken == 'class') { | ||
return 'def'; | ||
} | ||
return 'variable'; | ||
@@ -262,3 +265,3 @@ } | ||
style = stream.match(identifiers, false) ? null : ERRORCLASS; | ||
if (style === null && state.lastToken === 'meta') { | ||
if (style === null && state.lastStyle === 'meta') { | ||
// Apply 'meta' style to '.' connected identifiers when | ||
@@ -277,3 +280,3 @@ // appropriate. | ||
if ((style === 'variable' || style === 'builtin') | ||
&& state.lastToken === 'meta') { | ||
&& state.lastStyle === 'meta') { | ||
style = 'meta'; | ||
@@ -319,2 +322,3 @@ } | ||
scopes: [{offset:basecolumn || 0, type:'py'}], | ||
lastStyle: null, | ||
lastToken: null, | ||
@@ -329,8 +333,12 @@ lambda: false, | ||
state.lastToken = style; | ||
state.lastStyle = style; | ||
var current = stream.current(); | ||
if (current && style) { | ||
state.lastToken = current; | ||
} | ||
if (stream.eol() && state.lambda) { | ||
state.lambda = false; | ||
} | ||
return style; | ||
@@ -337,0 +345,0 @@ }, |
@@ -127,5 +127,3 @@ CodeMirror.defineMode('rst-base', function (config) { | ||
if (stream.current().match(/^(?:math|latex)/)) { | ||
state.tmp = { | ||
mode: mode_stex, local: mode_stex.startState() | ||
}; | ||
state.tmp_stex = true; | ||
} | ||
@@ -139,2 +137,8 @@ break; | ||
case 3: | ||
if (state.tmp_stex) { | ||
state.tmp_stex = undefined; state.tmp = { | ||
mode: mode_stex, local: mode_stex.startState() | ||
}; | ||
} | ||
if (state.tmp) { | ||
@@ -350,20 +354,20 @@ if (stream.peek() == '`') { | ||
token = 'meta'; | ||
break; | ||
default: | ||
if (stream.match(/^latex\s*$/) || state.tmp_stex) { | ||
state.tmp_stex = undefined; | ||
change(state, to_mode, { | ||
state.tmp_stex = undefined; change(state, to_mode, { | ||
mode: mode_stex, local: mode_stex.startState() | ||
}); | ||
} else if (stream.match(/^python\s*$/) || state.tmp_py) { | ||
state.tmp_py = undefined; | ||
change(state, to_mode, { | ||
} | ||
break; | ||
case 2: | ||
change(state, to_explicit, context(rx_directive, 3)); | ||
if (stream.match(/^python\s*$/) || state.tmp_py) { | ||
state.tmp_py = undefined; change(state, to_mode, { | ||
mode: mode_python, local: mode_python.startState() | ||
}); | ||
} | ||
else { | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
break; | ||
default: | ||
change(state, to_normal); | ||
assert(stream.current() == ''); | ||
} | ||
@@ -443,8 +447,3 @@ } else if (phase(state) == rx_link || stream.match(rx_link, false)) { | ||
try { | ||
return state.ctx.mode.token(stream, state.ctx.local); | ||
} catch (ex) { | ||
change(state, to_normal); | ||
return null; | ||
} | ||
return state.ctx.mode.token(stream, state.ctx.local); | ||
} | ||
@@ -451,0 +450,0 @@ |
@@ -12,3 +12,3 @@ CodeMirror.defineMode("velocity", function() { | ||
"#{if} #{elseif} #{foreach} #{set} #{include} #{parse} #{macro} #{define} #{evaluate}"); | ||
var specials = parseWords("$foreach.count $foreach.hasNext $foreach.first $foreach.last $foreach.topmost $foreach.parent $velocityCount"); | ||
var specials = parseWords("$foreach.count $foreach.hasNext $foreach.first $foreach.last $foreach.topmost $foreach.parent.count $foreach.parent.hasNext $foreach.parent.first $foreach.parent.last $foreach.parent $velocityCount $!bodyContent $bodyContent"); | ||
var isOperatorChar = /[+\-*&%=<>!?:\/|]/; | ||
@@ -24,9 +24,25 @@ | ||
var ch = stream.next(); | ||
// start of string? | ||
if ((ch == '"' || ch == "'") && state.inParams) | ||
// start of unparsed string? | ||
if ((ch == "'") && state.inParams) { | ||
state.lastTokenWasBuiltin = false; | ||
return chain(stream, state, tokenString(ch)); | ||
} | ||
// start of parsed string? | ||
else if ((ch == '"')) { | ||
state.lastTokenWasBuiltin = false; | ||
if (state.inString) { | ||
state.inString = false; | ||
return "string"; | ||
} | ||
else if (state.inParams) | ||
return chain(stream, state, tokenString(ch)); | ||
} | ||
// is it one of the special signs []{}().,;? Seperator? | ||
else if (/[\[\]{}\(\),;\.]/.test(ch)) { | ||
if (ch == "(" && beforeParams) state.inParams = true; | ||
else if (ch == ")") state.inParams = false; | ||
if (ch == "(" && beforeParams) | ||
state.inParams = true; | ||
else if (ch == ")") { | ||
state.inParams = false; | ||
state.lastTokenWasBuiltin = true; | ||
} | ||
return null; | ||
@@ -36,2 +52,3 @@ } | ||
else if (/\d/.test(ch)) { | ||
state.lastTokenWasBuiltin = false; | ||
stream.eatWhile(/[\w\.]/); | ||
@@ -42,2 +59,3 @@ return "number"; | ||
else if (ch == "#" && stream.eat("*")) { | ||
state.lastTokenWasBuiltin = false; | ||
return chain(stream, state, tokenComment); | ||
@@ -47,2 +65,3 @@ } | ||
else if (ch == "#" && stream.match(/ *\[ *\[/)) { | ||
state.lastTokenWasBuiltin = false; | ||
return chain(stream, state, tokenUnparsed); | ||
@@ -52,2 +71,3 @@ } | ||
else if (ch == "#" && stream.eat("#")) { | ||
state.lastTokenWasBuiltin = false; | ||
stream.skipToEnd(); | ||
@@ -60,6 +80,7 @@ return "comment"; | ||
// is it one of the specials? | ||
if (specials && specials.propertyIsEnumerable(stream.current().toLowerCase())) { | ||
if (specials && specials.propertyIsEnumerable(stream.current())) { | ||
return "keyword"; | ||
} | ||
else { | ||
state.lastTokenWasBuiltin = true; | ||
state.beforeParams = true; | ||
@@ -71,2 +92,3 @@ return "builtin"; | ||
else if (isOperatorChar.test(ch)) { | ||
state.lastTokenWasBuiltin = false; | ||
stream.eatWhile(isOperatorChar); | ||
@@ -77,4 +99,4 @@ return "operator"; | ||
// get the whole word | ||
stream.eatWhile(/[\w\$_{}]/); | ||
var word = stream.current().toLowerCase(); | ||
stream.eatWhile(/[\w\$_{}@]/); | ||
var word = stream.current(); | ||
// is it one of the listed keywords? | ||
@@ -85,7 +107,16 @@ if (keywords && keywords.propertyIsEnumerable(word)) | ||
if (functions && functions.propertyIsEnumerable(word) || | ||
stream.current().match(/^#[a-z0-9_]+ *$/i) && stream.peek()=="(") { | ||
(stream.current().match(/^#@?[a-z0-9_]+ *$/i) && stream.peek()=="(") && | ||
!(functions && functions.propertyIsEnumerable(word.toLowerCase()))) { | ||
state.beforeParams = true; | ||
state.lastTokenWasBuiltin = false; | ||
return "keyword"; | ||
} | ||
if (state.inString) { | ||
state.lastTokenWasBuiltin = false; | ||
return "string"; | ||
} | ||
if (stream.pos > word.length && stream.string.charAt(stream.pos-word.length-1)=="." && state.lastTokenWasBuiltin) | ||
return "builtin"; | ||
// default: just a "word" | ||
state.lastTokenWasBuiltin = false; | ||
return null; | ||
@@ -99,6 +130,11 @@ } | ||
while ((next = stream.next()) != null) { | ||
if (next == quote && !escaped) { | ||
if ((next == quote) && !escaped) { | ||
end = true; | ||
break; | ||
} | ||
if (quote=='"' && stream.peek() == '$' && !escaped) { | ||
state.inString = true; | ||
end = true; | ||
break; | ||
} | ||
escaped = !escaped && next == "\\"; | ||
@@ -144,3 +180,5 @@ } | ||
beforeParams: false, | ||
inParams: false | ||
inParams: false, | ||
inString: false, | ||
lastTokenWasBuiltin: false | ||
}; | ||
@@ -152,3 +190,7 @@ }, | ||
return state.tokenize(stream, state); | ||
} | ||
}, | ||
blockCommentStart: "#*", | ||
blockCommentEnd: "*#", | ||
lineComment: "##", | ||
fold: "velocity" | ||
}; | ||
@@ -155,0 +197,0 @@ }); |
@@ -264,3 +264,3 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { | ||
if (!Kludges.allowMissing) setStyle = "error"; | ||
else if (type == "word") setStyle = "attribute"; | ||
else if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);} | ||
return (type == "endTag" || type == "selfcloseTag") ? pass() : cont(); | ||
@@ -267,0 +267,0 @@ } |
@@ -445,3 +445,7 @@ /* | ||
return style; | ||
} | ||
}, | ||
blockCommentStart: "(:", | ||
blockCommentEnd: ":)" | ||
}; | ||
@@ -448,0 +452,0 @@ |
@@ -29,10 +29,2 @@ CodeMirror.defineMode("yaml", function() { | ||
} | ||
/* pairs (associative arrays) -> key */ | ||
if (!state.pair && stream.match(/^\s*([a-z0-9\._-])+(?=\s*:)/i)) { | ||
state.pair = true; | ||
state.keyCol = stream.indentation(); | ||
return "atom"; | ||
} | ||
if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; } | ||
/* inline pairs/lists */ | ||
@@ -78,2 +70,10 @@ if (stream.match(/^(\{|\}|\[|\])/)) { | ||
/* pairs (associative arrays) -> key */ | ||
if (!state.pair && stream.match(/^\s*\S+(?=\s*:($|\s))/i)) { | ||
state.pair = true; | ||
state.keyCol = stream.indentation(); | ||
return "atom"; | ||
} | ||
if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; } | ||
/* nothing found, continue */ | ||
@@ -80,0 +80,0 @@ state.pairStart = false; |
{ | ||
"name": "codemirror", | ||
"version":"3.15.0", | ||
"version":"3.16.0", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "description": "In-browser code editing made bearable", |
@@ -87,3 +87,3 @@ var tests = [], debug = null, debugUsed = new Array(), allNames = []; | ||
else { | ||
var pos = /\bat .*?([^\/:]+):(\d+):/.exec(e.stack); | ||
var pos = /(?:\bat |@).*?([^\/:]+):(\d+)/.exec(e.stack); | ||
callback("error", test.name, e.toString() + (pos ? " (" + pos[1] + ":" + pos[2] + ")" : "")); | ||
@@ -90,0 +90,0 @@ } |
@@ -520,2 +520,20 @@ var Pos = CodeMirror.Pos; | ||
testCM("multiBookmarkCursor", function(cm) { | ||
if (phantom) return; | ||
var ms = [], m; | ||
function add(insertLeft) { | ||
for (var i = 0; i < 3; ++i) { | ||
var node = document.createElement("span"); | ||
node.innerHTML = "X"; | ||
ms.push(cm.setBookmark(Pos(0, 1), {widget: node, insertLeft: insertLeft})); | ||
} | ||
} | ||
var base1 = cm.cursorCoords(Pos(0, 1)).left, base4 = cm.cursorCoords(Pos(0, 4)).left; | ||
add(true); | ||
eq(base1, cm.cursorCoords(Pos(0, 1)).left); | ||
while (m = ms.pop()) m.clear(); | ||
add(false); | ||
eq(base4, cm.cursorCoords(Pos(0, 1)).left); | ||
}, {value: "abcdefg"}); | ||
testCM("getAllMarks", function(cm) { | ||
@@ -856,2 +874,13 @@ addDoc(cm, 10, 10); | ||
testCM("changedBookmark", function(cm) { | ||
cm.setSize("10em"); | ||
var w = document.createElement("span"); | ||
w.innerHTML = "x"; | ||
var m = cm.setBookmark(Pos(0, 4), {widget: w}); | ||
w.innerHTML = "and now the widget is really really long all of a sudden and a scrollbar is needed"; | ||
m.changed(); | ||
var hScroll = byClassName(cm.getWrapperElement(), "CodeMirror-hscrollbar")[0]; | ||
is(hScroll.scrollWidth > hScroll.clientWidth); | ||
}, {value: "abcdefg"}); | ||
testCM("inlineWidget", function(cm) { | ||
@@ -858,0 +887,0 @@ var w = cm.setBookmark(Pos(0, 2), {widget: document.createTextNode("uu")}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
2325436
0
38547
314