From 6afb0f477a766bf9d6781493f070ca86846afed9 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 28 Sep 2016 14:34:48 +0200 Subject: [PATCH] allow to define gutter and content icons paths as string OR uri, #12111 --- .../editor/browser/services/codeEditorServiceImpl.ts | 12 +++++++++--- src/vs/editor/common/editorCommon.ts | 4 ++-- src/vs/vscode.d.ts | 9 +++++---- src/vs/workbench/api/node/extHostTypeConverters.ts | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/vs/editor/browser/services/codeEditorServiceImpl.ts b/src/vs/editor/browser/services/codeEditorServiceImpl.ts index 9169bfce8f5..f4c295a4f09 100644 --- a/src/vs/editor/browser/services/codeEditorServiceImpl.ts +++ b/src/vs/editor/browser/services/codeEditorServiceImpl.ts @@ -301,8 +301,10 @@ class DecorationRenderHelper { if (typeof opts !== 'undefined') { DecorationRenderHelper.collectBorderSettingsCSSText(opts, cssTextArr); - if (typeof opts.contentIconPath !== 'undefined') { - cssTextArr.push(strings.format(this._CSS_MAP.contentIconPath, URI.parse(opts.contentIconPath).toString())); + if (typeof opts.contentIconPath === 'string') { + cssTextArr.push(strings.format(this._CSS_MAP.contentIconPath, URI.file(opts.contentIconPath).toString())); + } else if(opts.contentIconPath instanceof URI) { + cssTextArr.push(strings.format(this._CSS_MAP.contentIconPath, opts.contentIconPath.toString())); } if (typeof opts.contentText !== 'undefined') { let escaped = opts.contentText.replace(/\"/g, '\\\"'); @@ -324,7 +326,11 @@ class DecorationRenderHelper { let cssTextArr = []; if (typeof opts.gutterIconPath !== 'undefined') { - cssTextArr.push(strings.format(this._CSS_MAP.gutterIconPath, URI.parse(opts.gutterIconPath).toString())); + if (typeof opts.gutterIconPath === 'string') { + cssTextArr.push(strings.format(this._CSS_MAP.gutterIconPath, URI.file(opts.gutterIconPath).toString())); + } else { + cssTextArr.push(strings.format(this._CSS_MAP.gutterIconPath, opts.gutterIconPath.toString())); + } if (typeof opts.gutterIconSize !== 'undefined') { cssTextArr.push(strings.format(this._CSS_MAP.gutterIconSize, opts.gutterIconSize)); } diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 3dac506d42b..f64c674ec54 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -3788,7 +3788,7 @@ export interface IThemeDecorationRenderOptions { color?: string; letterSpacing?: string; - gutterIconPath?: string; + gutterIconPath?: string | URI; gutterIconSize?: string; overviewRulerColor?: string; @@ -3802,7 +3802,7 @@ export interface IThemeDecorationRenderOptions { */ export interface IContentDecorationRenderOptions { contentText?: string; - contentIconPath?: string; + contentIconPath?: string | URI; border?: string; textDecoration?: string; diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index f80a8ea9088..6a310d6f2be 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -782,9 +782,10 @@ declare namespace vscode { letterSpacing?: string; /** - * An **absolute path** to an image to be rendered in the gutterIconPath. + * An **absolute path** to an image to be rendered in the gutterIconPath or + * an URI. */ - gutterIconPath?: string; + gutterIconPath?: string | Uri; /** * Specifies the size of the gutter icon. @@ -815,9 +816,9 @@ declare namespace vscode { */ contentText?: string; /** - * An **absolute path** to an image to be rendered in the attachment. Either an icon or a text can be shown, but not both. + * An **absolute path** to an image to be rendered in the attachment or an URI. Either an icon or a text can be shown, but not both. */ - contentIconPath?: string; + contentIconPath?: string | Uri; /** * CSS styling property that will be applied to the decoration attachment. */ diff --git a/src/vs/workbench/api/node/extHostTypeConverters.ts b/src/vs/workbench/api/node/extHostTypeConverters.ts index 9aebafecfb2..b81f07900a3 100644 --- a/src/vs/workbench/api/node/extHostTypeConverters.ts +++ b/src/vs/workbench/api/node/extHostTypeConverters.ts @@ -143,7 +143,7 @@ export function fromRangeOrRangeWithMessage(ranges: vscode.Range[] | vscode.Deco return { range: fromRange(r.range), hoverMessage: r.hoverMessage, - renderOptions: r.renderOptions + renderOptions: /* URI vs Uri*/ r.renderOptions }; }); } else { -- GitLab