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 <me@silverwind.io>
(cherry picked from commit c9633f2d74490211ffd9fd6b3a17180e86fa1fb9)
This commit is contained in:
Giteabot 2024-04-18 17:38:32 +08:00 committed by Earl Warren
parent f436cb86d4
commit cb4246ed57
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -112,6 +112,10 @@ export async function createMonaco(textarea, filename, editorOpts) {
...other, ...other,
}); });
monaco.editor.addKeybindingRules([
{keybinding: monaco.KeyCode.Enter, command: null}, // disable enter from accepting code completion
]);
const model = editor.getModel(); const model = editor.getModel();
model.onDidChangeContent(() => { model.onDidChangeContent(() => {
textarea.value = editor.getValue({preserveBOM: true}); textarea.value = editor.getValue({preserveBOM: true});