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 Diff Editor Model Refs #696

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Fix Diff Editor Model Refs #696

merged 2 commits into from
Jul 2, 2024

Conversation

zgbpr
Copy link
Contributor

@zgbpr zgbpr commented Jul 2, 2024

Summary

Fixes a bug that caused both diff editors to display the same model.

Details

We ran into a bug with the diff editor where both the modified editor and original editor displayed the same content. When we inspected the editors in the browser, we found that they had the same data-uri value.

After tracing through the editorAppBase.ts file, we saw that the getEditorUri function accepts a boolean to determine whether to append 'Original'. But the buildModelRef function always passed false when building the model reference for both editors.

This pull request fixes the bug by passing a boolean parameter from buildModelRef to getEditorUri and ensuring that the URIs are different for both editors.

Screenshots

Here is a screenshot before the change, showing how the modified editor and original editor displayed the same content.

Screenshot 2024-07-01 at 7 51 16 PM

Here is a screenshot after the change, showing how the modified editor and original editor now display different content.

Screenshot 2024-07-01 at 7 52 32 PM

@kaisalmen
Copy link
Collaborator

@zgbpr thank you for spotting this and providing the fix. Can you please add a unit test? https://github.com/TypeFox/monaco-languageclient/blob/main/packages/wrapper/test/wrapper.test.ts#L114-L133 should be a good template to derive a new test from.

@zgbpr
Copy link
Contributor Author

zgbpr commented Jul 2, 2024

Thanks for the suggestion, @kaisalmen! Since that test already creates and verifies the model references, I added a few more expect statements to make sure that each model reference has a different name.

Let me know if you'd prefer to verify the names in a separate test.

Copy link
Collaborator

@kaisalmen kaisalmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you'd prefer to verify the names in a separate test.

No, that is fine. Thank you. LGTM

@kaisalmen kaisalmen merged commit 3c1c0ac into TypeFox:main Jul 2, 2024
1 check passed
@zgbpr
Copy link
Contributor Author

zgbpr commented Jul 2, 2024

Thanks @kaisalmen! Do you happen to know when these changes might be included with a release?

@kaisalmen
Copy link
Collaborator

@zgbpr
Copy link
Contributor Author

zgbpr commented Jul 2, 2024

Amazing, thank you! 🙏

@zgbpr
Copy link
Contributor Author

zgbpr commented Jul 2, 2024

Hmm, I pulled down v4.3.1 of @typefox/monaco-editor-react but it looks like the underlying version of monaco-editor-wrapper still contains the diff model ref bug.

Any chance that there needs to be a v5.3.1 release of monaco-editor-wrapper as well?

@kaisalmen
Copy link
Collaborator

Sorry, my fault. New versions will come soon.

@kaisalmen
Copy link
Collaborator

kaisalmen commented Jul 2, 2024

@zgbpr
Copy link
Contributor Author

zgbpr commented Jul 2, 2024

Thank you for the quick updates, @kaisalmen! That's working well. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants