microsoft / VSSDK-Extensibility-Samples

Samples for building your own Visual Studio extensions
http://aka.ms/extendvs
MIT License
1.22k stars 452 forks source link

Settings ILanguageClient impossible to get #270

Open guillaume-kotulski opened 1 year ago

guillaume-kotulski commented 1 year ago

Installed products

Description

Cannot get the settings from the ILanguageClient

Steps to recreate

  1. Create an extension for LSP
public class LanguageClient : AsyncPackage, ILanguageClient
    {

        public async Task<Connection> ActivateAsync(CancellationToken token)
        {
           ...
        }

        public async Task OnLoadedAsync()
        {

            Config page = (Config)GetDialogPage(typeof(Config));
            _path = page.OptionPath;
            if (_path != null && _path != "")
            {
                await StartAsync.InvokeAsync(this, EventArgs.Empty);
            }
        }

        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            Config page = (Config)GetDialogPage(typeof(Config));

            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
        }

Current behavior

The Page "Config" does exist but impossible to get it from the OnLoadedAsync I always obtain the default values. But if I go directly to the settings InitializeAsync is called with the settings. InitializeAsync is called only when we go in the settings ?

Expected behavior

Should get the settings.