diff --git a/packages/bruno-app/src/components/CodeEditor/index.js b/packages/bruno-app/src/components/CodeEditor/index.js index f42098469..fcb55fbd8 100644 --- a/packages/bruno-app/src/components/CodeEditor/index.js +++ b/packages/bruno-app/src/components/CodeEditor/index.js @@ -64,13 +64,16 @@ class CodeEditor extends React.Component { componentDidMount() { const variables = getAllVariables(this.props.collection, this.props.item); - const runShortcut = () => { - if (this.props.onRun) { - this.props.onRun(); - return; - } - return CodeMirror.Pass; - }; + /** + * No-op. We claim Cmd-Enter / Ctrl-Enter here only to suppress CodeMirror's + * sublime keymap default (insertLineAfter), which would otherwise insert a + * newline. sendRequest dispatch is owned by Mousetrap — the editor input has + * the `mousetrap` class (added below) so the global + * useKeybinding('sendRequest', …) in RequestTabPanel handles it, and only + * in request tabs. Falling through with CodeMirror.Pass when onRun is absent + * would re-introduce the newline in collection/folder-level editors. + */ + const runShortcut = () => {}; const editor = (this.editor = CodeMirror(this._node, { value: this.props.value || '', diff --git a/packages/bruno-app/src/components/MultiLineEditor/index.js b/packages/bruno-app/src/components/MultiLineEditor/index.js index 41c720343..f22c6acaa 100644 --- a/packages/bruno-app/src/components/MultiLineEditor/index.js +++ b/packages/bruno-app/src/components/MultiLineEditor/index.js @@ -30,13 +30,16 @@ class MultiLineEditor extends Component { // Initialize CodeMirror as a single line editor /** @type {import("codemirror").Editor} */ const variables = getAllVariables(this.props.collection, this.props.item); - const runShortcut = () => { - if (this.props.onRun) { - this.props.onRun(); - return; - } - return CodeMirror.Pass; - }; + /** + * No-op. We claim Cmd-Enter / Ctrl-Enter here only to suppress CodeMirror's + * sublime keymap default (insertLineAfter), which would otherwise insert a + * newline. sendRequest dispatch is owned by Mousetrap — the editor input has + * the `mousetrap` class (added below) so the global + * useKeybinding('sendRequest', …) in RequestTabPanel handles it, and only + * in request tabs. Falling through with CodeMirror.Pass when onRun is absent + * would re-introduce the newline in collection/folder-level editors. + */ + const runShortcut = () => {}; this.editor = CodeMirror(this.editorRef.current, { lineWrapping: false, diff --git a/packages/bruno-app/src/components/RequestPane/QueryEditor/index.js b/packages/bruno-app/src/components/RequestPane/QueryEditor/index.js index ee16fa1fb..b3a174bac 100644 --- a/packages/bruno-app/src/components/RequestPane/QueryEditor/index.js +++ b/packages/bruno-app/src/components/RequestPane/QueryEditor/index.js @@ -53,6 +53,16 @@ export default class QueryEditor extends React.Component { } componentDidMount() { + /** + * No-op. We claim Cmd-Enter / Ctrl-Enter here only to suppress CodeMirror's + * sublime keymap default (insertLineAfter), which would otherwise insert a + * newline. sendRequest dispatch is owned by Mousetrap — the editor input has + * the `mousetrap` class (added below) so the global + * useKeybinding('sendRequest', …) in RequestTabPanel handles it, and only + * in request tabs. + */ + const runShortcut = () => {}; + const editor = (this.editor = CodeMirror(this._node, { value: this.props.value || '', lineNumbers: true, @@ -125,7 +135,9 @@ export default class QueryEditor extends React.Component { } }, 'Cmd-F': 'findPersistent', - 'Ctrl-F': 'findPersistent' + 'Ctrl-F': 'findPersistent', + 'Cmd-Enter': runShortcut, + 'Ctrl-Enter': runShortcut } })); if (editor) {