microsoft / microsoft/monaco-editor
[Bug] How to remove the previous decorations permanently ?
Open
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
No response
Monaco Editor Playground Code
goToRefSelection(range: any, editorInstance: ICodeEditor) {
editorInstance.focus();
let decorationsCollection = editorInstance.createDecorationsCollection();
const decorations = [{
range: new monaco.Range(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn),
options: {
inlineClassName: 'go-to-definition-highlight',
},
}];
decorationsCollection.set(decorations);
setTimeout(() => {
decorationsCollection.clear();
decorationsCollection = null;
decorationsCollection.set([]);
}, 5000);
}
Reproduction Steps
No response
Actual (Problematic) Behavior
after some duration removing the decoration, but when I call this method next with new decoration, previous decoration is also applying.
Expected Behavior
Need to removing the previous decorations and apply the new decorations.
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
Start with the goToRefSelection method in the issue's TypeScript example and review how createDecorationsCollection, set, and clear are used across repeated calls. Reproduce the behavior by invoking the method with successive ranges; done when applying a new decoration no longer leaves the previous decoration visible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100