Skip to content

Commit

Permalink
Be more careful about registering keys as movement keys
Browse files Browse the repository at this point in the history
Closes #155
  • Loading branch information
marijnh committed Aug 2, 2011
1 parent afe77d2 commit 32e8565
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/codemirror.js
Expand Up @@ -350,14 +350,16 @@ var CodeMirror = (function() {
// its start when it is inverted and a movement key is pressed
// (and later restore it again), shouldn't be used for
// non-movement keys.
curKeyId = (mod ? "c" : "") + code;
if (sel.inverted && movementKeys.hasOwnProperty(curKeyId)) {
curKeyId = (mod ? "c" : "") + (e.altKey ? "a" : "") + code;
if (sel.inverted && movementKeys[curKeyId] === true) {
var range = selRange(input);
if (range) {
reducedSelection = {anchor: range.start};
setSelRange(input, range.start, range.start);
}
}
// Don't save the key as a movementkey unless it had a modifier
if (!mod && !e.altKey) curKeyId = null;
fastPoll(curKeyId);
}
function onKeyUp(e) {
Expand Down Expand Up @@ -569,7 +571,10 @@ var CodeMirror = (function() {
function p() {
startOperation();
var changed = readInput();
if (changed == "moved" && keyId) movementKeys[keyId] = true;
if (changed && keyId) {
if (changed == "moved" && movementKeys[keyId] == null) movementKeys[keyId] = true;
if (changed == "changed") movementKeys[keyId] = false;
}
if (!changed && !missed) {missed = true; poll.set(80, p);}
else {pollingFast = false; slowPoll();}
endOperation();
Expand Down

0 comments on commit 32e8565

Please sign in to comment.