tgjones / HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files
http://timjones.io/blog/archive/2016/04/25/hlsl-tools-for-visual-studio-v1.0-released
Other
553 stars 95 forks source link

Deactivate VSCode extension asynchronously #252

Closed cgavalos closed 11 months ago

cgavalos commented 1 year ago

Description

When using HLSL Tools on MacOS, orphaned ShaderTools.LanguageServer processes will accumulate, wasting memory. This happens after closing and opening VSCode repeatedly. This does not appear to happen on Windows in my experience.

https://github.com/microsoft/vscode/issues/35196#issuecomment-334399348

The above GitHub issue details other developers' experiences with the same problem. The solution presented by dbaeumer was to return a Promise from an exported deactivate().

https://code.visualstudio.com/api/references/activation-events#Start-up

This is confirmed by the above VSCode docs. Extensions with asynchronous cleanup processes must return a Promise from their deactivate(). As LanguageServerClient.stop() returns a Promise, we are obligated to return it when deactivating.

Testing

Tested by copying compilation results from main.ts and session.ts into the existing .vscode/extensions extension folder.

tgjones commented 11 months ago

Thank you!