microsoft / microsoft/monaco-editor

[Bug] line (decoration) is breaking when we have code lenses in between the line numbers in the editor

Open
#4,896 3 comments 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#XQAAAAJHCAAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw9jH9ZzFei_Sc4PyOP7F38Mszh1Ij9x3NVO4_ojXjl2Ga5DzZtPmYdeuqg-oqKsw2anTFFxwt8mEXMTeW1sCX_TAnlOjQ4gFMqDHRrb1MmgQE7_iQSo2r1f6w4M-4SwH_dpxj0djJTXmZliFZ7kobLp_oYn_isoUplAtrfedavGc5uRyZISGysFyiInl_rTcSKHlcSzhhNmDFv3ySA56r_UIdMLdYj5TkMGN5hfs3RQIVMBDGbOJ6koAH5g6WSFmgGPrLR4cfFPeDQxIKdWApHJ1fbzGL2Vz-Nte713hmXFdXWMhqLvk3kTWlNeEKDxk9yDX-eY18_d4oZUaqIq8gL-nglk-n7R0GMaHOt_8mf1nX02LkBiHX0DECDX0-c4rX4r_V7CxSU-gJRMPCV-KrvNJus0vxKcfrO_peRHpjGiAvOY10ZOjXSSNRlPwXoJmPFSizvGgYC3hPouEkVihwHBq2EghxNREfY9ZBGziuqyA2HTcLEUSJWcuUQE0hatGyIBVd70iGYNFHfzKWOyEeRYkLefZvrGDnfiFXAQtJ7OEMltn6Gmi1G3fW8uh1ZZJMNezS2iQYMI4T1ORt-CaBpk3qChl3WxzF3k4iVvEX-ildXfDSF2pD0aWgRwq2LebQHsfbMsBkU1KOU50c7n7mY_Tc40fAya7trlOsHP9ovzdcOscg0wMLsodEm3zalu224Jmdvg3OWzh46A1ieEDoB8KGD30MZ1sulYObwIxJ8MawbVrcAzblwxuZprmchwyI8V0072Bick8L04sdBJq7ehCK47DVx0NKuIZf4mLNmSR7EtaIOtO3om_li4iwv520f72gkdMl3-GpLLgT_nzXAyxqbo3mrkbrNIfXNjoclm7g1-gzt3nHriMdnLtw4SvLSmax2_DEqLKzcICKjVOkPqUmUp1e103_tG3wg5gVvIsXxUbccQUizss86cV9P6VdKdOzOVdozMuH-yj0h5Mq0hsu4p8qjrkjwrtUUTXfY6ETqfISQ2d8GyDEoEnQCNiTE3VGoiaiBjQdBwNOVfExbAMCmDGc5xAsbjzcxkwhyUWjzIjIMnkcutv5D4gIThWtOsFWj7VpONeLm0y7oBicxOoP4b9mDqDxBcI0CxxhfArLz__U_wWM

Monaco Editor Playground Code
var editor = monaco.editor.create(document.getElementById("container"), {
	value: '{\n\t"dependencies": {\n\t\t\n\t}\n}\n {\n\t"dependencies": {\n\t\t\n\t}\n}\n {\n\t"dependencies": {\n\t\t\n\t}\n}\n',
	language: "json",
});

var commandId = editor.addCommand(
	0,
	function () {
		// services available in `ctx`
		alert("my command is executing!");
		alert("my command is executing!");
		
	},
	""
);

var decorations = editor.createDecorationsCollection([
	{
		range: new monaco.Range(1, 0, 9, 0),
		options: {
			isWholeLine: true,
			linesDecorationsClassName: "myLineDecoration",
		},
	},
	{
		range: new monaco.Range(1, 0, 9, 0),
		options: {
			isWholeLine: true,
			className: "my-right-edge-decoration",
		},
	},
	
]);


monaco.languages.registerCodeLensProvider("json", {
	provideCodeLenses: function (model, token) {
		return {
			lenses: [
				{
					range: {
						startLineNumber: 1,
						startColumn: 1,
						endLineNumber: 2,
						endColumn: 1,
					},
					id: "First Line",
					command: {
						id: commandId,
						title: "First Line",
					},
				},
				{
					range: {
						startLineNumber: 6,
						startColumn: 1,
						endLineNumber: 10,
						endColumn: 1,
					},
					id: "First Line",
					command: {
						id: commandId,
						title: "First Line",
					},
				},
			],
			dispose: () => {},
		};
	},
	resolveCodeLens: function (model, codeLens, token) {
		return codeLens;
	},
});
-----------------------------------------------------------
.myInlineDecoration {
	/* color: red !important; */
	cursor: pointer;
	text-decoration: underline;
	font-weight: bold;
	font-style: oblique;
	background: red
}

.my-right-edge-decoration {
    position: absolute;
    background:
    linear-gradient(green 0 0) calc(5.9*100%/6);
  background-size:6px 100% !important;  /* Control the width here*/
  background-repeat:no-repeat;
}

.myLineDecoration {
	background: green;
	width: 5px !important;
	margin-left: 3px;
	display: flex;
    flex-direction: row-reverse; 
	order: 1; 
	justify-content: right;
	
	/* position: absolute; 
	right: 0; 
	bottom: 0; */
}
--------------------------------------------------------
<div id="container" style="height: 100%"></div>
Reproduction Steps

Image

line decoration is breaking when we have code lenses in between the line numbers in the editor

Actual (Problematic) Behavior

No response

Expected Behavior

it should not break when there is a code lenses in between line numbers

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 Monaco Editor Playground link and the provided TypeScript reproduction, focusing on the interaction between whole-line decorations and code lenses inserted between line numbers. Reproduce the layout breakage, then trace the relevant editor rendering behavior; done means line decorations remain intact when code lenses are present.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.