@ -191,6 +191,7 @@ pub struct Column<T, D> {
/// `DynamicPicker` uses this so that the dynamic column (for example regex in
/// `DynamicPicker` uses this so that the dynamic column (for example regex in
/// global search) is not used for filtering twice.
/// global search) is not used for filtering twice.
filter : bool ,
filter : bool ,
hidden : bool ,
}
}
impl < T , D > Column < T , D > {
impl < T , D > Column < T , D > {
@ -199,6 +200,19 @@ impl<T, D> Column<T, D> {
name : name . into ( ) ,
name : name . into ( ) ,
format ,
format ,
filter : true ,
filter : true ,
hidden : false ,
}
}
/// A column which does not display any contents
pub fn hidden ( name : impl Into < Arc < str > > ) -> Self {
let format = | _ : & T , _ : & D | unreachable! ( ) ;
Self {
name : name . into ( ) ,
format ,
filter : false ,
hidden : true ,
}
}
}
}
@ -677,6 +691,10 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
let mut matcher_index = 0 ;
let mut matcher_index = 0 ;
Row ::new ( self . columns . iter ( ) . map ( | column | {
Row ::new ( self . columns . iter ( ) . map ( | column | {
if column . hidden {
return Cell ::default ( ) ;
}
let Some ( Constraint ::Length ( max_width ) ) = widths . next ( ) else {
let Some ( Constraint ::Length ( max_width ) ) = widths . next ( ) else {
unreachable! ( ) ;
unreachable! ( ) ;
} ;
} ;
@ -757,7 +775,11 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
let header_style = cx . editor . theme . get ( "ui.picker.header" ) ;
let header_style = cx . editor . theme . get ( "ui.picker.header" ) ;
table = table . header ( Row ::new ( self . columns . iter ( ) . map ( | column | {
table = table . header ( Row ::new ( self . columns . iter ( ) . map ( | column | {
if column . hidden {
Cell ::default ( )
} else {
Cell ::from ( Span ::styled ( Cow ::from ( & * column . name ) , header_style ) )
Cell ::from ( Span ::styled ( Cow ::from ( & * column . name ) , header_style ) )
}
} ) ) ) ;
} ) ) ) ;
}
}