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"); this._insertText("\n");
handled = true; handled = true;
// autocomplete or enter to send below shouldn't have any modifier keys pressed. // 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()) { if (model.autoComplete && model.autoComplete.hasCompletions()) {
const autoComplete = model.autoComplete; const autoComplete = model.autoComplete;
switch (event.key) { switch (event.key) {
case "ArrowUp": case "ArrowUp":
autoComplete.onUpArrow(event); if (!modifierPressed) {
handled = true; autoComplete.onUpArrow(event);
handled = true;
}
break; break;
case "ArrowDown": case "ArrowDown":
autoComplete.onDownArrow(event); if (!modifierPressed) {
handled = true; autoComplete.onDownArrow(event);
handled = true;
}
break; break;
case "Tab": case "Tab":
autoComplete.onTab(event); if (!metaOrAltPressed) {
handled = true; autoComplete.onTab(event);
handled = true;
}
break; break;
case "Escape": case "Escape":
autoComplete.onEscape(event); if (!modifierPressed) {
handled = true; autoComplete.onEscape(event);
handled = true;
}
break; break;
default: default:
return; // don't preventDefault on anything else return; // don't preventDefault on anything else