microsoft / microsoft/monaco-editor
[Bug] line (decoration) is breaking when we have code lenses in between the line numbers in the editor
Open
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?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
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
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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