Skip to content

Commit

Permalink
Fix bug in coordsChar
Browse files Browse the repository at this point in the history
Page-up would sometimes scroll all the way to the top even
though it shouldn't, because of a poorly chosen check in coordsChar.

The new check should no longer get false positives.
  • Loading branch information
marijnh committed Aug 10, 2012
1 parent 65651f9 commit 7ac5398
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/codemirror.js
Expand Up @@ -1707,8 +1707,8 @@ var CodeMirror = (function() {
}
// Coords must be lineSpace-local
function coordsChar(x, y) {
if (y < 0) return {line: 0, ch: 0};
var th = textHeight(), cw = charWidth(), heightPos = displayOffset + Math.floor(y / th);
if (heightPos < 0) return {line: 0, ch: 0};
var lineNo = lineAtHeight(doc, heightPos);
if (lineNo >= doc.size) return {line: doc.size - 1, ch: getLine(doc.size - 1).text.length};
var lineObj = getLine(lineNo), text = lineObj.text;
Expand Down

0 comments on commit 7ac5398

Please sign in to comment.