@@ -11,7 +11,7 @@ import { EditorViewColumn } from 'vs/workbench/api/shared/editor';
1111import { IDecorationOptions , IThemeDecorationRenderOptions , IDecorationRenderOptions , IContentDecorationRenderOptions } from 'vs/editor/common/editorCommon' ;
1212import { EndOfLineSequence , TrackedRangeStickiness } from 'vs/editor/common/model' ;
1313import * as vscode from 'vscode' ;
14- import { URI } from 'vs/base/common/uri' ;
14+ import { URI , UriComponents } from 'vs/base/common/uri' ;
1515import { ProgressLocation as MainProgressLocation } from 'vs/platform/progress/common/progress' ;
1616import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles' ;
1717import { IPosition } from 'vs/editor/common/core/position' ;
@@ -25,6 +25,8 @@ import { ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/ed
2525import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumentsAndEditors' ;
2626import { isString , isNumber } from 'vs/base/common/types' ;
2727import * as marked from 'vs/base/common/marked/marked' ;
28+ import { parse } from 'vs/base/common/marshalling' ;
29+ import { cloneAndChange } from 'vs/base/common/objects' ;
2830
2931export interface PositionLike {
3032 line : number ;
@@ -227,7 +229,9 @@ export namespace MarkdownString {
227229 let renderer = new marked . Renderer ( ) ;
228230 renderer . image = renderer . link = ( href : string ) : string => {
229231 try {
230- res . uris [ href ] = URI . parse ( href , true ) ;
232+ let uri = URI . parse ( href , true ) ;
233+ uri = uri . with ( { query : _uriMassage ( uri . query , res . uris ) } ) ;
234+ res . uris [ href ] = uri ;
231235 } catch ( e ) {
232236 // ignore
233237 }
@@ -238,6 +242,31 @@ export namespace MarkdownString {
238242 return res ;
239243 }
240244
245+ function _uriMassage ( part : string , bucket : { [ n : string ] : UriComponents } ) : string {
246+ if ( ! part ) {
247+ return part ;
248+ }
249+ let data : any ;
250+ try {
251+ data = parse ( decodeURIComponent ( part ) ) ;
252+ } catch ( e ) {
253+ // ignore
254+ }
255+ if ( ! data ) {
256+ return part ;
257+ }
258+ data = cloneAndChange ( data , value => {
259+ if ( value instanceof URI ) {
260+ let key = `__uri_${ Math . random ( ) . toString ( 16 ) . slice ( 2 , 8 ) } ` ;
261+ bucket [ key ] = value ;
262+ return key ;
263+ } else {
264+ return undefined ;
265+ }
266+ } ) ;
267+ return encodeURIComponent ( JSON . stringify ( data ) ) ;
268+ }
269+
241270 export function to ( value : htmlContent . IMarkdownString ) : vscode . MarkdownString {
242271 const ret = new htmlContent . MarkdownString ( value . value ) ;
243272 ret . isTrusted = value . isTrusted ;
0 commit comments