Changeset 3979:af2eb4115a98 for admin/js/codemirror/addon
- Timestamp:
- 06/24/19 13:04:56 (6 years ago)
- Branch:
- default
- Location:
- admin/js/codemirror/addon
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/codemirror/addon/display/fullscreen.js
r3253 r3979 1 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http ://codemirror.net/LICENSE2 // Distributed under an MIT license: https://codemirror.net/LICENSE 3 3 4 4 (function(mod) { -
admin/js/codemirror/addon/edit/closebrackets.js
r3758 r3979 1 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http ://codemirror.net/LICENSE2 // Distributed under an MIT license: https://codemirror.net/LICENSE 3 3 4 4 (function(mod) { … … 12 12 var defaults = { 13 13 pairs: "()[]{}''\"\"", 14 closeBefore: ")]}'\":;>", 14 15 triples: "", 15 16 explode: "[]{}" … … 110 111 var pos = pairs.indexOf(ch); 111 112 if (pos == -1) return CodeMirror.Pass; 113 114 var closeBefore = getOption(conf,"closeBefore"); 115 112 116 var triples = getOption(conf, "triples"); 113 117 … … 137 141 if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; 138 142 else return CodeMirror.Pass; 139 } else if (opening && (cm.getLine(cur.line).length == cur.ch || 140 isClosingBracket(next, pairs) || 141 /\s/.test(next))) { 143 } else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) { 142 144 curType = "both"; 143 145 } else { … … 176 178 } 177 179 178 function isClosingBracket(ch, pairs) {179 var pos = pairs.lastIndexOf(ch);180 return pos > -1 && pos % 2 == 1;181 }182 183 180 function charsAround(cm, pos) { 184 181 var str = cm.getRange(Pos(pos.line, pos.ch - 1), -
admin/js/codemirror/addon/edit/matchbrackets.js
r3758 r3979 1 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http ://codemirror.net/LICENSE2 // Distributed under an MIT license: https://codemirror.net/LICENSE 3 3 4 4 (function(mod) { … … 15 15 var Pos = CodeMirror.Pos; 16 16 17 var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"}; 17 var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"}; 18 19 function bracketRegex(config) { 20 return config && config.bracketRegex || /[(){}[\]]/ 21 } 18 22 19 23 function findMatchingBracket(cm, where, config) { … … 22 26 if (afterCursor == null) 23 27 afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className) 28 var re = bracketRegex(config) 24 29 25 30 // A cursor is defined as between two characters, but in in vim command mode … … 27 32 // highlighted box on top of the 2nd character. Otherwise, we allow matches 28 33 // from before or after the cursor. 29 var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||30 matching[line.text.charAt(++pos)];34 var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) || 35 re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)]; 31 36 if (!match) return null; 32 37 var dir = match.charAt(1) == ">" ? 1 : -1; … … 52 57 53 58 var stack = []; 54 var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;59 var re = bracketRegex(config) 55 60 var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) 56 61 : Math.max(cm.firstLine() - 1, where.line - maxScanLines); … … 65 70 if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { 66 71 var match = matching[ch]; 67 if ( (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);72 if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch); 68 73 else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; 69 74 else stack.pop(); -
admin/js/codemirror/addon/mode/multiplex.js
r3758 r3979 1 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http ://codemirror.net/LICENSE2 // Distributed under an MIT license: https://codemirror.net/LICENSE 3 3 4 4 (function(mod) { … … 55 55 var outerIndent = 0; 56 56 if (outer.indent) { 57 var possibleOuterIndent = outer.indent(state.outer, "" );57 var possibleOuterIndent = outer.indent(state.outer, "", ""); 58 58 if (possibleOuterIndent !== CodeMirror.Pass) outerIndent = possibleOuterIndent; 59 59 } … … 97 97 }, 98 98 99 indent: function(state, textAfter ) {99 indent: function(state, textAfter, line) { 100 100 var mode = state.innerActive ? state.innerActive.mode : outer; 101 101 if (!mode.indent) return CodeMirror.Pass; 102 return mode.indent(state.innerActive ? state.inner : state.outer, textAfter );102 return mode.indent(state.innerActive ? state.inner : state.outer, textAfter, line); 103 103 }, 104 104 … … 113 113 if (other.open === "\n") { 114 114 state.innerActive = other; 115 state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "" ) : 0);115 state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "", "") : 0); 116 116 } 117 117 }
Note: See TracChangeset
for help on using the changeset viewer.