зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1557632 - Don't check if input is compilable unit on Ctrl+Enter. r=Honza.
In the regular webconsole input, on Enter, we check that the input is a compilable unit, so the user don't accidentally execute an incomplete snippet. In the editor mode, the user will have to use Ctrl/Cmd + Enter to execute, so we don't have to worry about Enter (it will simply append a new line). And since the user might deal with a large number of characters, we don't want to prevent them to execute. If it's malformed, they will get an error in the output and can fix their input easily, since it wasn't cleared. The patch adds a test to ensure this work as expected. Differential Revision: https://phabricator.services.mozilla.com/D34522 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
af1495af8e
Коммит
8c902ec959
|
@ -196,14 +196,7 @@ class JSTerm extends Component {
|
|||
};
|
||||
|
||||
const onCtrlCmdEnter = () => {
|
||||
const hasSuggestion = this.hasAutocompletionSuggestion();
|
||||
if (!hasSuggestion &&
|
||||
!Debugger.isCompilableUnit(this.getInputValueBeforeCursor())) {
|
||||
// incomplete statement
|
||||
return "CodeMirror.Pass";
|
||||
}
|
||||
|
||||
if (hasSuggestion) {
|
||||
if (this.hasAutocompletionSuggestion()) {
|
||||
return this.acceptProposedCompletion();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,12 +53,20 @@ async function performEditorEnabledTests() {
|
|||
const {visibleMessages} = hud.ui.wrapper.getStore().getState().messages;
|
||||
is(visibleMessages.length, 0, "input expressions should not have been executed");
|
||||
|
||||
const onMessage = waitForMessage(hud, "11", ".result");
|
||||
let onMessage = waitForMessage(hud, "11", ".result");
|
||||
EventUtils.synthesizeKey("KEY_Enter", {
|
||||
[Services.appinfo.OS === "Darwin" ? "metaKey" : "ctrlKey"]: true,
|
||||
});
|
||||
await onMessage;
|
||||
ok(true, "Input was executed on Ctrl/Cmd + Enter");
|
||||
|
||||
setInputValue(hud, "function x() {");
|
||||
onMessage = waitForMessage(hud, "SyntaxError");
|
||||
EventUtils.synthesizeKey("KEY_Enter", {
|
||||
[Services.appinfo.OS === "Darwin" ? "metaKey" : "ctrlKey"]: true,
|
||||
});
|
||||
await onMessage;
|
||||
ok(true, "The expression was evaluated, even if it wasn't well-formed");
|
||||
}
|
||||
|
||||
async function performEditorDisabledTests() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче