Skip to content

Commit 67ca578

Browse files
committed
fix: infinite extension host restarting until window is reloaded (only when overrideActivationEvents is used & first time applied)
1 parent 7fd951f commit 67ca578

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/extension.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const activate = async () => {
7878

7979
// Main activation actions
8080

81-
let reloadExtHostExtensions = false
81+
let patchedManifestExtensions = [] as string[]
8282
for (const [id, expected] of Object.entries(getExtensionSetting('overrideActivationEvents'))) {
8383
const ext = vscode.extensions.getExtension(id)
8484
if (!ext) continue
@@ -96,19 +96,25 @@ export const activate = async () => {
9696
4,
9797
),
9898
)
99-
reloadExtHostExtensions = true
99+
patchedManifestExtensions.push(id)
100100
}
101101
}
102-
if (reloadExtHostExtensions) {
103-
vscode.window.showInformationMessage('Restarting extension host as activation events were patched...')
104-
await vscode.commands.executeCommand('workbench.action.restartExtensionHost')
105-
return
102+
if (patchedManifestExtensions.length) {
103+
const action = await vscode.window.showInformationMessage(
104+
`Manifest of these extension were patched: ${patchedManifestExtensions}`,
105+
'Reload window to apply',
106+
)
107+
if (action) {
108+
await vscode.commands.executeCommand('workbench.action.reloadWindow')
109+
return
110+
}
106111
}
107112

108113
const extVersion = extensionCtx.extension.packageJSON.version
109114
const currentLoadedConfig = process.env.VSC_CONTROL_EXT_CONFIG && JSON.parse(process.env.VSC_CONTROL_EXT_CONFIG)
110115
const patchedVersion = currentLoadedConfig?.version
111-
if (patchedVersion && patchedVersion === extVersion) {
116+
if (patchedVersion && (patchedVersion === extVersion || process.env.NODE_ENV === 'development')) {
117+
// dev: force patch here when needed
112118
if (process.env.VSC_CONTROL_EXT_CONFIG !== JSON.stringify(getNewConfig())) await updateConfig()
113119
} else {
114120
if (

0 commit comments

Comments
 (0)