From dd22ebdaf001a5baf65130e4d06c0d4aa8ae5871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Thu, 6 Oct 2022 12:37:50 +0200 Subject: [PATCH] (core) Handling shift+enter on ace editor Summary: Shift+Enter doesn't work on ace editor when suggestions are shown. Propobly this is bug in the ace-editor. Test Plan: Manual: Start ace editor, and trigger auto-completion menu. Pressing shift+enter should add new line (with proper indention). Previously it did nothing. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3625 --- app/client/components/AceEditorCompletions.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/client/components/AceEditorCompletions.ts b/app/client/components/AceEditorCompletions.ts index 1438a110..6046cb8b 100644 --- a/app/client/components/AceEditorCompletions.ts +++ b/app/client/components/AceEditorCompletions.ts @@ -20,6 +20,13 @@ export function setupAceEditorCompletions(editor: Ace.Editor, options: ICompleti const {Autocomplete} = ace.require('ace/autocomplete'); const completer = new Autocomplete(); + // Here is the source code: + // https://github.com/ajaxorg/ace/blob/23208f2f19020d1f69b90bc3b02460bda8422072/src/autocomplete.js#L180 + // It seems that this function wasn't doing anything special, and wasn't returning anything, so + // AceEditor refused to insert new line. Option 'deleteSuffix is also not supported (line 150). + if (completer.keyboardHandler?.commands?.["Shift-Return"]) { + completer.keyboardHandler.commands["Shift-Return"].exec = () => false; + } completer.autoSelect = false; (editor as any).completer = completer;