microsoft / microsoft/monaco-editor
Decorations are improper on undo
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 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".
- open url
- wait a few seconds
- 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
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
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