microsoft / microsoft/monaco-editor

[Bug] setModelMarkers() with MarkerSeverity.Hint only underlines the first letter, regardless of the endColumn value

Open
#4,890 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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.52.2#XQAAAAJDBAAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw6ZS5CnGBGpWlpVktocO7_BJCkQTDFxt_ci1cqyNrK3ItLbvv1-Zz0fHL6Cz9KJxFTtbVcdJhBb1NEK5NdL9czUzR_L9F1Aszt1mvOedxUpUCcJX_CT4tERgNixslXGvm9zIM10Ei67TNBSQTLj4dZx3FM-KzOYDcdGQGy10iJYoTXlb-9Y6eAyx9JzbUJbqOhV7E9ZX8bAnUXw4SAAvJep7bPOx_XvDuN7IDLGbwJRrBTGWjnDwgL22ulE34Ifd_l1TmUn2yfawi8I8gpWRQLvD5WTTMUZkfr2r1MdySdIDW-lENfH0UO42gtQJzzbR7TD915wDmitER9PWFvVXZ_KcMrgSGAgVtdCfhnRsBdafGcsi2AEowu_TERMZAIxLtEDvvDME-NuN3K9ZB4CNZ9Y_xQH09GKJFUaT_2erZl8n8O39dZk4TW19e-JpZlPUNfVSFgka69ZZkRL-WQuO-JVXOcuwXL6hE_95d1ec

Monaco Editor Playground Code
monaco.languages.register({ id: 'myLanguage' });

monaco.editor.onDidCreateModel(function(model) {
	var markers = [
		{
			severity: monaco.MarkerSeverity.Hint,
			startLineNumber: 1,
			startColumn: 1,
			endLineNumber: 1,
			endColumn: 20,
			message: 'test hint'
		},
		{
			severity: monaco.MarkerSeverity.Info,
			startLineNumber: 2,
			startColumn: 1,
			endLineNumber: 2,
			endColumn: 20,
			message: 'test info'
		},
		{
			severity: monaco.MarkerSeverity.Warning,
			startLineNumber: 3,
			startColumn: 1,
			endLineNumber: 3,
			endColumn: 20,
			message: 'test warning'
		},
		{
			severity: monaco.MarkerSeverity.Error,
			startLineNumber: 4,
			startColumn: 1,
			endLineNumber: 4,
			endColumn: 20,
			message: 'test error'
		},
	];

	monaco.editor.setModelMarkers(model, 'myLanguage', markers);
});

var ed = monaco.editor.create(document.getElementById("container"), {
    value: "this is a hint test\nthis is an info test\nthis is a warning test\nthis is an error test\n\n",
    language: "myLanguage",
});
Reproduction Steps

After creating a Monaco editor with non-empty text, use setModelMarkers() to apply some markers, where at least one marker has MarkerSeverity.Hint and a "length" >1 (a.k.a. an endColumn value much higher than startColumn).

Actual (Problematic) Behavior

Any marker with MarkerSeverity.Hint will only underline a single letter, even if its startColumn and endColumn values imply it should underline several letters. The other three MarkerSeverities correctly underline multiple letters.

Expected Behavior

All MarkerSeverities underline multiple letters when asked to.

Additional Context

I have no idea how to attempt reproducing this in vscode.dev or VS Code Desktop, but Github is forcing me to check that box anyway.

If this is intended behavior, then it's not documented on any of:
https://microsoft.github.io/monaco-editor/typedoc/functions/editor.setModelMarkers.html
https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IMarkerData.html
https://microsoft.github.io/monaco-editor/typedoc/enums/MarkerSeverity.html

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 run the setModelMarkers() example comparing Hint with Info, Warning, and Error. Trace the setModelMarkers() entry point to determine why Hint ignores the requested endColumn; done when Hint underlines the full requested span like the other severities.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.