Skip to content

Commit

Permalink
fix: infinite extension host restarting until window is reloaded (onl…
Browse files Browse the repository at this point in the history
…y when `overrideActivationEvents` is used & first time applied)
  • Loading branch information
zardoy committed Apr 26, 2023
1 parent 7fd951f commit 67ca578
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const activate = async () => {

// Main activation actions

let reloadExtHostExtensions = false
let patchedManifestExtensions = [] as string[]
for (const [id, expected] of Object.entries(getExtensionSetting('overrideActivationEvents'))) {
const ext = vscode.extensions.getExtension(id)
if (!ext) continue
Expand All @@ -96,19 +96,25 @@ export const activate = async () => {
4,
),
)
reloadExtHostExtensions = true
patchedManifestExtensions.push(id)
}
}
if (reloadExtHostExtensions) {
vscode.window.showInformationMessage('Restarting extension host as activation events were patched...')
await vscode.commands.executeCommand('workbench.action.restartExtensionHost')
return
if (patchedManifestExtensions.length) {
const action = await vscode.window.showInformationMessage(
`Manifest of these extension were patched: ${patchedManifestExtensions}`,
'Reload window to apply',
)
if (action) {
await vscode.commands.executeCommand('workbench.action.reloadWindow')
return
}
}

const extVersion = extensionCtx.extension.packageJSON.version
const currentLoadedConfig = process.env.VSC_CONTROL_EXT_CONFIG && JSON.parse(process.env.VSC_CONTROL_EXT_CONFIG)
const patchedVersion = currentLoadedConfig?.version
if (patchedVersion && patchedVersion === extVersion) {
if (patchedVersion && (patchedVersion === extVersion || process.env.NODE_ENV === 'development')) {
// dev: force patch here when needed
if (process.env.VSC_CONTROL_EXT_CONFIG !== JSON.stringify(getNewConfig())) await updateConfig()
} else {
if (
Expand Down

0 comments on commit 67ca578

Please sign in to comment.