From 7cf25323970d9887cf3775b0a7db85b0399fd046 Mon Sep 17 00:00:00 2001 From: jin-sir <942725119@qq.com> Date: Fri, 14 Jun 2024 10:38:15 +0800 Subject: [PATCH] fix: compare incoming value with modal's value --- src/services/workbench/editorService.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/services/workbench/editorService.ts b/src/services/workbench/editorService.ts index c1fd37027..2534f1c7c 100644 --- a/src/services/workbench/editorService.ts +++ b/src/services/workbench/editorService.ts @@ -1,6 +1,6 @@ import 'reflect-metadata'; import { singleton, container } from 'tsyringe'; -import { cloneDeep } from 'lodash'; +import { cloneDeep, isString } from 'lodash'; import { Component } from 'mo/react'; import { EditorModel, @@ -337,8 +337,13 @@ export class EditorService const model = MonacoEditor.getModel( Uri.parse(tab.id.toString()) ); - if (model) { - model.setValue(editorValue || ''); + const currentValue = model?.getValue(); + if ( + model && + isString(editorValue) && + currentValue !== editorValue + ) { + model.setValue(editorValue); } this.updateGroup(groupId, group); @@ -362,8 +367,13 @@ export class EditorService const model = MonacoEditor.getModel( Uri.parse(tab.id.toString()) ); - if (model) { - model.setValue(editorValue || ''); + const currentValue = model?.getValue(); + if ( + model && + isString(editorValue) && + currentValue !== editorValue + ) { + model.setValue(editorValue); } });