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 <me@silverwind.io>
This commit is contained in:
Giteabot 2024-04-18 17:38:24 +08:00 committed by GitHub
parent a82bf022bf
commit 332ee359ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

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