Skip to content

Commit 2cb976c

Browse files
committed
fix: compare incoming value with modal's value
1 parent 0ed42e8 commit 2cb976c

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

CHANGELOG.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ All notable changes to this project will be documented in this file. See [standa
44

55
### [1.3.5](https://github.com/DTStack/molecule/compare/v1.3.4...v1.3.5) (2023-12-29)
66

7-
87
### Bug Fixes
98

10-
* fix model's value not change and add onEditorInstanceMount event ([eb93979](https://github.com/DTStack/molecule/commit/eb939798a0dd09dd46a7c1d8966a744c5749b0ca))
11-
* fix stylelint ([f126404](https://github.com/DTStack/molecule/commit/f126404bfa0b631923c985bc6679f73800bb7182))
12-
* **scrollBar:** disable clickable when hide track ([e15b8b6](https://github.com/DTStack/molecule/commit/e15b8b68200654863bce5077d4b98b8682f37781))
13-
* update types ([c8d8a1f](https://github.com/DTStack/molecule/commit/c8d8a1fea19060ceb313986482d9fef8791ca124))
9+
- fix model's value not change and add onEditorInstanceMount event ([eb93979](https://github.com/DTStack/molecule/commit/eb939798a0dd09dd46a7c1d8966a744c5749b0ca))
10+
- fix stylelint ([f126404](https://github.com/DTStack/molecule/commit/f126404bfa0b631923c985bc6679f73800bb7182))
11+
- **scrollBar:** disable clickable when hide track ([e15b8b6](https://github.com/DTStack/molecule/commit/e15b8b68200654863bce5077d4b98b8682f37781))
12+
- update types ([c8d8a1f](https://github.com/DTStack/molecule/commit/c8d8a1fea19060ceb313986482d9fef8791ca124))
1413

1514
### [1.3.4](https://github.com/DTStack/molecule/compare/v1.3.3...v1.3.4) (2023-06-12)
1615

src/services/workbench/__tests__/editorService.test.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,12 @@ describe('Test EditorService', () => {
208208
expect(groups?.length).toBe(1);
209209

210210
const setValFn = jest.fn();
211+
const getValFn = jest.fn();
211212
(MonacoEditor.getModel as jest.Mock).mockImplementation(() => ({
212213
setValue: setValFn,
214+
getValue: getValFn,
213215
}));
216+
214217
act(() => {
215218
editor.updateTab({
216219
id: mockTab.id,

src/services/workbench/editorService.ts

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'reflect-metadata';
22
import { singleton, container } from 'tsyringe';
3-
import { cloneDeep } from 'lodash';
3+
import { cloneDeep, isString } from 'lodash';
44
import { Component } from 'mo/react';
55
import {
66
EditorModel,
@@ -337,8 +337,13 @@ export class EditorService
337337
const model = MonacoEditor.getModel(
338338
Uri.parse(tab.id.toString())
339339
);
340-
if (model) {
341-
model.setValue(editorValue || '');
340+
const currentValue = model?.getValue();
341+
if (
342+
model &&
343+
isString(editorValue) &&
344+
currentValue !== editorValue
345+
) {
346+
model.setValue(editorValue);
342347
}
343348
this.updateGroup(groupId, group);
344349

@@ -362,8 +367,13 @@ export class EditorService
362367
const model = MonacoEditor.getModel(
363368
Uri.parse(tab.id.toString())
364369
);
365-
if (model) {
366-
model.setValue(editorValue || '');
370+
const currentValue = model?.getValue();
371+
if (
372+
model &&
373+
isString(editorValue) &&
374+
currentValue !== editorValue
375+
) {
376+
model.setValue(editorValue);
367377
}
368378
});
369379

0 commit comments

Comments
 (0)