Skip to content

Instantly share code, notes, and snippets.

@njx
Created April 2, 2013 17:47
Show Gist options
  • Save njx/5294458 to your computer and use it in GitHub Desktop.
Save njx/5294458 to your computer and use it in GitHub Desktop.
Change in behavior of cursor positioning after replaceRange
<!doctype html>
<html>
<head>
<title>replaceRange Bug</title>
<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<link rel="stylesheet" href="doc/docs.css">
<style type="text/css">
.CodeMirror {border: 1px solid black;}
</style>
</head>
<body>
<h1>replaceRange Bug</h1>
<div id="editor"></div>
<script id="script">
window.onload = function() {
var editor = CodeMirror(document.getElementById("editor"), {
lineNumbers: true,
});
editor.focus();
editor.replaceRange("content", {line: 0, ch: 0});
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment