eclipse-theia/theia

Lazily Create Monaco Models in Resource Preference Providers

Open

#7,426 opened on Mar 26, 2020

View on GitHub
 (4 comments) (0 reactions) (0 assignees)TypeScript (18,676 stars) (2,478 forks)batch import
enhancementhelp wantedmonacopreferences

Description

For a while now, AbstractResourcePreferenceProvider has used monaco editor models to manage the contents of settings files. This creates a circular dependency, because the editor model waits for preferences to be ready and preferences can't be read before the editor model is created. While this seems to work, I think it would be better if we would apply the following changes:

  1. Read the file contents directly from the file initially. Only signal "ready" once the file contents have been read
  2. Create a monaco model on demand, that is when opening an editor or when setting a preference programatically. Once we have the model, we can keep it just like now.

Opening an editor will create a model, which will wait for preferences to be ready. I also would setting a preference before the preferences provider is ready to be a programming error to be rejected.

Contributor guide