Skip to content

Commit 0ecc79b

Browse files
authored
ensure the windowConfig window dimensions uses inherit (#7511) (#7531)
Cherry-picked from #7511. - a follow-up to #7440 to address - #3303 - #6277
1 parent f2453d0 commit 0ecc79b

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

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

+28-2
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)