#8815 introduced LS caching and ref counting, such that the interactive window can reference the same language server as the regular code and keep it around until it's no longer needed. The keys are resource scoped, which are good for ensuring things are shared and the minimum number of LSs are spawned.
Unfortunately, the activeServer and resource properties are essentially "globals" to the extension as a whole. The current code kills LSs as the user moves around different files to save resources, however this breaks multi-root workspaces which rely on being able to navigate around and still get code completions. (e.g., I open two files, one in each workspace, and switch between them)
Additionally, I believe the current code over-disposes, leading to a scenario where on the first active LS change, the next spawned server cannot be killed and isn't configured correctly, leading both to #5132 (comment) and a related bug where the next-spawned server's interpreter doesn't change.
The solution here is to eliminate activeServer and resource and make LSs fully resource-scoped (only accessible by key). Once a LS is no longer referenced (no handles from the interactive window, and its workspace no longer exists), the LS can be thrown away.
#8815 introduced LS caching and ref counting, such that the interactive window can reference the same language server as the regular code and keep it around until it's no longer needed. The keys are resource scoped, which are good for ensuring things are shared and the minimum number of LSs are spawned.
Unfortunately, the
activeServerandresourceproperties are essentially "globals" to the extension as a whole. The current code kills LSs as the user moves around different files to save resources, however this breaks multi-root workspaces which rely on being able to navigate around and still get code completions. (e.g., I open two files, one in each workspace, and switch between them)Additionally, I believe the current code over-disposes, leading to a scenario where on the first active LS change, the next spawned server cannot be killed and isn't configured correctly, leading both to #5132 (comment) and a related bug where the next-spawned server's interpreter doesn't change.
The solution here is to eliminate
activeServerandresourceand make LSs fully resource-scoped (only accessible by key). Once a LS is no longer referenced (no handles from the interactive window, and its workspace no longer exists), the LS can be thrown away.