Sha256: eb6b2a295ee662e7d720f1674322e2b50cd65fa5081f63d55f8259230a971dc4
Contents?: true
Size: 1.47 KB
Versions: 13
Compression:
Stored size: 1.47 KB
Contents
(function() { "use strict"; CodeMirror.defineOption("matchTags", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { cm.off("cursorActivity", doMatchTags); cm.off("viewportChange", maybeUpdateMatch); clear(cm); } if (val) { cm.on("cursorActivity", doMatchTags); cm.on("viewportChange", maybeUpdateMatch); doMatchTags(cm); } }); function clear(cm) { if (cm.state.matchedTag) { cm.state.matchedTag.clear(); cm.state.matchedTag = null; } } function doMatchTags(cm) { cm.state.failedTagMatch = false; cm.operation(function() { clear(cm); var cur = cm.getCursor(), range = cm.getViewport(); range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to); var match = CodeMirror.findMatchingTag(cm, cur, range); if (!match) return; var other = match.at == "close" ? match.open : match.close; if (other) cm.state.matchedTag = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"}); else cm.state.failedTagMatch = true; }); } function maybeUpdateMatch(cm) { if (cm.state.failedTagMatch) doMatchTags(cm); } CodeMirror.commands.toMatchingTag = function(cm) { var found = CodeMirror.findMatchingTag(cm, cm.getCursor()); if (found) { var other = found.at == "close" ? found.open : found.close; if (other) cm.setSelection(other.to, other.from); } }; })();
Version data entries
13 entries across 13 versions & 2 rubygems