Disable enter key for accepting code completion in Monaco (#30548)

Fixes https://github.com/go-gitea/gitea/issues/28114 and behaviour
matches vscode on desktop as well.

Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit 49b80f8ac1cf9f0b56da0c73d0f34ef030f4c447)
This commit is contained in:
silverwind 2024-04-18 10:06:56 +02:00 committed by Gergely Nagy
parent b3a6596b54
commit 5b08c0a013
No known key found for this signature in database

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});