[php] use textToMarkedString for descriptions in hover

This commit is contained in:
Martin Aeschlimann
2016-09-07 16:24:31 +02:00
parent 757650b26e
commit d6f897fd35
2 changed files with 13 additions and 1 deletions

View File

@@ -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);
}
}

View 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
}