microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
caa0dc5eb84731caee69a4d06915c6a3856ec289

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/common/editorColorThemesHelper.ts

30lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import * as vscode from "vscode";
5
6export enum SystemColorTheme {
7 Light = "Light",
8 Dark = "Dark",
9}
10
11export class EditorColorThemesHelper {
12 public static isAutoDetectColorSchemeEnabled(): boolean {
13 return !!vscode.workspace.getConfiguration("window").get("autoDetectColorScheme");
14 }
15
16 public static getCurrentSystemColorTheme(): SystemColorTheme {
17 if (EditorColorThemesHelper.isAutoDetectColorSchemeEnabled()) {
18 const workbenchConfiguration = vscode.workspace.getConfiguration("workbench");
19 const currentTheme = workbenchConfiguration.get("colorTheme");
20 const preferredDarkColorTheme = workbenchConfiguration.get("preferredDarkColorTheme");
21 return currentTheme === preferredDarkColorTheme
22 ? SystemColorTheme.Dark
23 : SystemColorTheme.Light;
24 } else {
25 throw new Error(
26 "Couldn't detect the current system color theme: 'window.autoDetectColorScheme' parameter is disabled",
27 );
28 }
29 }
30}
31