From 16d26077bea56482b563f3c8ea3be828484b8e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD?= <81747598+lan-yonghui@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:49:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=9B=91=E5=90=AC=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=86=85=E5=AE=B9=E5=8F=98=E5=8C=96=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4=20(#5732)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整监听编辑器内容变化事件到初始化编辑器之后,避免编辑器初始化时导致默认内容被视为用户编辑行为。 --- .../views/host/file-management/code-editor/index.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/host/file-management/code-editor/index.vue b/frontend/src/views/host/file-management/code-editor/index.vue index 99f717df5..7d668d00b 100644 --- a/frontend/src/views/host/file-management/code-editor/index.vue +++ b/frontend/src/views/host/file-management/code-editor/index.vue @@ -393,17 +393,17 @@ const initEditor = () => { let defaultContent = '\n\n\n\n'; editor.getModel().setValue(defaultContent); } + + editor.getModel().pushEOL(config.eol); + + editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, quickSave); + editor.onDidChangeModelContent(() => { if (editor) { form.value.content = editor.getValue(); isEdit.value = true; } }); - - // After onDidChangeModelContent - editor.getModel().pushEOL(config.eol); - - editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, quickSave); }); };