microsoft / microsoft/monaco-editor

[Feature Request] Add support for X position of a line decoration

Open
#4,427 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
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:
312349679-932b0ee7-483a-4290-be97-3a3f3c02b14c

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:
312350067-23bb5e01-7ea6-46b1-9a02-61a9965f7cfe

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.