Skip to content

Instantly share code, notes, and snippets.

@njx
Last active December 13, 2015 19:38
Show Gist options
  • Save njx/4964012 to your computer and use it in GitHub Desktop.
Save njx/4964012 to your computer and use it in GitHub Desktop.
Linked doc undo bug
<!doctype html>
<html>
<head>
<title>Linked Doc Undo 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>Linked Doc Undo Bug</h1>
<div id="editor"></div>
<div id="subeditor"></div>
<script id="script">
window.onload = function() {
var content = "line 0\nline 1\nline 2\nline 3\nline 4";
var editor = CodeMirror(document.getElementById("editor"), {
lineNumbers: true,
value: content
});
var subdoc = editor.getDoc().linkedDoc({sharedHist: true, from: 1, to: 4});
subdoc.replaceRange("x", {line: 2, ch: 0}, {line: 2, 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