Skip to content

Commit 17df8dd

Browse files
authored
ensure the windowConfig window dimensions uses inherit (#7511)
## Summary - a follow-up to #7440 to address - #3303 - #6277 I'll also cherry-pick this to `main` once merged. ### Implementation We need to explicitly set the windowConfig to `window.newWindowDimensions = 'inherit'` because the default settings aren't read anywhere otherwise. Similar handling can be found in: - https://github.com/posit-dev/positron/blob/66236dbf0e9dd1739915979cdd152adc587810c6/src/vs/platform/launch/electron-main/launchMainService.ts#L159-L173 - https://github.com/posit-dev/positron/blob/83cc85cee46e2d53a1eadcb86f8cfb9704c1e5a4/src/vs/platform/windows/electron-main/windowsMainService.ts#L985-L999 ## QA Notes Please try this out on machines with different screen sizes and operating systems! Make sure you don't already have `window.newWindowDimensions = inherit` set in your user settings JSON, to ensure that the setting is pulling in our new default value instead of pulling from your user setting (...not speaking from experience or anything 😅) Please also try testing: - with no user settings that are for `window`, e.g. comment out/remove any settings that start with `window.` - with at least one user setting that is for `window`, such as `"window.openFoldersInNewWindow": "on"`
1 parent 076f4fb commit 17df8dd

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/vs/platform/windows/electron-main/windowsStateHandler.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ export class WindowsStateHandler extends Disposable {
269269

270270
getNewWindowState(configuration: INativeWindowConfiguration): INewWindowState {
271271
const state = this.doGetNewWindowState(configuration);
272-
const windowConfig = this.configurationService.getValue<IWindowSettings | undefined>('window');
272+
// --- Start Positron ---
273+
// const windowConfig = this.configurationService.getValue<IWindowSettings | undefined>('window');
274+
const windowConfig = this.getWindowSettingsConfig();
275+
// --- End Positron --
273276

274277
// Fullscreen state gets special treatment
275278
if (state.mode === WindowMode.Fullscreen) {
@@ -385,7 +388,10 @@ export class WindowsStateHandler extends Disposable {
385388
state.y = Math.round(displayToUse.bounds.y + (displayToUse.bounds.height / 2) - (state.height! / 2));
386389

387390
// Check for newWindowDimensions setting and adjust accordingly
388-
const windowConfig = this.configurationService.getValue<IWindowSettings | undefined>('window');
391+
// --- Start Positron ---
392+
// const windowConfig = this.configurationService.getValue<IWindowSettings | undefined>('window');
393+
const windowConfig = this.getWindowSettingsConfig();
394+
// --- End Positron ---
389395
let ensureNoOverlap = true;
390396
if (windowConfig?.newWindowDimensions) {
391397
if (windowConfig.newWindowDimensions === 'maximized') {
@@ -418,6 +424,26 @@ export class WindowsStateHandler extends Disposable {
418424
return state;
419425
}
420426

427+
// --- Start Positron ---
428+
/**
429+
* Retrieves the window settings configuration object from the configuration service and ensures
430+
* that the newWindowDimensions property is updated with Positron's default config changes.
431+
* @returns The window settings configuration object, or undefined if it doesn't exist.
432+
*/
433+
private getWindowSettingsConfig() {
434+
const windowConfig = this.configurationService.getValue<IWindowSettings | undefined>('window');
435+
const updatedWindowConfig = {
436+
...(windowConfig ? windowConfig : {}),
437+
// We've changed the default value of newWindowDimensions to 'inherit' in Positron, so we need to
438+
// set it to 'inherit' if it unset in the config, as we'll fallthrough to the default window state otherwise.
439+
// Search for `window.newWindowDimensions` in src/vs/workbench/electron-sandbox/desktop.contribution.ts
440+
// for the default configuration.
441+
newWindowDimensions: windowConfig?.newWindowDimensions || 'inherit',
442+
};
443+
return updatedWindowConfig;
444+
}
445+
// --- End Positron ---
446+
421447
private ensureNoOverlap(state: IWindowUIState): IWindowUIState {
422448
if (this.windowsMainService.getWindows().length === 0) {
423449
return state;

0 commit comments

Comments
 (0)