[Bug] ModelMarker hover widget does not always render full size on first hover

Open
#4,314 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the linked Monaco Editor Playground example on version 0.45.0 and reproduce the first-hover behavior using the supplied marker code. Done means the initial hover displays the full “View Problem (alt+F8)” text, matching subsequent hovers; no code location or test is named in the issue.

Written by the indexing model from the issue text.

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.45.0#example-extending-language-services-model-markers-example

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,
			});
		} 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 over the initial problem (one of the errors), and it displays "View"

re-hover over it, and it will change to "View Problem (alt+F8)"

I am using 0.45.0

Actual (Problematic) Behavior

Should always show the hotkey and the full text of the marker.

Expected Behavior

On the first hover, the editor should fully display the "View Problem (alt+F8)" text.

If there is some method I can call to force it into the latter as I create markers, that would be acceptable (I tried editor.layout() thinking the editor needed to re-configure itself a bit or something, but that did not seem to work).

Additional Context

Initial render display:
bad

Subsequent render display:
good

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

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.

More from microsoft/monaco-editor

All issues in microsoft/monaco-editor

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.