microsoft / microsoft/monaco-editor

[Bug] customized Diff-Algorithm, needed for diff-editor

Open
#4,764 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

demo

Cannot be used in the latest version, how to solve it

Monaco Editor Playground Code
const WorkerBasedDocumentDiffProvider = require('vs/editor/browser/widget/diffEditor/workerBasedDocumentDiffProvider').WorkerBasedDocumentDiffProvider;

class MyDiffProviderFactoryService {
	createDiffProvider(editor, options) {
		console.log('compute diff');
		const provider = standaloneServices.StandaloneServices.initialize().createInstance(WorkerBasedDocumentDiffProvider, {});

		return {
			onDidChange: () => {},
			async computeDiff(original, modified, options, token) {
				const d = await provider.computeDiff(original, modified, options, token);
				return {
					changes: d.changes.slice(1),
					moves: [],
					identical: false,
					quitEarly: false,
				};
			}
		}
	}
}

const standaloneServices = require("vs/editor/standalone/browser/standaloneServices");

standaloneServices.StandaloneServices.initialize({
	'diffProviderFactoryService': new MyDiffProviderFactoryService(),
});

const m1 = monaco.editor.createModel(`
1
2
3
4
5
6
7
8
9`);

const m2 = monaco.editor.createModel(`
1
2
x
4
5
6
8
9`);

const diffEditor = monaco.editor.createDiffEditor(document.getElementById('container'), {});
console.log('1');
diffEditor.setModel({
	original: m1,
	modified: m2,
});
Reproduction Steps
  1. Use the above code or demo
  2. Update monaco version to 0.49
Actual (Problematic) Behavior

No response

Expected Behavior

No response

Additional Context

No response

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.

Research direction

Start with the linked Monaco Editor Playground reproduction and the referenced vs/editor/browser/widget/diffEditor/workerBasedDocumentDiffProvider module, comparing behavior before and after version 0.49. Clarify the intended customized diff algorithm and expected behavior first; the issue is complete only when that behavior is reproducible and a supported resolution is established.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.