Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compare incoming value with modal's value #887

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/services/workbench/__tests__/editorService.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ describe('Test EditorService', () => {
expect(groups?.length).toBe(1);

const setValFn = jest.fn();
const getValFn = jest.fn();
(MonacoEditor.getModel as jest.Mock).mockImplementation(() => ({
setValue: setValFn,
getValue: getValFn,
}));

act(() => {
editor.updateTab({
id: mockTab.id,
Expand Down
20 changes: 15 additions & 5 deletions src/services/workbench/editorService.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -337,8 +337,13 @@
const model = MonacoEditor.getModel(
Uri.parse(tab.id.toString())
);
if (model) {
model.setValue(editorValue || '');
const currentValue = model?.getValue();
if (
model &&
isString(editorValue) &&
currentValue !== editorValue

Check warning on line 344 in src/services/workbench/editorService.ts

View check run for this annotation

Codecov / codecov/patch

src/services/workbench/editorService.ts#L343-L344

Added lines #L343 - L344 were not covered by tests
) {
model.setValue(editorValue);

Check warning on line 346 in src/services/workbench/editorService.ts

View check run for this annotation

Codecov / codecov/patch

src/services/workbench/editorService.ts#L346

Added line #L346 was not covered by tests
}
this.updateGroup(groupId, group);

Expand All @@ -362,8 +367,13 @@
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);
}
});

Expand Down
Loading