Skip to content

Commit 0e2d1c5

Browse files
bpaseroCopilot
andauthored
Sessions goes black on Reload (fix #305568) (#306742)
* Sessions goes black on Reload (fix #305568) * Update src/vs/sessions/electron-browser/sessions.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * ccr --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e98b050 commit 0e2d1c5

1 file changed

Lines changed: 45 additions & 6 deletions

File tree

src/vs/sessions/electron-browser/sessions.ts

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,48 @@
2525
function showSplash(configuration: INativeWindowConfiguration) {
2626
performance.mark('code/willShowPartsSplash');
2727

28-
const baseTheme = 'vs-dark';
29-
const shellBackground = '#191A1B';
30-
const shellForeground = '#CCCCCC';
28+
let data = configuration.partsSplash;
29+
if (data) {
30+
if (configuration.autoDetectHighContrast && configuration.colorScheme.highContrast) {
31+
if ((configuration.colorScheme.dark && data.baseTheme !== 'hc-black') || (!configuration.colorScheme.dark && data.baseTheme !== 'hc-light')) {
32+
data = undefined; // high contrast mode has been turned by the OS -> ignore stored colors and layouts
33+
}
34+
} else if (configuration.autoDetectColorScheme) {
35+
if ((configuration.colorScheme.dark && data.baseTheme !== 'vs-dark') || (!configuration.colorScheme.dark && data.baseTheme !== 'vs')) {
36+
data = undefined; // OS color scheme is tracked and has changed
37+
}
38+
}
39+
}
40+
41+
// minimal color configuration (works with or without persisted data)
42+
let baseTheme = 'vs-dark';
43+
let shellBackground = '#1E1E1E';
44+
let shellForeground = '#CCCCCC';
45+
if (data) {
46+
baseTheme = data.baseTheme;
47+
shellBackground = data.colorInfo.editorBackground ?? data.colorInfo.background;
48+
shellForeground = data.colorInfo.foreground ?? shellForeground;
49+
} else if (configuration.autoDetectHighContrast && configuration.colorScheme.highContrast) {
50+
if (configuration.colorScheme.dark) {
51+
baseTheme = 'hc-black';
52+
shellBackground = '#000000';
53+
shellForeground = '#FFFFFF';
54+
} else {
55+
baseTheme = 'hc-light';
56+
shellBackground = '#FFFFFF';
57+
shellForeground = '#000000';
58+
}
59+
} else if (configuration.autoDetectColorScheme) {
60+
if (configuration.colorScheme.dark) {
61+
baseTheme = 'vs-dark';
62+
shellBackground = '#1E1E1E';
63+
shellForeground = '#CCCCCC';
64+
} else {
65+
baseTheme = 'vs';
66+
shellBackground = '#FFFFFF';
67+
shellForeground = '#000000';
68+
}
69+
}
3170

3271
// Apply base colors
3372
const style = document.createElement('style');
@@ -36,13 +75,13 @@
3675
style.textContent = `body { background-color: ${shellBackground}; color: ${shellForeground}; margin: 0; padding: 0; }`;
3776

3877
// Set zoom level from splash data if available
39-
if (typeof configuration.partsSplash?.zoomLevel === 'number' && typeof preloadGlobals?.webFrame?.setZoomLevel === 'function') {
40-
preloadGlobals.webFrame.setZoomLevel(configuration.partsSplash.zoomLevel);
78+
if (typeof data?.zoomLevel === 'number' && typeof preloadGlobals?.webFrame?.setZoomLevel === 'function') {
79+
preloadGlobals.webFrame.setZoomLevel(data.zoomLevel);
4180
}
4281

4382
const splash = document.createElement('div');
4483
splash.id = 'monaco-parts-splash';
45-
splash.className = baseTheme;
84+
splash.className = baseTheme ?? 'vs-dark';
4685

4786
window.document.body.appendChild(splash);
4887

0 commit comments

Comments
 (0)