Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2756 from adobe/rlim/key-handling-issue
Browse files Browse the repository at this point in the history
Simplify key handlings in code hint manager.
  • Loading branch information
redmunds committed Feb 8, 2013
2 parents 0bd49aa + b26d2c6 commit 546e9cd
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/editor/CodeHintManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,29 +453,18 @@ define(function (require, exports, module) {
} else if (_inSession(editor) && hintList.isOpen()) {
// Pass event to the hint list, if it's open
hintList.handleKeyEvent(event);
} else if (!(event.ctrlKey || event.altKey || event.metaKey) &&
(event.keyCode === KeyEvent.DOM_VK_ENTER ||
event.keyCode === KeyEvent.DOM_VK_RETURN ||
event.keyCode === KeyEvent.DOM_VK_TAB)) {
}
if (!(event.ctrlKey || event.altKey || event.metaKey) &&
(event.keyCode === KeyEvent.DOM_VK_ENTER ||
event.keyCode === KeyEvent.DOM_VK_RETURN ||
event.keyCode === KeyEvent.DOM_VK_TAB)) {
lastChar = String.fromCharCode(event.keyCode);
}
} else if (event.type === "keypress") {
// Last inserted character, used later by handleChange
lastChar = String.fromCharCode(event.charCode);
} else if (event.type === "keyup") {
if (_inSession(editor)) {
if ((event.keyCode !== 32 && event.ctrlKey) || event.altKey || event.metaKey) {
// End the session if the user presses any key with a modifier (other than Ctrl+Space).
_endSession();
} else if (event.keyCode === KeyEvent.DOM_VK_LEFT ||
event.keyCode === KeyEvent.DOM_VK_RIGHT ||
event.keyCode === KeyEvent.DOM_VK_BACK_SPACE) {
// Update the list after a simple navigation.
// We do this in "keyup" because we want the cursor position to be updated before
// we redraw the list.
_updateHintList();
}
}
} else if (event.type === "keyup" && _inSession(editor)) {
_updateHintList();
}
}

Expand Down

0 comments on commit 546e9cd

Please sign in to comment.