diff --git a/extensions/css/client/src/cssMain.ts b/extensions/css/client/src/cssMain.ts index 3e0ba970b0d..c8d307d9732 100644 --- a/extensions/css/client/src/cssMain.ts +++ b/extensions/css/client/src/cssMain.ts @@ -70,7 +70,7 @@ export function activate(context: ExtensionContext) { }); }); }, - provideColorPresentations(colorInfo: ColorInformation): ColorPresentation[] | Thenable { + provideColorPresentations(document: TextDocument, colorInfo: ColorInformation): ColorPresentation[] | Thenable { let result: ColorPresentation[] = []; let color = colorInfo.color; let label; diff --git a/extensions/html/client/src/htmlMain.ts b/extensions/html/client/src/htmlMain.ts index 627f771f7d1..39bf0e1a468 100644 --- a/extensions/html/client/src/htmlMain.ts +++ b/extensions/html/client/src/htmlMain.ts @@ -87,7 +87,7 @@ export function activate(context: ExtensionContext) { }); }); }, - provideColorPresentations(colorInfo: ColorInformation): ColorPresentation[] | Thenable { + provideColorPresentations(document: TextDocument, colorInfo: ColorInformation): ColorPresentation[] | Thenable { let result: ColorPresentation[] = []; let color = colorInfo.color; let label; diff --git a/extensions/json/client/src/jsonMain.ts b/extensions/json/client/src/jsonMain.ts index 6a06b7bcbb9..8ffdb77d52d 100644 --- a/extensions/json/client/src/jsonMain.ts +++ b/extensions/json/client/src/jsonMain.ts @@ -132,7 +132,7 @@ export function activate(context: ExtensionContext) { }); }); }, - provideColorPresentations(colorInfo: ColorInformation): ColorPresentation[] | Thenable { + provideColorPresentations(document: TextDocument, colorInfo: ColorInformation): ColorPresentation[] | Thenable { let result: ColorPresentation[] = []; let color = colorInfo.color; let label; diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index 9c01e6aaafb..a67046cf0e4 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -728,7 +728,7 @@ export interface DocumentColorProvider { /** * Provide the string representations for a color. */ - provideColorPresentations(colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; + provideColorPresentations(model: editorCommon.IReadOnlyModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; } export interface IResourceEdit { diff --git a/src/vs/editor/contrib/colorPicker/common/color.ts b/src/vs/editor/contrib/colorPicker/common/color.ts index d85a0375ba3..14309923337 100644 --- a/src/vs/editor/contrib/colorPicker/common/color.ts +++ b/src/vs/editor/contrib/colorPicker/common/color.ts @@ -27,6 +27,6 @@ export function getColors(model: IReadOnlyModel): TPromise { return TPromise.join(promises).then(() => colors); } -export function getColorPresentations(colorInfo: IColorInformation, provider: DocumentColorProvider): TPromise { - return asWinJsPromise(token => provider.provideColorPresentations(colorInfo, token)); +export function getColorPresentations(model: IReadOnlyModel, colorInfo: IColorInformation, provider: DocumentColorProvider): TPromise { + return asWinJsPromise(token => provider.provideColorPresentations(model, colorInfo, token)); } diff --git a/src/vs/editor/contrib/hover/browser/modesContentHover.ts b/src/vs/editor/contrib/hover/browser/modesContentHover.ts index 0e0ea6df661..acd18602e01 100644 --- a/src/vs/editor/contrib/hover/browser/modesContentHover.ts +++ b/src/vs/editor/contrib/hover/browser/modesContentHover.ts @@ -325,7 +325,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget { const model = new ColorPickerModel(color, [], 0); const widget = new ColorPickerWidget(fragment, model, this._editor.getConfiguration().pixelRatio); - getColorPresentations(colorInfo, msg.provider).then(colorPresentations => { + getColorPresentations(editorModel, colorInfo, msg.provider).then(colorPresentations => { model.colorPresentations = colorPresentations; const originalText = this._editor.getModel().getValueInRange(msg.range); model.guessColorPresentation(color, originalText); @@ -360,7 +360,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget { }; const updateColorPresentations = (color: Color) => { - return getColorPresentations({ + return getColorPresentations(editorModel, { range: range, color: { red: color.rgba.r / 255, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 8be006d7a8c..09311d8c968 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -4904,7 +4904,7 @@ declare module monaco.languages { /** * Provide the string representations for a color. */ - provideColorPresentations(colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; + provideColorPresentations(model: editor.IReadOnlyModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; } export interface IResourceEdit { diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 42f021d9f85..6ed9537d1b6 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -222,7 +222,7 @@ declare module 'vscode' { /** * Provide representations for a color. */ - provideColorPresentations(colorInfo: ColorInformation, token: CancellationToken): ProviderResult; + provideColorPresentations(document: TextDocument, colorInfo: ColorInformation, token: CancellationToken): ProviderResult; } export namespace languages { diff --git a/src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts b/src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts index 6e9cb4f1961..525ded68a57 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts @@ -306,8 +306,8 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha }); }, - provideColorPresentations: (colorInfo, token) => { - return wireCancellationToken(token, proxy.$provideColorPresentations(handle, { + provideColorPresentations: (model, colorInfo, token) => { + return wireCancellationToken(token, proxy.$provideColorPresentations(handle, model.uri, { color: [colorInfo.color.red, colorInfo.color.green, colorInfo.color.blue, colorInfo.color.alpha], range: colorInfo.range })); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index e71bcb49058..8c981201c27 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -559,7 +559,7 @@ export interface ExtHostLanguageFeaturesShape { $provideDocumentLinks(handle: number, resource: URI): TPromise; $resolveDocumentLink(handle: number, link: modes.ILink): TPromise; $provideDocumentColors(handle: number, resource: URI): TPromise; - $provideColorPresentations(handle: number, colorInfo: IRawColorInfo): TPromise; + $provideColorPresentations(handle: number, resource: URI, colorInfo: IRawColorInfo): TPromise; } export interface ExtHostQuickOpenShape { diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index 6b4bfc769aa..a6733cc7695 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -729,7 +729,7 @@ class ColorProviderAdapter { }); } - provideColorPresentations(rawColorInfo: IRawColorInfo): TPromise { + provideColorPresentations(resource: URI, rawColorInfo: IRawColorInfo): TPromise { let colorInfo: vscode.ColorInformation = { range: TypeConverters.toRange(rawColorInfo.range), color: { @@ -739,7 +739,8 @@ class ColorProviderAdapter { alpha: rawColorInfo.color[3] } }; - return asWinJsPromise(token => this._provider.provideColorPresentations(colorInfo, token)).then(value => { + const doc = this._documents.getDocumentData(resource).document; + return asWinJsPromise(token => this._provider.provideColorPresentations(doc, colorInfo, token)).then(value => { return value.map(v => TypeConverters.ColorPresentation.from(v)); }); } @@ -1053,8 +1054,8 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape { return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.provideColors(resource)); } - $provideColorPresentations(handle: number, colorInfo: IRawColorInfo): TPromise { - return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.provideColorPresentations(colorInfo)); + $provideColorPresentations(handle: number, resource: URI, colorInfo: IRawColorInfo): TPromise { + return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.provideColorPresentations(resource, colorInfo)); } // --- configuration