microsoft / microsoft/monaco-editor

[Bug] DiffEditor shows overloads because of duplicated definitions

Open
#3,049 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug typescript-multifile
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
Monaco Editor Playground Code
var originalModel = monaco.editor.createModel('function foo() {}', 'javascript');
var modifiedModel = monaco.editor.createModel('function foo() {}', 'javascript');

var diffEditor = monaco.editor.createDiffEditor(document.getElementById('container'));
diffEditor.setModel({
	original: originalModel,
	modified: modifiedModel
});
Actual Behavior

Editor shows two definitions for function
image

Resulting in a +1 overload
image

Expected Behavior

I would expect just one definition. The definition, referencing a function in the same file should depend on the model I am currently looking at.

Additional Context

We are using the DiffEditor to compare changes to a file since it has been saved the last time, thus the two models refer to the same file in different states. Cross referencing functions between the two models does not make sense for our use case and is kind of irritating.
Is there an option to deactivate it, or are we entirely on the wrong track?

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 Monaco Editor Playground reproduction using monaco.editor.createModel, monaco.editor.createDiffEditor, and diffEditor.setModel. Trace how definitions are resolved across the original and modified models, then check whether an existing option controls this behavior. Done means the same-file DiffEditor case shows one definition without breaking cross-file references.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.