microsoft / microsoft/monaco-editor

Decorations are improper on undo

Open
#4,587 0 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.50.0#XQAAAAJOAwAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw2TFFKXzoBtNlUc7JzEx8NDAUbFLl_jqQ-13Gd-1RJYH2Zt9Ji-HKLTQUAY3dr9vTn3QH3Ox7hyIstkn4D6ZgA6N_RtXb_HexBA6A5D_L5VxZvx6s0f-RwMssATjNUJpb9kRqAa052ldBleV6_U8X6JnEBsGPqfGqZ87bKknyqjy3E23r3KPMjf81SjBsa5BcM7-d4u3fo-eUpOtuI5uC9JI029j_XR8UAKeRFfKhnU0_yB4TuUHTO433mmfZMWSozpRO45JzMlhV12g44qux8ZlGx-pM-IMoNWmYjf4bwsDbeuePq5Bjwc44ixyPWydGF3zPUbs-gPwLCwwjj9t4qLtmqptgM1Ydt6Wse7qZDIMhd9VX7HKQWKAOVOyu9ZN26-HTHTQ1oKuLC3a1vsdpv1Ia0oafZdS6teRsd9LfelyHfjzq9KU0Q9KVXGy4NamprsOMUOMJTHN9hKYwRR8IblIVSX7C5H4TJ9pTfdtCuHnc9yCMZ22U3GAu3-DpUveWkpQ8iMmNJtPJIQCEG_rZTcDABslJzhSs-0yPpfdCgAD5MjmHn1SfP6WxLkZkCaQ7DSlkMAxX0GMdDvoZBVUzyW6308oAFPZmwbNr_1Ek_1mRdXvG0xKiahF2xN5qVP_2sJXM

Monaco Editor Playground Code
var jsCode = "function Person(age) {if (age)123456{this.age = age;}}"

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

setTimeout(() => {
	editor.executeEdits("", [{
		range: new monaco.Range(1, 1, 1, 99),
		text: "function Person(age) {\n  if (age)123456{\n    this.age = age;\n  }\n}",
		forceMoveMarkers: true,
	}]);
	editor.createDecorationsCollection([
		{
			range: new monaco.Range(2, 7, 2, 10),
			options: { inlineClassName: "myInlineDecoration", shouldFillLineOnLineBreak: false },

		},
	]);
	console.log(editor)
}, 3000)
Reproduction Steps

3 seconds after the editor was loaded, I added a decorator ("age"), and then I withdrew (ctrl+z), and the original "age" in the editor changed to "123".

  1. open url
  2. wait a few seconds
  3. undo when editor content changes
Actual (Problematic) Behavior

The content of the decorator has changed

Expected Behavior

after the retraction, the decorator content is normal.

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

Use the linked Monaco Editor Playground and its executeEdits/createDecorationsCollection setup as the entry point; reproduce the Ctrl+Z case where the decoration covering “age” displays “123”. Trace how undo updates decoration ranges and content, and consider the issue complete when the decoration still covers the intended text after undo.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.