Skip to content

[Bug] How to remove the previous decorations permanently ? #4840

Open
@naganand123

Description

@naganand123

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions