From cb4246ed570f14a3320658f5693246deeebad64a Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 18 Apr 2024 17:38:32 +0800 Subject: [PATCH] Disable enter key for accepting code completion in Monaco (#30548) (#30559) Backport #30548 by @silverwind Fixes https://github.com/go-gitea/gitea/issues/28114 and behaviour matches vscode on desktop as well. Co-authored-by: silverwind (cherry picked from commit c9633f2d74490211ffd9fd6b3a17180e86fa1fb9) --- web_src/js/features/codeeditor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web_src/js/features/codeeditor.js b/web_src/js/features/codeeditor.js index 4fb8bb9e63..f5e4e74dc6 100644 --- a/web_src/js/features/codeeditor.js +++ b/web_src/js/features/codeeditor.js @@ -112,6 +112,10 @@ export async function createMonaco(textarea, filename, editorOpts) { ...other, }); + monaco.editor.addKeybindingRules([ + {keybinding: monaco.KeyCode.Enter, command: null}, // disable enter from accepting code completion + ]); + const model = editor.getModel(); model.onDidChangeContent(() => { textarea.value = editor.getValue({preserveBOM: true});