diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index e1999859678..029aa27b95f 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -189,6 +189,23 @@ export class CodeWindow implements ICodeWindow { this._win = new BrowserWindow(options); this._id = this._win.id; + // TODO@Ben Bug in Electron (https://github.com/electron/electron/issues/10862). On multi-monitor setups, + // it can happen that the position we set to the window is not the correct one on the display. + // To workaround, we ask the window for its position and set it again if not matching. + // This only applies if the window is not fullscreen or maximized and multiple monitors are used. + if (isWindows && !isFullscreenOrMaximized) { + try { + if (screen.getAllDisplays().length > 1) { + const [x, y] = this._win.getPosition(); + if (x !== this.windowState.x || y !== this.windowState.y) { + this._win.setPosition(x, y, false); + } + } + } catch (err) { + this.logService.log(`Unexpected error fixing window position on windows with multiple windows: ${err}\n${err.stack}`); + } + } + if (useCustomTitleStyle) { this._win.setSheetOffset(22); // offset dialogs by the height of the custom title bar if we have any }