microsoft / microsoft/monaco-editor

[Bug] StorageService override doesn't see the onDidChangeValue function

Open
#4,829 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?
Description

In version 0.41.0 this works. But after upgrade to the latest 0.52.2 it does't.
After some investigation I can see that versions > 0.41.0 gives error in console but not breaking an app and versions > 0.48.0 started to break an app.
It's reproducible in the playground. Try please.

I tried to debug it in the browser and I see that on the error line I have _storageService.onDidChangeValue and it's defined as function, but it still throws an error.

Image
Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `function hello() {
	alert('Hello world!');
}`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "javascript",
	automaticLayout: true,
}, {
      // Note: Overrides inner editor UI configuration
      storageService: {
        get() {},
        getBoolean(key) {
          // Note: This config is to show property description on property selection automatically
          if (key === "expandSuggestionDocs") return true;
          return false;
        },
        remove(){},
        store(){},
        onWillSaveState(){},
        onDidChangeStorage(){},
        onDidChangeValue(){}
      }
    });
Reproduction Steps

Just refresh. Error will be from start.

Actual (Problematic) Behavior

TypeError: _storageService.onDidChangeValue(...) is not a function: undefined

Expected Behavior

No error

Additional Context

I am trying to override storage service to show property description on property selection automatically. This workaround was helpful in the old 0.41.0 version

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 Monaco Editor playground and the provided storageService override, then trace where onDidChangeValue is consumed after the editor is created. Done means refreshing the playground with the override no longer throws the reported TypeError in current versions.

Written by the indexing model from the issue text.

Assessment

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