extensions: Ensure extensions that no longer match the action events are deactivated
Created by: philipp-spiess
Fixes #28973 (closed)
Right now, when different language-triggered extensions are activated, they stay active as long as the browser session is open. This means that a hover action exported in an extension that activates onLanguage:x
will still be active even though we might no longer be on a document with language x
. This is causes some actions to be omitted multiple times, c.f. #28973 (closed):
There are several ideas I have to fix this. For example we could make sure that all exported actions also undergo the onLanguage:
check if they are exported from an extension that activates on a specific language. A simpler solution is to disable extensions that no longer match, which is what I am doing in this PR.
Regression Test
Switching from a Rust to a Go file now only shows one Find implementation button:
https://user-images.githubusercontent.com/458591/149927478-20ca5d10-6f8d-4297-b4b1-faf80da38a67.mov
Open Questions
- Are there any memory/perf implications of this? I imagine a user that often switches between two languages might be running into issues. How do I verify this?
- Are there any side effects of activating the same extension multiple times? A quick check by jumping from Go -> Rust -> Go indicates that everything works fine.
- How do I properly test these changes?
action.test.ts
looks pretty confusing with all the mocking but even when I add telemetry (so I can spy on it) and try to callactivateExtensions
again with no active extensions, I won't observe a deactivation. If you think this approach makes sense I am happy to investigate further.