1+ use crate :: app:: DisplayContext ;
2+ use crate :: path:: relativize_path;
3+
14use {
25 super :: {
36 cond_bg,
912 SPACE_FILLING , BRANCH_FILLING ,
1013 } ,
1114 crate :: {
12- app:: AppState ,
1315 content_search:: ContentMatch ,
1416 errors:: ProgramError ,
1517 file_sum:: FileSum ,
3739/// - a scrollbar may be drawn
3840/// - the empty lines will be erased
3941pub struct DisplayableTree < ' a , ' s , ' t > {
40- pub app_state : Option < & ' a AppState > ,
42+ pub display_context : Option < & ' a DisplayContext < ' a > > ,
4143 pub tree : & ' t Tree ,
4244 pub skin : & ' s StyleMap ,
4345 pub area : termimad:: Area ,
@@ -55,7 +57,7 @@ impl<'a, 's, 't> DisplayableTree<'a, 's, 't> {
5557 height : u16 ,
5658 ) -> DisplayableTree < ' a , ' s , ' t > {
5759 DisplayableTree {
58- app_state : None ,
60+ display_context : None ,
5961 tree,
6062 skin,
6163 ext_colors,
@@ -413,8 +415,15 @@ impl<'a, 's, 't> DisplayableTree<'a, 's, 't> {
413415 ) ?;
414416 }
415417 }
416- let title = line. path . to_string_lossy ( ) ;
417- cw. queue_str ( style, & title) ?;
418+ match self . display_context {
419+ Some ( context) if self . tree . options . relative_root => {
420+ cw. queue_str ( style, & relativize_path ( & line. path , context. con ) ?) ?;
421+ } ,
422+ _ => {
423+ cw. queue_str ( style, & line. path . to_string_lossy ( ) ) ?;
424+ } ,
425+ }
426+
418427 if self . in_app && !cw. is_full ( ) {
419428 if let ComputationResult :: Done ( git_status) = & self . tree . git_status {
420429 let git_status_display = GitStatusDisplay :: from (
@@ -486,7 +495,7 @@ impl<'a, 's, 't> DisplayableTree<'a, 's, 't> {
486495 . options
487496 . cols_order
488497 . iter ( )
489- . filter ( |col| col. is_visible ( tree, self . app_state ) )
498+ . filter ( |col| col. is_visible ( tree, self . display_context . map ( |con| con . app_state ) ) )
490499 . cloned ( )
491500 . collect ( ) ;
492501
@@ -536,8 +545,8 @@ impl<'a, 's, 't> DisplayableTree<'a, 's, 't> {
536545 if visible_cols[ 0 ] . needs_left_margin ( ) {
537546 cw. queue_char ( space_style, ' ' ) ?;
538547 }
539- let staged = self . app_state
540- . map_or ( false , |a| a. stage . contains ( & line. path ) ) ;
548+ let staged = self . display_context
549+ . map_or ( false , |a| a. app_state . stage . contains ( & line. path ) ) ;
541550 for col in & visible_cols {
542551 let void_len = match col {
543552
0 commit comments