Skip to content

Commit

Permalink
Fix TypeError: Cannot read property 'line' of undefined exception.
Browse files Browse the repository at this point in the history
Triggered on any change when line 0 contains a CM bookmark.

I wrote the lazy `found.line ?` without cosidering what if line == 0.
Very embarrasing.  I should be fired :-(

In Mathdown this caused cben/mathdown#85
because Firepad renders other users' cursors with a CM bookmark
=> editing the first line immediately broke other windows editing same line.

Bug originated in 475901c on 2014-10-21
  • Loading branch information
cben committed Apr 30, 2015
1 parent 03666ad commit efe3a4f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion render-math.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ CodeMirror.hookMath = function(editor, MathJax) {
// Verify it's in range, even after findMarks() - it returns
// marks that touch the range, we want at least one char overlap.
var found = mark.find();
if(found.line ?
if(found.line !== undefined ?
/* bookmark */ posInsideRange(found, {from: from, to: to}) :
/* marked range */ rangesOverlap(found, {from: from, to: to})) {
mark.clear();
Expand Down

0 comments on commit efe3a4f

Please sign in to comment.