microsoft / microsoft/monaco-editor

[Bug] Secondary rendered Diff Editor has broken code highlighting

Open
#4,235 0 comments 0 reactions 1 assignee View on GitHub

@hediet is already working on this.

Since Dec 13, 2023.

bug diff-editor
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.44.0#XQAAAAKzAwAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw4oYX04gV7gAKENNue8aHDKpiOMt5TS-H99PBmnXpDKne8F9nszaFUCBldxoV8OiO__3phokWZZ6A_3OLOuUQpCIet3XaGtfI9xxmPgab2lLsKrPegU9OSkUbyxeRFXuPESzgzGtFAIzrgTA1TzY3vFErd0a9GxkYPhoi1eTuiTp_oUu0FLgEGCcRxMuaCeJW96N2ZSda8Ch53YgCpdxELY0wB2yLm6aEZM--7mDEWJ9qa_i2mCeZeIRNZLayeWIQ3f79RLxXB3-vmEIDYVl9cnUaJvsWN6dDd6gE0MsQdRT5A2XZPYO0LH6yPvF4mIRGJKy8T68bY4-26Z739WWmbApVexm9KD4Wh_Wp9FfJgDDz7wdchni2jMsRHEnVRudNN69EpypVYRWEZlDeZO726AuQbpYdACkCZyLzqfK7syDUxNKto5GyLr-iXrb-ez7a

Monaco Editor Playground Code
const container = document.getElementById('container');


const container1 = document.createElement('div');
container1.style.cssText = 'height: 50%';
container.appendChild(container1);
var diffEditor = monaco.editor.createDiffEditor(
	container1,
	{
		renderSideBySide: false,
	}
);

diffEditor.setModel({
	original: monaco.editor.createModel(
		`version: 2;`,
		"yaml"
	),
	modified: monaco.editor.createModel(
		"", "yaml"
	),
});

 
setTimeout(() => {
	const container2 = document.createElement('div');
	container2.style.cssText = 'height: 50%';
	container.appendChild(container2);

	var diffEditor2 = monaco.editor.createDiffEditor(
		container2,
		{
			renderSideBySide: false,
		}
	);

	diffEditor2.setModel({
		original: monaco.editor.createModel(
			`version: 2;`,
			"yaml"
		),
		modified: monaco.editor.createModel(
			"", "yaml"
		),
	}); 
        
}, 1000);
Reproduction Steps
  • Create two dom element containers for two diff editors
  • Render diffEditor into the first container and set model
  • Wait for 1s and render the second diffEditor into the second container and set similar model
Actual (Problematic) Behavior

Secondary rendered after 1s delay diff editor has broken code highlighting
изображение

Expected Behavior

All diff editors should have the same code highlighting

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.