Skip to content

Commit 69e8ee5

Browse files
committed
Force input polling before running key handlers
This makes it impossible for the handlers to see an outdated view of the content.
1 parent e09b2e8 commit 69e8ee5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/codemirror.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ var CodeMirror = (function() {
524524
function onKeyDown(e) {
525525
if (!focused) onFocus();
526526
if (ie && e.keyCode == 27) { e.returnValue = false; }
527+
if (pollingFast) { if (readInput()) pollingFast = false; }
527528
if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
528529
var code = e_prop(e, "keyCode");
529530
// IE does strange things with escape.
@@ -538,6 +539,7 @@ var CodeMirror = (function() {
538539
}
539540
}
540541
function onKeyPress(e) {
542+
if (pollingFast) readInput();
541543
if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
542544
var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode");
543545
if (window.opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}

mode/xml/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ <h1>CodeMirror: XML mode</h1>
2525
<script>
2626
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
2727
mode: {name: "xml", alignCDATA: true},
28-
lineNumbers: true,
29-
onChange: function() { editor.save(); }
28+
lineNumbers: true
3029
});
3130
</script>
3231
<p>The XML mode supports two configuration parameters:</p>

0 commit comments

Comments
 (0)