From 89c1c4897a4508a9562a9de0e483f29275655676 Mon Sep 17 00:00:00 2001 From: Amir Omidi Date: Tue, 24 Sep 2019 01:30:39 -0700 Subject: [PATCH] proper icon rendering (#7337) * proper icon rendering * address comments --- .../common/connectionProviderExtension.ts | 21 +++++++++---------- .../objectExplorer/browser/iconRenderer.ts | 6 +++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/sql/workbench/parts/connection/common/connectionProviderExtension.ts b/src/sql/workbench/parts/connection/common/connectionProviderExtension.ts index 531b73fed1..e1db88a832 100644 --- a/src/sql/workbench/parts/connection/common/connectionProviderExtension.ts +++ b/src/sql/workbench/parts/connection/common/connectionProviderExtension.ts @@ -11,8 +11,7 @@ import { Event, Emitter } from 'vs/base/common/event'; import { deepClone } from 'vs/base/common/objects'; import * as azdata from 'azdata'; -import * as path from 'vs/base/common/path'; -import { URI } from 'vs/base/common/uri'; +import * as resources from 'vs/base/common/resources'; export interface ConnectionProviderProperties { providerId: string; @@ -180,24 +179,24 @@ ExtensionsRegistry.registerExtensionPoint): void { if (!extension || !extension.value) { return undefined; } - let toAbsolutePath = (iconPath: any, baseDir: string) => { + let toAbsolutePath = (iconPath: any) => { if (!iconPath || !baseDir) { return; } if (Array.isArray(iconPath)) { for (let e of iconPath) { e.path = { - light: URI.file(path.join(baseDir, e.path.light)), - dark: URI.file(path.join(baseDir, e.path.dark)) + light: resources.joinPath(extension.description.extensionLocation, e.path.light), + dark: resources.joinPath(extension.description.extensionLocation, e.path.dark) }; } } else if (typeof iconPath === 'string') { iconPath = { - light: URI.file(path.join(baseDir, iconPath)), - dark: URI.file(path.join(baseDir, iconPath)) + light: resources.joinPath(extension.description.extensionLocation, iconPath), + dark: resources.joinPath(extension.description.extensionLocation, iconPath) }; } else { iconPath = { - light: URI.file(path.join(baseDir, iconPath.light)), - dark: URI.file(path.join(baseDir, iconPath.dark)) + light: resources.joinPath(extension.description.extensionLocation, iconPath.light), + dark: resources.joinPath(extension.description.extensionLocation, iconPath.dark) }; } }; @@ -206,9 +205,9 @@ function resolveIconPath(extension: IExtensionPointUser): void { let properties: ConnectionProviderProperties = extension.value; if (Array.isArray(properties)) { for (let p of properties) { - toAbsolutePath(p['iconPath'], baseDir); + toAbsolutePath(p['iconPath']); } } else { - toAbsolutePath(properties['iconPath'], baseDir); + toAbsolutePath(properties['iconPath']); } } diff --git a/src/sql/workbench/parts/objectExplorer/browser/iconRenderer.ts b/src/sql/workbench/parts/objectExplorer/browser/iconRenderer.ts index 2c8cf677fd..7b9e5be74f 100644 --- a/src/sql/workbench/parts/objectExplorer/browser/iconRenderer.ts +++ b/src/sql/workbench/parts/objectExplorer/browser/iconRenderer.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { createCSSRule } from 'vs/base/browser/dom'; +import { createCSSRule, asCSSUrl } from 'vs/base/browser/dom'; import { hash } from 'vs/base/common/hash'; import { URI } from 'vs/base/common/uri'; @@ -15,8 +15,8 @@ class IconRenderer { let iconPath: IconPath = this.toIconPath(path); let iconUid: string = this.getIconUid(iconPath); if (!this.iconRegistered.has(iconUid)) { - createCSSRule(`.icon#${iconUid}`, `background: url("${iconPath.light.toString()}") center center no-repeat`); - createCSSRule(`.vs-dark .icon#${iconUid}, .hc-black .icon#${iconUid}`, `background: url("${iconPath.dark.toString()}") center center no-repeat`); + createCSSRule(`.icon#${iconUid}`, `background: ${asCSSUrl(iconPath.light || iconPath.dark)} center center no-repeat`); + createCSSRule(`.vs-dark .icon#${iconUid}, .hc-black .icon#${iconUid}`, `background: ${asCSSUrl(iconPath.dark)} center center no-repeat`); this.iconRegistered.add(iconUid); } return iconUid;