Change:
Since the november 2023 update steals window focus. This is really problematic because uses this to run end to end tests and now the development host window pops up for every single test case, which renders all other windows unusable while I’m running tests, as the test window steals focus many times per second. <!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.85.1 (user setup) OS Version: Windows_NT x64 10.0. Steps to Reproduce: extension host vscode main window the following code: vscode extension development host window is now focused.
We should add rules to not change focus during extension development tests.
<!-- AUTHORVERIFICATIONREQUEST --This bug has been fixed in the latest release of ! you can help us out by commenting if things are now working as expected. If things still don't seem right, please ensure you're on version of Insiders (today's or later - you can use in the command palette to check), and leave a comment letting us know what isn't working as expected. Happy Coding!
I can reproduce this: an extension that activates : 5, and immediately focus back to the VS Code window you F5'd from When executes, the ext dev host window will regain focus
Sorry, bad description: its only disabled when running extension tests.

Discussion:
const that = this; const originalWindowFocus = mainWindow.focus.bind(mainWindow); mainWindow.focus = function () { <ins> if (that.environmentService.extensionTestsLocationURI) { return; // no focus when we are running tests from CLI } </ins> originalWindowFocus(); if (!mainWindow.document.hasFocus()) {

import { ShutdownReason } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { Barrier } from 'vs/base/common/async'; <ins> import { IEnvironmentService } from 'vs/platform/environment/common/environment'; </ins> type NativeCodeWindow = CodeWindow & { readonly vscode: ISandboxGlobals;

@INativeHostService private readonly nativeHostService: INativeHostService, @IDialogService dialogService: IDialogService, @IInstantiationService private readonly instantiationService: IInstantiationService, <del> @ITelemetryService telemetryService: ITelemetryService </del> <ins> @ITelemetryService telemetryService: ITelemetryService, @IEnvironmentService private readonly environmentService: IEnvironmentService </ins> ) { super(layoutService, dialogService, configurationService, telemetryService); }

const that = this; const originalWindowFocus = auxiliaryWindow.focus.bind(auxiliaryWindow); auxiliaryWindow.focus = function () { <ins> if (that.environmentService.extensionTestsLocationURI) { return; // no focus when we are running tests from CLI } </ins> originalWindowFocus(); if (!auxiliaryWindow.document.hasFocus()) {