microsoft / microsoft/monaco-editor

[Feature Request] Option to keep glyphs position without changes

Open
#4,396 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

In my project I need glyphs be positioned on provided place without changes. I added glyph by editor.createDecorationsCollection, it works fine. However if I left click + Enter on the very beggining of the line where glyph positioned the glyph will appear on the next line.

I added stickiness property TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges and the growing of glyphs stopped. But the glyph goes to the next line still. Is there another option, which can help me? Or maybe it's possible to add it to monaco editor?

Monaco Editor Playground Link

Reproduction:

  1. Go to playground (link to monaco playground example)
  2. Set cursor on the beggining of 3rd line
  3. Press Enter
  4. Code from 3rd line went to 4th line with glyph
  5. How to keep glyph on the 3rd line?
Monaco Editor Playground Code
var jsCode = [
	'"use strict";',
	"function Person(age) {",
	"	if (age) {",
	"		this.age = age;",
	"	}",
	"}",
	"Person.prototype.getAge = function () {",
	"	return this.age;",
	"};",
].join("\n");

var editor = monaco.editor.create(document.getElementById("container"), {
	value: jsCode,
	language: "javascript",
	glyphMargin: true,
});

var decorations = editor.createDecorationsCollection([
	{
		range: new monaco.Range(3, 1, 3, 1),
		options: {
			isWholeLine: true,
			className: "myContentClass",
			glyphMarginClassName: "myGlyphMarginClass",
			stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
		},
	},
]);

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 linked Monaco Editor Playground reproduction and the editor.createDecorationsCollection API, focusing on TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges. Reproduce pressing Enter at the beginning of the third line, then trace how the glyph decoration moves. Done means a supported option or documented behavior keeps the glyph on the intended line without breaking existing decoration behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
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.