mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
replace MarkedString with object-type IMarkdownString, #29076
This commit is contained in:
@@ -204,7 +204,7 @@ class HoverAdapter {
|
||||
|
||||
// we wanna know which extension uses command links
|
||||
// because that is a potential trick-attack on users
|
||||
if (result.contents.some(containsCommandLink)) {
|
||||
if (result.contents.some(h => containsCommandLink(h.value))) {
|
||||
this._telemetryLog('usesCommandLink', { from: 'hover' });
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -16,6 +16,7 @@ import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { ISelection } from 'vs/editor/common/core/selection';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
|
||||
export interface PositionLike {
|
||||
line: number;
|
||||
@@ -144,14 +145,17 @@ function isDecorationOptionsArr(something: vscode.Range[] | vscode.DecorationOpt
|
||||
}
|
||||
|
||||
export namespace MarkedString {
|
||||
export function from(markup: vscode.MarkedString): string {
|
||||
export function from(markup: vscode.MarkedString): IMarkdownString {
|
||||
if (typeof markup === 'string' || !markup) {
|
||||
return <string>markup;
|
||||
return { value: <string>markup, enableCommands: true };
|
||||
} else {
|
||||
const { language, value } = markup;
|
||||
return '```' + language + '\n' + value + '\n```';
|
||||
return { value: '```' + language + '\n' + value + '\n```' };
|
||||
}
|
||||
}
|
||||
export function to(value: IMarkdownString): vscode.MarkedString {
|
||||
return value.value;
|
||||
}
|
||||
}
|
||||
|
||||
export function fromRangeOrRangeWithMessage(ranges: vscode.Range[] | vscode.DecorationOptions[]): IDecorationOptions[] {
|
||||
@@ -272,7 +276,7 @@ export function fromHover(hover: vscode.Hover): modes.Hover {
|
||||
}
|
||||
|
||||
export function toHover(info: modes.Hover): types.Hover {
|
||||
return new types.Hover(info.contents, toRange(info.range));
|
||||
return new types.Hover(info.contents.map(MarkedString.to), toRange(info.range));
|
||||
}
|
||||
|
||||
export function toDocumentHighlight(occurrence: modes.DocumentHighlight): types.DocumentHighlight {
|
||||
|
||||
Reference in New Issue
Block a user