Merge pull request #3481 from matrix-org/bwindels/cider-ac-shifttab

Fix: don't block Shift+Tab in CIDER autocomplete
This commit is contained in:
Bruno Windels 2019-09-26 15:08:36 +00:00 committed by GitHub
commit 8301943cfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -346,25 +346,35 @@ export default class BasicMessageEditor extends React.Component {
this._insertText("\n");
handled = true;
// autocomplete or enter to send below shouldn't have any modifier keys pressed.
} else if (!(event.metaKey || event.altKey || event.shiftKey)) {
} else {
const metaOrAltPressed = event.metaKey || event.altKey;
const modifierPressed = metaOrAltPressed || event.shiftKey;
if (model.autoComplete && model.autoComplete.hasCompletions()) {
const autoComplete = model.autoComplete;
switch (event.key) {
case "ArrowUp":
autoComplete.onUpArrow(event);
handled = true;
if (!modifierPressed) {
autoComplete.onUpArrow(event);
handled = true;
}
break;
case "ArrowDown":
autoComplete.onDownArrow(event);
handled = true;
if (!modifierPressed) {
autoComplete.onDownArrow(event);
handled = true;
}
break;
case "Tab":
autoComplete.onTab(event);
handled = true;
if (!metaOrAltPressed) {
autoComplete.onTab(event);
handled = true;
}
break;
case "Escape":
autoComplete.onEscape(event);
handled = true;
if (!modifierPressed) {
autoComplete.onEscape(event);
handled = true;
}
break;
default:
return; // don't preventDefault on anything else