Skip to content

Commit

Permalink
[matchtags addon] cleanup b3a1ed4
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh authored and anaran committed Feb 22, 2014
1 parent 3e89cc6 commit 93a9e67
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions addon/edit/matchtags.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
clear(cm);
}
if (val) {
cm.state.matchBothTags = (val.bothTags);
cm.state.matchBothTags = typeof val == "object" && val.bothTags;
cm.on("cursorActivity", doMatchTags);
cm.on("viewportChange", maybeUpdateMatch);
doMatchTags(cm);
Expand All @@ -18,7 +18,7 @@
function clear(cm) {
if (cm.state.tagHit) cm.state.tagHit.clear();
if (cm.state.tagOther) cm.state.tagOther.clear();
cm.state.tagHit = null; cm.state.tagOther = null;
cm.state.tagHit = cm.state.tagOther = null;
}

function doMatchTags(cm) {
Expand All @@ -29,9 +29,9 @@
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;
if(cm.state.matchBothTags) {
if (cm.state.matchBothTags) {
var hit = match.at == "open" ? match.open : match.close;
if(hit)cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"});
if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"});
}
var other = match.at == "close" ? match.open : match.close;
if (other)
Expand Down

0 comments on commit 93a9e67

Please sign in to comment.