microsoft / microsoft/monaco-editor
[Feature Request] Add support for X position of a line decoration
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Context
- This issue is not a bug report. (please use a different template for reporting a bug)
- This issue is not a duplicate of an existing issue. (please use the search to find existing issues)
Description
We are using Monaco Editor component showing files and marking license hits in the editor gutter with decorations. Each detected license gets its own colour, and we are passing this colour in linesDecorationsClassName. The result is this:
Currently, the lines are shown with
const className = compound
? "bg-gray-400"
: `bg-${expression} w-3 ml-3`;
...
const decoration = {
range: range,
options: {
isWholeLine: true,
linesDecorationsClassName: `${className}`,
},
};
Each license hit in a file has start and end lines, where we use Range, and quite often these overlap, so we need a way to offset overlapping lines in X direction, so the editor gutter would be looking something like this:
The problem is, lines decorations in the gutter always seem to stick to the rightmost edge of the gutter, and setting the right margin for shifting some lines to the left does nothing. So, for example, this doesn't work at all:
const className = compound
? "bg-gray-400"
: `bg-${expression} w-3 mr-3`;
Is this an inherent limitation of the Monaco Editor component itself, and any ideas to circumvent it or implement some support for defining a line decoration's horizontal placement in the editor gutter?
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
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
No source file, test, or Playground link is named. Start by reproducing the issue with linesDecorationsClassName, Range, and overlapping gutter decorations, then trace Monaco's line-decoration and gutter-layout entry points. Done means providing a supported horizontal placement or offset for overlapping decorations, with behavior documented and verified against the reported example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100