gutterIconPath is string or Uri, #12111

This commit is contained in:
Johannes Rieken
2016-09-29 09:54:55 +02:00
parent c4f793759a
commit 2d1c94ab08
6 changed files with 46 additions and 8 deletions

View File

@@ -163,7 +163,7 @@ class TextEditorDecorationType implements vscode.TextEditorDecorationType {
constructor(proxy: MainThreadEditorsShape, options: vscode.DecorationRenderOptions) {
this.key = TextEditorDecorationType._Keys.nextId();
this._proxy = proxy;
this._proxy.$registerTextEditorDecorationType(this.key, options);
this._proxy.$registerTextEditorDecorationType(this.key, TypeConverters.fromDecorationRenderOptions(options));
}
public dispose(): void {

View File

@@ -12,7 +12,7 @@ import { stringDiff } from 'vs/base/common/diff/diff';
import * as modes from 'vs/editor/common/modes';
import * as types from './extHostTypes';
import { Position as EditorPosition } from 'vs/platform/editor/common/editor';
import { IPosition, ISelection, IRange, IDecorationOptions, ISingleEditOperation } from 'vs/editor/common/editorCommon';
import { IPosition, ISelection, IRange, IDecorationOptions, IDecorationRenderOptions, ISingleEditOperation } from 'vs/editor/common/editorCommon';
import { IWorkspaceSymbol } from 'vs/workbench/parts/search/common/search';
import * as vscode from 'vscode';
import URI from 'vs/base/common/uri';
@@ -155,6 +155,43 @@ export function fromRangeOrRangeWithMessage(ranges: vscode.Range[] | vscode.Deco
}
}
export function fromDecorationRenderOptions(options: vscode.DecorationRenderOptions): IDecorationRenderOptions {
const {
after,
backgroundColor, before, border, borderColor, borderRadius, borderSpacing, borderStyle, borderWidth,
color, cursor,
dark,
gutterIconPath, gutterIconSize,
isWholeLine,
letterSpacing, light,
outline, outlineColor, outlineStyle, outlineWidth, overviewRulerColor, overviewRulerLane,
textDecoration
} = options;
// properly convert the gutterIconPath to an url
let gutterIconUrl: string;
if (typeof gutterIconPath === 'string') {
gutterIconUrl = URI.file(gutterIconPath).toString();
} else if (gutterIconPath) {
// don't escape scheme-sensitive and there better don't
// escape at all, it would break http/data/etc links
gutterIconUrl = gutterIconPath.toString(true);
}
return {
after,
backgroundColor, before, border, borderColor, borderRadius, borderSpacing, borderStyle, borderWidth,
color, cursor,
dark,
gutterIconUrl, gutterIconSize,
isWholeLine,
letterSpacing, light,
outline, outlineColor, outlineStyle, outlineWidth, overviewRulerColor, overviewRulerLane,
textDecoration
};
}
export const TextEdit = {
minimalEditOperations(edits: vscode.TextEdit[], document: vscode.TextDocument, beforeDocumentVersion: number): ISingleEditOperation[] {