44 *--------------------------------------------------------------------------------------------*/
55
66import { handleANSIOutput } from './ansi' ;
7+ import { LinkOptions } from './linkify' ;
78import { OutputElementOptions , OutputWithAppend } from './rendererTypes' ;
89export const scrollableClass = 'scrollable' ;
910
@@ -68,44 +69,44 @@ function generateNestedViewAllElement(outputId: string) {
6869 return container ;
6970}
7071
71- function truncatedArrayOfString ( id : string , buffer : string [ ] , linesLimit : number , trustHtml : boolean ) {
72+ function truncatedArrayOfString ( id : string , buffer : string [ ] , linesLimit : number , linkOptions : LinkOptions ) {
7273 const container = document . createElement ( 'div' ) ;
7374 const lineCount = buffer . length ;
7475
7576 if ( lineCount <= linesLimit ) {
76- const spanElement = handleANSIOutput ( buffer . join ( '\n' ) , trustHtml ) ;
77+ const spanElement = handleANSIOutput ( buffer . join ( '\n' ) , linkOptions ) ;
7778 container . appendChild ( spanElement ) ;
7879 return container ;
7980 }
8081
81- container . appendChild ( handleANSIOutput ( buffer . slice ( 0 , linesLimit - 5 ) . join ( '\n' ) , trustHtml ) ) ;
82+ container . appendChild ( handleANSIOutput ( buffer . slice ( 0 , linesLimit - 5 ) . join ( '\n' ) , linkOptions ) ) ;
8283
8384 // truncated piece
8485 const elipses = document . createElement ( 'div' ) ;
8586 elipses . innerText = '...' ;
8687 container . appendChild ( elipses ) ;
8788
88- container . appendChild ( handleANSIOutput ( buffer . slice ( lineCount - 5 ) . join ( '\n' ) , trustHtml ) ) ;
89+ container . appendChild ( handleANSIOutput ( buffer . slice ( lineCount - 5 ) . join ( '\n' ) , linkOptions ) ) ;
8990
9091 container . appendChild ( generateViewMoreElement ( id ) ) ;
9192
9293 return container ;
9394}
9495
95- function scrollableArrayOfString ( id : string , buffer : string [ ] , trustHtml : boolean ) {
96+ function scrollableArrayOfString ( id : string , buffer : string [ ] , linkOptions : LinkOptions ) {
9697 const element = document . createElement ( 'div' ) ;
9798 if ( buffer . length > softScrollableLineLimit ) {
9899 element . appendChild ( generateNestedViewAllElement ( id ) ) ;
99100 }
100101
101- element . appendChild ( handleANSIOutput ( buffer . slice ( - 1 * softScrollableLineLimit ) . join ( '\n' ) , trustHtml ) ) ;
102+ element . appendChild ( handleANSIOutput ( buffer . slice ( - 1 * softScrollableLineLimit ) . join ( '\n' ) , linkOptions ) ) ;
102103
103104 return element ;
104105}
105106
106107const outputLengths : Record < string , number > = { } ;
107108
108- function appendScrollableOutput ( element : HTMLElement , id : string , appended : string , trustHtml : boolean ) {
109+ function appendScrollableOutput ( element : HTMLElement , id : string , appended : string , linkOptions : LinkOptions ) {
109110 if ( ! outputLengths [ id ] ) {
110111 outputLengths [ id ] = 0 ;
111112 }
@@ -117,22 +118,23 @@ function appendScrollableOutput(element: HTMLElement, id: string, appended: stri
117118 return false ;
118119 }
119120 else {
120- element . appendChild ( handleANSIOutput ( buffer . join ( '\n' ) , trustHtml ) ) ;
121+ element . appendChild ( handleANSIOutput ( buffer . join ( '\n' ) , linkOptions ) ) ;
121122 outputLengths [ id ] = appendedLength ;
122123 }
123124 return true ;
124125}
125126
126127export function createOutputContent ( id : string , outputText : string , options : OutputElementOptions ) : HTMLElement {
127- const { linesLimit, error, scrollable, trustHtml } = options ;
128+ const { linesLimit, error, scrollable, trustHtml, linkifyFilePaths } = options ;
129+ const linkOptions : LinkOptions = { linkifyFilePaths, trustHtml } ;
128130 const buffer = outputText . split ( / \r \n | \r | \n / g) ;
129131 outputLengths [ id ] = outputLengths [ id ] = Math . min ( buffer . length , softScrollableLineLimit ) ;
130132
131133 let outputElement : HTMLElement ;
132134 if ( scrollable ) {
133- outputElement = scrollableArrayOfString ( id , buffer , ! ! trustHtml ) ;
135+ outputElement = scrollableArrayOfString ( id , buffer , linkOptions ) ;
134136 } else {
135- outputElement = truncatedArrayOfString ( id , buffer , linesLimit , ! ! trustHtml ) ;
137+ outputElement = truncatedArrayOfString ( id , buffer , linesLimit , linkOptions ) ;
136138 }
137139
138140 outputElement . setAttribute ( 'output-item-id' , id ) ;
@@ -145,9 +147,10 @@ export function createOutputContent(id: string, outputText: string, options: Out
145147
146148export function appendOutput ( outputInfo : OutputWithAppend , existingContent : HTMLElement , options : OutputElementOptions ) {
147149 const appendedText = outputInfo . appendedText ?.( ) ;
150+ const linkOptions = { linkifyFilePaths : options . linkifyFilePaths , trustHtml : options . trustHtml } ;
148151 // appending output only supported for scrollable ouputs currently
149152 if ( appendedText && options . scrollable ) {
150- if ( appendScrollableOutput ( existingContent , outputInfo . id , appendedText , false ) ) {
153+ if ( appendScrollableOutput ( existingContent , outputInfo . id , appendedText , linkOptions ) ) {
151154 return ;
152155 }
153156 }
0 commit comments