From 332ee359ce8b4945f4eb463d4413582fd3bf91d1 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 18 Apr 2024 17:38:24 +0800 Subject: [PATCH] Disable enter key for accepting code completion in Monaco (#30548) (#30558) 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 --- 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 9640c87c1b..e70895e7f0 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});