microsoft / microsoft/monaco-editor

[Bug] Duplicate underlines in model makers with `code` that has a `target`

Open
#5,003 2 comments 0 reactions 1 assignee View on GitHub

@hediet is already working on this.

Since Dec 15, 2025.

bug editor-core
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.54.0-dev-20250916#XQAAAAK-BQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw9ehbjwLINgRABDcFm89fBOSueOLTYt0aaEwnsLoPwmLxwedOn8Q8TDA7HdG2A53dB9AMwMH_c2UsEDCPbL8A4cD4wMZ1VB0MWs_y8RU4Rfp30mb6j4qTZKwUsJT_Y6UO5T9OwHKk44-wuN3FrNkoMlyuHr9pGHVtjhrklmGHrcy0-LqP9muYZYtszV0OOFI0KwyofOIRcJI_i_VGlYJIkUONR11xqsXKDvLnjkjwTRvpUtCs08KlP136Xme_NvlziGY2yv0QATuwfy55XkdSpy1JsupnWflFj-DieEjMAsQp5m7Bxec4rFWdqcmwcgyRSXOotE5SSBMvHby5WUohzPzZrPP09gS-2FImOIlKy3Mu_zbWcY5tZ2641TZejtPKCgiX5ILxEFO8H6G9onmZHbeT_d1YqnPIXeSLTrpOYyBMhh0sBd8wiAoLnEDQoxO6Ft1X6M-OiBUvX5vgYXJibFLcZyIQXwVPc854TCja1fOcO4j6SsGZ9AqmasBANLAM87Ba39m9Spf-299BS9vch6olcpfmIPfbHnku2SkkTghKW50qpzw2GsLo34CcK86IFl_2Fg6pvdui82XNq9M8-3xXF6aMTQIeFUjiWIsd0gX4mhhA6UJry4SN-hr-xuh34GaTwTbvaWJJ4XRpHE-gOtcdAKh52bShRw20bc73L8Ka-gXmicGa_0OzVrE67t7X7w2rq8xOlUpF9H7cRFmzg5rb2OWSJ6C0y2XuvfcVVlmP_0nAl8wOTzUBC475oI3ibEec39HSY5JIRRyX9R_69vrW

Monaco Editor Playground Code
function validate(model) {
	const markers = [];
	// lines start at 1
	for (let i = 1; i < model.getLineCount() + 1; i++) {
		const range = {
			startLineNumber: i,
			startColumn: 1,
			endLineNumber: i,
			endColumn: model.getLineLength(i) + 1,
		};
		const content = model.getValueInRange(range).trim();
		const number = Number(content);
		if (Number.isNaN(number)) {
			markers.push({
				message: "not a number",
				severity: monaco.MarkerSeverity.Error,
				startLineNumber: range.startLineNumber,
				startColumn: range.startColumn,
				endLineNumber: range.endLineNumber,
				endColumn: range.endColumn,
				code: {
					value: 'NAN',
					target: monaco.Uri.parse('https://example.com/')
				}
			});
		} else if (!Number.isInteger(number)) {
			markers.push({
				message: "not an integer",
				severity: monaco.MarkerSeverity.Warning,
				startLineNumber: range.startLineNumber,
				startColumn: range.startColumn,
				endLineNumber: range.endLineNumber,
				endColumn: range.endColumn,
			});
		}
	}
	monaco.editor.setModelMarkers(model, "owner", markers);
}

const value = `12345
abcd
234.56
12345
abcd
234.56`;
const uri = monaco.Uri.parse("inmemory://test");
const model = monaco.editor.createModel(value, "demoLanguage", uri);
const editor = monaco.editor.create(document.getElementById("container"), {
	model,
});
validate(model);
model.onDidChangeContent(() => {
	validate(model);
});
Reproduction Steps

Hover on the abcd to see hover contents

Actual (Problematic) Behavior

Duplicate underlines.

Image
Expected Behavior

Only one underline, the same as vscode.

Image
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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.