From 7b40094bbb22953b7cc2b4111cafc9289b0e6dee Mon Sep 17 00:00:00 2001 From: fofolee Date: Fri, 21 Feb 2025 00:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8D=A2=E8=A1=8Cbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/editor/CodeEditor.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/editor/CodeEditor.vue b/src/components/editor/CodeEditor.vue index 701f115..6284411 100644 --- a/src/components/editor/CodeEditor.vue +++ b/src/components/editor/CodeEditor.vue @@ -121,6 +121,7 @@ export default defineComponent({ return { resizeTimeout: null, showAIAssistant: false, + wordWrap: "off", }; }, watch: { @@ -179,6 +180,7 @@ export default defineComponent({ value: this.modelValue || "", language, theme: this.theme, + wordWrap: this.wordWrap, }; editor = monaco.editor.create(this.$refs.editorContainer, options); @@ -354,9 +356,11 @@ export default defineComponent({ }, bindKeys() { // alt + z 换行 - const revWordWrap = this.wordWrap === "on" ? "off" : "on"; editor.addCommand(monaco.KeyMod.Alt | monaco.KeyCode.KeyZ, () => { - editor.updateOptions({ wordWrap: revWordWrap }); + this.wordWrap = this.wordWrap === "on" ? "off" : "on"; + editor.updateOptions({ + wordWrap: this.wordWrap, + }); }); }, // 替换选中的文本,供外部调用