Created
April 6, 2012 20:32
-
-
Save peterflynn/2322730 to your computer and use it in GitHub Desktop.
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> | |
<title>CodeMirror: Bug testcase - marijnh/CodeMirror2</title> | |
<link rel="stylesheet" href="../lib/codemirror.css"> | |
<script src="../lib/codemirror.js"></script> | |
<script src="../mode/css/css.js"></script> | |
<link rel="stylesheet" href="../doc/docs.css"> | |
<style type="text/css"> | |
.CodeMirror {border: 1px solid black;} | |
</style> | |
</head> | |
<body> | |
<h1>Bug testcase - marijnh/CodeMirror2</h1> | |
<form><textarea id="code" name="code"> | |
div { | |
margin: 0; | |
padding: 0; | |
} | |
.foo { | |
color: #f00; | |
} | |
#myDiv { | |
display: block; | |
}</textarea></form> | |
<p> | |
<button onclick='bug1()'>Test bug 1</button> | |
<button onclick='bug2()'>Test bug 2</button> | |
</p> | |
<script> | |
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | |
lineNumbers: true | |
}); | |
var textToInsert = "\n"; | |
// var textToInsert = "/* test comment */\n"; // bug repros with "meatier" lines of text, too | |
// Inserting on two different lines causes crash on undo() | |
function bug1() { | |
editor.operation(function () { | |
editor.replaceRange( | |
textToInsert, | |
{ line: 5, ch: 0 } | |
); | |
editor.replaceRange( | |
textToInsert, | |
{ line: 8, ch: 0 } | |
); | |
}); | |
editor.undo(); | |
} | |
// Inserting on same line causes text corruption on undo() | |
function bug2() { | |
editor.operation(function () { | |
editor.replaceRange( | |
textToInsert, | |
{ line: 5, ch: 0 } | |
); | |
editor.replaceRange( | |
textToInsert, | |
{ line: 5, ch: 0 } | |
); | |
}); | |
editor.undo(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment