microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.28k stars 28.57k forks source link

Extension Development: View Name/Id Guidelines #224590

Open Jason3S opened 1 month ago

Jason3S commented 1 month ago

With the latest vscode-insiders, No view is registered with id: cspell.issuesViewByFile started showing up. The 4.0.5 version of the Code Spell Checker extension works just fine with 1.92.0, but breaks with Version: 1.93.0-insider Commit: 3b27f1f74bc09fe2e2068997fcd42768be44a4e3. The issue is with the . in the ID. I would consider the breakage to be a bug in vscode-insiders, since there previously had been no checks in VSCode for proper formatted view IDs. But the underlying cause was a lack of documentation / guidelines.

As the developer of Code Spell Checker Extension (or any other extension), I would like guidance on the suggested naming convention for contribution points: https://code.visualstudio.com/api/references/contribution-points#contributes.views

With better documentation, hopefully the breakage could have been avoided.

Kind Regards, Jason

Jason3S commented 1 month ago

I think No view is registered with id: cspell.issuesViewByFile might be caused by a race condition. I just saw it when I installed the latest version of Code Spell Checker v4.0.6 in 1.92.0. Something about the way the Extension Host is restarted seems to have changed.

The extension first starts the LSP client before registering some views because it needs access to the client. I'll try and change the order to register views as soon as possible. Even so, it is an async function, so there is always a chance of a race condition if the views are expected to exist before the activate resolves.

export async function activate(context: ExtensionContext): Promise<ExtensionApi>