File tree Expand file tree Collapse file tree
workbench/browser/parts/views Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6+ import { memoize } from 'vs/base/common/decorators' ;
7+
68export interface ILink {
79 readonly label : string ;
810 readonly href : string ;
911 readonly title ?: string ;
1012}
1113
1214export type LinkedTextNode = string | ILink ;
13- export type LinkedText = LinkedTextNode [ ] ;
15+
16+ export class LinkedText {
17+
18+ constructor ( readonly nodes : LinkedTextNode [ ] ) { }
19+
20+ @memoize
21+ toString ( ) : string {
22+ return this . nodes . map ( node => typeof node === 'string' ? node : node . label ) . join ( '' ) ;
23+ }
24+ }
1425
1526const LINK_REGEX = / \[ ( [ ^ \] ] + ) \] \( ( (?: h t t p s ? : \/ \/ | c o m m a n d : ) [ ^ \) \s ] + ) (?: " ( [ ^ " ] + ) " ) ? \) / gi;
1627
@@ -40,5 +51,5 @@ export function parseLinkedText(text: string): LinkedText {
4051 result . push ( text . substring ( index ) ) ;
4152 }
4253
43- return result ;
54+ return new LinkedText ( result ) ;
4455}
Original file line number Diff line number Diff line change @@ -402,10 +402,10 @@ export abstract class ViewPane extends Pane implements IView {
402402 const p = append ( this . viewWelcomeContainer , $ ( 'p' ) ) ;
403403 const linkedText = parseLinkedText ( line ) ;
404404
405- for ( const node of linkedText ) {
405+ for ( const node of linkedText . nodes ) {
406406 if ( typeof node === 'string' ) {
407407 append ( p , document . createTextNode ( node ) ) ;
408- } else if ( linkedText . length === 1 ) {
408+ } else if ( linkedText . nodes . length === 1 ) {
409409 const button = new Button ( p , { title : node . title } ) ;
410410 button . label = node . label ;
411411 button . onDidClick ( _ => this . openerService . open ( node . href ) , null , disposables ) ;
You can’t perform that action at this time.
0 commit comments