mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-01 14:01:38 +01:00
[php] use textToMarkedString for descriptions in hover
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import {HoverProvider, Hover, MarkedString, TextDocument, CancellationToken, Position} from 'vscode';
|
||||
import phpGlobals = require('./phpGlobals');
|
||||
import { textToMarkedString } from './utils/markedTextUtil';
|
||||
|
||||
export default class PHPHoverProvider implements HoverProvider {
|
||||
|
||||
@@ -21,7 +22,7 @@ export default class PHPHoverProvider implements HoverProvider {
|
||||
var entry = phpGlobals.globalfunctions[name] || phpGlobals.compiletimeconstants[name] || phpGlobals.globalvariables[name] || phpGlobals.keywords[name];
|
||||
if (entry && entry.description) {
|
||||
let signature = name + (entry.signature || '');
|
||||
let contents: MarkedString[] = [entry.description, { language: 'php', value: signature }];
|
||||
let contents: MarkedString[] = [ textToMarkedString(entry.description), { language: 'php', value: signature }];
|
||||
return new Hover(contents, wordRange);
|
||||
}
|
||||
}
|
||||
|
||||
11
extensions/php/src/features/utils/markedTextUtil.ts
Normal file
11
extensions/php/src/features/utils/markedTextUtil.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {MarkedString} from 'vscode';
|
||||
|
||||
export function textToMarkedString(text: string) : MarkedString {
|
||||
return text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
||||
}
|
||||
Reference in New Issue
Block a user