diff --git a/client/src/templates/Challenges/classic/editor.tsx b/client/src/templates/Challenges/classic/editor.tsx index 8b3b4fdc2a..459587be6c 100644 --- a/client/src/templates/Challenges/classic/editor.tsx +++ b/client/src/templates/Challenges/classic/editor.tsx @@ -379,6 +379,21 @@ const Editor = (props: EditorProps): JSX.Element => { null, () => {} ); + const newLine = editor.getAction('editor.action.insertLineAfter'); + // @ts-ignore + editor._standaloneKeybindingService.addDynamicKeybinding( + '-editor.action.insertLineAfter', + null, + () => {} + ); + // @ts-ignore + editor._standaloneKeybindingService.addDynamicKeybinding( + 'editor.action.insertLineAfter', + monaco.KeyMod.Alt | monaco.KeyCode.Enter, + () => { + newLine.run(); + } + ); /* eslint-enable */ editor.addAction({ id: 'execute-challenge', diff --git a/cypress/integration/learn/common-components/editor.js b/cypress/integration/learn/common-components/editor.js new file mode 100644 index 0000000000..25f9596814 --- /dev/null +++ b/cypress/integration/learn/common-components/editor.js @@ -0,0 +1,29 @@ +const selectors = { + editor: '.monaco-editor' +}; + +describe('Editor Shortcuts', () => { + it('Should handle Alt+Enter', () => { + cy.visit( + 'learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements' + ); + cy.get(selectors.editor, { timeout: 15000 }) + .first() + .click() + .focused() + .type('{alt}{enter}') + .should('have.value', '