File tree 1 file changed +6
-2
lines changed
packages/knip/src/reporters
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,16 @@ const bright = picocolors.whiteBright;
11
11
12
12
const TRUNCATE_WIDTH = 40 ;
13
13
const truncate = ( text : string ) => ( text . length > TRUNCATE_WIDTH ? `${ text . slice ( 0 , TRUNCATE_WIDTH - 3 ) } ...` : text ) ;
14
+ const truncateStart = ( text : string , width : number ) => ( text . length > width ? `...${ text . slice ( - ( width - 3 ) ) } ` : text ) ;
14
15
15
16
const hl = ( issue : Issue ) => {
16
17
if ( issue . specifier && issue . specifier !== issue . symbol && issue . specifier . includes ( issue . symbol ) ) {
17
18
const parts = issue . specifier . split ( issue . symbol ) ;
18
- const rest = parts . slice ( 1 ) . join ( '' ) ;
19
- return [ dim ( parts [ 0 ] ) , bright ( issue . symbol ) , dim ( rest ) ] . join ( '' ) ;
19
+ const right = parts . slice ( 1 ) . join ( '' ) ;
20
+ const max = TRUNCATE_WIDTH - issue . symbol . length - right . length ;
21
+ const part = parts [ 0 ] ;
22
+ const left = part . length > 3 ? ( max <= 3 ? `...${ part . slice ( - 3 ) } ` : truncateStart ( part , max ) ) : part ;
23
+ return [ dim ( left ) , bright ( issue . symbol ) , dim ( right ) ] . join ( '' ) ;
20
24
}
21
25
return issue . symbol ;
22
26
} ;
You can’t perform that action at this time.
0 commit comments