@@ -27,20 +27,35 @@ function splitByHighLightToken(search: SgSearch) {
27
27
endIdx -= leadingSpaces
28
28
}
29
29
return {
30
- index : [ startIdx , endIdx ] ,
31
- displayLine
30
+ startIdx,
31
+ endIdx,
32
+ displayLine,
33
+ lineSpan : end . line - start . line
32
34
}
33
35
}
34
36
37
+ // this is also hardcoded in vscode
38
+ const lineIndicatorStyle = {
39
+ margin : '0 7px 4px' ,
40
+ opacity : '0.7' ,
41
+ fontSize : '0.9em' ,
42
+ verticalAlign : 'bottom'
43
+ }
44
+
45
+ function MultiLineIndicator ( { lineSpan } : { lineSpan : number } ) {
46
+ if ( lineSpan <= 0 ) {
47
+ return null
48
+ }
49
+ return < span style = { lineIndicatorStyle } > +{ lineSpan } </ span >
50
+ }
51
+
35
52
interface CodeBlockProps {
36
53
match : SgSearch
37
54
}
38
55
export const CodeBlock = ( { match } : CodeBlockProps ) => {
39
- const { file } = match
40
- const { index , displayLine } = splitByHighLightToken ( match )
56
+ const { startIdx , endIdx , displayLine , lineSpan } =
57
+ splitByHighLightToken ( match )
41
58
42
- const startIdx = index [ 0 ]
43
- const endIdx = index [ 1 ]
44
59
return (
45
60
< Box
46
61
flex = "1"
@@ -52,9 +67,10 @@ export const CodeBlock = ({ match }: CodeBlockProps) => {
52
67
height = "22px"
53
68
cursor = "pointer"
54
69
onClick = { ( ) => {
55
- openFile ( { filePath : file , locationsToSelect : match . range } )
70
+ openFile ( { filePath : match . file , locationsToSelect : match . range } )
56
71
} }
57
72
>
73
+ < MultiLineIndicator lineSpan = { lineSpan } />
58
74
{ displayLine . slice ( 0 , startIdx ) }
59
75
< span style = { style } > { displayLine . slice ( startIdx , endIdx ) } </ span >
60
76
{ displayLine . slice ( endIdx ) }
0 commit comments