@@ -11,13 +11,17 @@ use output::cell::TextCellContents;
11
11
pub struct FileName < ' a , ' dir : ' a > {
12
12
file : & ' a File < ' dir > ,
13
13
colours : & ' a Colours ,
14
+ target : Option < FileTarget < ' dir > > ,
14
15
}
15
16
16
17
impl < ' a , ' dir > FileName < ' a , ' dir > {
17
18
pub fn new ( file : & ' a File < ' dir > , colours : & ' a Colours ) -> FileName < ' a , ' dir > {
19
+ let target = if file. is_link ( ) { Some ( file. link_target ( ) ) }
20
+ else { None } ;
18
21
FileName {
19
22
file : file,
20
23
colours : colours,
24
+ target : target,
21
25
}
22
26
}
23
27
@@ -36,9 +40,9 @@ impl<'a, 'dir> FileName<'a, 'dir> {
36
40
}
37
41
}
38
42
39
- if links && self . file . is_link ( ) {
40
- match self . file . link_target ( ) {
41
- FileTarget :: Ok ( target) => {
43
+ if links && self . target . is_some ( ) {
44
+ match self . target . as_ref ( ) . unwrap ( ) {
45
+ & FileTarget :: Ok ( ref target) => {
42
46
bits. push ( Style :: default ( ) . paint ( " " ) ) ;
43
47
bits. push ( self . colours . punctuation . paint ( "->" ) ) ;
44
48
bits. push ( Style :: default ( ) . paint ( " " ) ) ;
@@ -55,16 +59,16 @@ impl<'a, 'dir> FileName<'a, 'dir> {
55
59
}
56
60
} ,
57
61
58
- FileTarget :: Broken ( broken_path) => {
62
+ & FileTarget :: Broken ( ref broken_path) => {
59
63
bits. push ( Style :: default ( ) . paint ( " " ) ) ;
60
64
bits. push ( self . colours . broken_arrow . paint ( "->" ) ) ;
61
65
bits. push ( Style :: default ( ) . paint ( " " ) ) ;
62
66
escape ( broken_path. display ( ) . to_string ( ) , & mut bits, self . colours . broken_filename , self . colours . control_char . underline ( ) ) ;
63
67
} ,
64
68
65
- FileTarget :: Err ( _) => {
69
+ & FileTarget :: Err ( _) => {
66
70
// Do nothing -- the error gets displayed on the next line
67
- }
71
+ } ,
68
72
}
69
73
}
70
74
else if classify {
0 commit comments