Skip to content

Commit 4202a6e

Browse files
committed
fix problem where fast-polling was canceled by slow-polling
1 parent f8dcde9 commit 4202a6e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/codemirror.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,9 @@ var CodeMirror = (function() {
460460
return getRange(sel.from, sel.to);
461461
}
462462

463+
var pollingFast = false; // Ensures slowPoll doesn't cancel fastPoll
463464
function slowPoll() {
465+
if (pollingFast) return;
464466
poll.set(2000, function() {
465467
startOperation();
466468
readInput();
@@ -470,12 +472,13 @@ var CodeMirror = (function() {
470472
}
471473
function fastPoll(keyId) {
472474
var missed = false;
475+
pollingFast = true;
473476
function p() {
474477
startOperation();
475478
var changed = readInput();
476479
if (changed == "moved" && keyId) movementKeys[keyId] = true;
477480
if (!changed && !missed) {missed = true; poll.set(80, p);}
478-
else slowPoll();
481+
else {pollingFast = false; slowPoll();}
479482
endOperation();
480483
}
481484
poll.set(20, p);

0 commit comments

Comments
 (0)