Created
December 4, 2012 19:17
-
-
Save ibdknox/4207675 to your computer and use it in GitHub Desktop.
CodeMirror V3 refresh doesn't calculate max line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>CodeMirror: Active Line Demo</title> | |
<link rel="stylesheet" href="../lib/codemirror.css"> | |
<script src="../lib/codemirror.js"></script> | |
<script src="../mode/xml/xml.js"></script> | |
<link rel="stylesheet" href="../doc/docs.css"> | |
<style type="text/css"> | |
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} | |
.activeline {background: #e8f2ff !important;} | |
</style> | |
</head> | |
<body> | |
<h1>CodeMirror: Active Line Demo</h1> | |
<form id="blah"></form> | |
<script> | |
var editor = CodeMirror(function() {}, { | |
mode: "application/xml", | |
lineNumbers: true, | |
lineWrapping: false | |
}); | |
editor.setValue("asdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nasdf\nsomething really long aosidjf oasdijf oiasjd foiaj sdoifj aoisdj foiaj dsofij aosidfj oaij sdfoiaj dosifj aoidsj foiaj sdofij aosdijf oaidsj foiaj sdoaifjsd "); | |
editor.clearHistory(); | |
document.getElementById("blah").appendChild(editor.getWrapperElement()); | |
editor.refresh(); | |
var hlLine = editor.addLineClass(0, "background", "activeline"); | |
editor.on("cursorActivity", function() { | |
var cur = editor.getLineHandle(editor.getCursor().line); | |
if (cur != hlLine) { | |
editor.removeLineClass(hlLine, "background", "activeline"); | |
hlLine = editor.addLineClass(cur, "background", "activeline"); | |
} | |
}); | |
</script> | |
<p>Styling the current cursor line.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment