@@ -20,7 +20,7 @@ import { ImageDiffView } from '@web/shared/imageDiffView';
20
20
import type { MultiTraceModel } from './modelUtil' ;
21
21
import { PlaceholderPanel } from './placeholderPanel' ;
22
22
import type { AfterActionTraceEventAttachment } from '@trace/trace' ;
23
- import { CodeMirrorWrapper } from '@web/components/codeMirrorWrapper' ;
23
+ import { CodeMirrorWrapper , lineHeight } from '@web/components/codeMirrorWrapper' ;
24
24
import { isTextualMimeType } from '@isomorphic/mimeType' ;
25
25
import { Expandable } from '@web/components/expandable' ;
26
26
import { linkifyText } from '@web/renderUtils' ;
@@ -51,6 +51,11 @@ const ExpandableAttachment: React.FunctionComponent<ExpandableAttachmentProps> =
51
51
}
52
52
} , [ expanded , attachmentText , placeholder , attachment ] ) ;
53
53
54
+ const snippetHeight = React . useMemo ( ( ) => {
55
+ const lineCount = attachmentText ? attachmentText . split ( '\n' ) . length : 0 ;
56
+ return Math . min ( Math . max ( 5 , lineCount ) , 20 ) * lineHeight ;
57
+ } , [ attachmentText ] ) ;
58
+
54
59
const title = < span style = { { marginLeft : 5 } } >
55
60
{ linkifyText ( attachment . name ) } { hasContent && < a style = { { marginLeft : 5 } } href = { downloadURL ( attachment ) } > download</ a > }
56
61
</ span > ;
@@ -62,14 +67,16 @@ const ExpandableAttachment: React.FunctionComponent<ExpandableAttachmentProps> =
62
67
< Expandable title = { title } expanded = { expanded } setExpanded = { setExpanded } expandOnTitleClick = { true } >
63
68
{ placeholder && < i > { placeholder } </ i > }
64
69
</ Expandable >
65
- { expanded && attachmentText !== null && < CodeMirrorWrapper
66
- text = { attachmentText }
67
- readOnly
68
- mimeType = { attachment . contentType }
69
- linkify = { true }
70
- lineNumbers = { true }
71
- wrapLines = { false } >
72
- </ CodeMirrorWrapper > }
70
+ { expanded && attachmentText !== null && < div className = 'vbox' style = { { height : snippetHeight } } >
71
+ < CodeMirrorWrapper
72
+ text = { attachmentText }
73
+ readOnly
74
+ mimeType = { attachment . contentType }
75
+ linkify = { true }
76
+ lineNumbers = { true }
77
+ wrapLines = { false } >
78
+ </ CodeMirrorWrapper >
79
+ </ div > }
73
80
</ > ;
74
81
} ;
75
82
0 commit comments