From 4e68ba25fbc752e3d7da488b8d3db374029577d6 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Sat, 16 Feb 2019 09:32:11 +0100 Subject: [PATCH] [themes] fix integration test on Windows --- .../services/themes/browser/colorThemeData.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/services/themes/browser/colorThemeData.ts b/src/vs/workbench/services/themes/browser/colorThemeData.ts index 3d4401e05f8..0f0f33b306d 100644 --- a/src/vs/workbench/services/themes/browser/colorThemeData.ts +++ b/src/vs/workbench/services/themes/browser/colorThemeData.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { toSlashes } from 'vs/base/common/extpath'; import { basename } from 'vs/base/common/path'; import * as Json from 'vs/base/common/json'; import { Color } from 'vs/base/common/color'; @@ -21,6 +20,7 @@ import { getParseErrorMessage } from 'vs/base/common/jsonErrorMessages'; import { URI } from 'vs/base/common/uri'; import { IFileService } from 'vs/platform/files/common/files'; import { parse as parsePList } from 'vs/workbench/services/themes/common/plistParser'; +import { startsWith } from 'vs/base/common/strings'; let colorRegistry = Registry.as(Extensions.ColorContribution); @@ -259,8 +259,7 @@ export class ColorThemeData implements IColorTheme { static fromExtensionTheme(theme: IThemeExtensionPoint, colorThemeLocation: URI, extensionData: ExtensionData): ColorThemeData { let baseTheme: string = theme['uiTheme'] || 'vs-dark'; - - let themeSelector = toCSSSelector(extensionData.extensionId + '-' + toSlashes(theme.path)); + let themeSelector = toCSSSelector(extensionData.extensionId, theme.path); let themeData = new ColorThemeData(); themeData.id = `${baseTheme} ${themeSelector}`; themeData.label = theme.label || basename(theme.path); @@ -274,7 +273,13 @@ export class ColorThemeData implements IColorTheme { } } -function toCSSSelector(str: string) { +function toCSSSelector(extensionId: string, path: string) { + if (startsWith(path, './')) { + path = path.substr(2); + } + let str = `${extensionId}-${path}`; + + //remove all characters that are not allowed in css str = str.replace(/[^_\-a-zA-Z0-9]/g, '-'); if (str.charAt(0).match(/[0-9\-]/)) { str = '_' + str; -- GitLab