@@ -1174,19 +1174,11 @@ fn draw_issue_list(f: &mut Frame, area: Rect, app: &mut App) {
11741174 . as_deref ( )
11751175 . map ( |o| truncate ( o, 10 ) )
11761176 . unwrap_or_else ( || "-" . to_string ( ) ) ;
1177- let tags = issue
1178- . frontmatter
1179- . tags
1180- . iter ( )
1181- . map ( |t| format ! ( "#{}" , t) )
1182- . collect :: < Vec < _ > > ( )
1183- . join ( " " ) ;
1184- let title_and_tags = if tags. is_empty ( ) {
1177+ let tags_width = issue_tags_width ( & issue. frontmatter . tags ) ;
1178+ let title_part = if tags_width == 0 {
11851179 truncate ( issue. title ( ) , title_width)
11861180 } else {
1187- let title_part =
1188- truncate ( issue. title ( ) , title_width. saturating_sub ( tags. len ( ) + 1 ) ) ;
1189- format ! ( "{} {}" , title_part, tags)
1181+ truncate ( issue. title ( ) , title_width. saturating_sub ( tags_width + 1 ) )
11901182 } ;
11911183
11921184 let duration = now - issue. frontmatter . created_at ;
@@ -1219,27 +1211,28 @@ fn draw_issue_list(f: &mut Frame, area: Rect, app: &mut App) {
12191211 None => base_style,
12201212 } ;
12211213
1222- // build line with optional red "!" prefix for blockers
1223- let rest_of_line = format ! (
1224- "{} {} {:>4} {:<10} {}" ,
1225- id,
1226- issue. priority( ) ,
1227- age,
1228- owner,
1229- title_and_tags
1230- ) ;
1214+ let mut rest_spans = vec ! [ Span :: styled(
1215+ format!(
1216+ "{} {} {:>4} {:<10} {}" ,
1217+ id,
1218+ issue. priority( ) ,
1219+ age,
1220+ owner,
1221+ title_part
1222+ ) ,
1223+ style,
1224+ ) ] ;
1225+ push_colored_tags ( & mut rest_spans, & issue. frontmatter . tags , style) ;
12311226
12321227 let line = if is_blocker && !is_selected {
12331228 // show red "!" prefix for blockers (but not when selected, as bg is yellow)
1234- Line :: from ( vec ! [
1235- Span :: styled( "! " , Style :: default ( ) . fg( Color :: Red ) ) ,
1236- Span :: styled( rest_of_line, style) ,
1237- ] )
1229+ let mut spans = vec ! [ Span :: styled( "! " , Style :: default ( ) . fg( Color :: Red ) ) ] ;
1230+ spans. extend ( rest_spans) ;
1231+ Line :: from ( spans)
12381232 } else {
1239- Line :: from ( Span :: styled (
1240- format ! ( "{}{}" , status_prefix, rest_of_line) ,
1241- style,
1242- ) )
1233+ let mut spans = vec ! [ Span :: styled( status_prefix. to_string( ) , style) ] ;
1234+ spans. extend ( rest_spans) ;
1235+ Line :: from ( spans)
12431236 } ;
12441237
12451238 ListItem :: new ( line)
@@ -1283,6 +1276,34 @@ fn draw_issue_list(f: &mut Frame, area: Rect, app: &mut App) {
12831276 }
12841277}
12851278
1279+ fn issue_tags_width ( tags : & [ String ] ) -> usize {
1280+ if tags. is_empty ( ) {
1281+ return 0 ;
1282+ }
1283+ // each tag contributes "#" + tag plus one separator between tags.
1284+ tags. iter ( ) . map ( |tag| tag. len ( ) + 1 ) . sum :: < usize > ( ) + tags. len ( ) - 1
1285+ }
1286+
1287+ fn push_colored_tags ( spans : & mut Vec < Span < ' static > > , tags : & [ String ] , style : Style ) {
1288+ if tags. is_empty ( ) {
1289+ return ;
1290+ }
1291+
1292+ spans. push ( Span :: styled ( " " , style) ) ;
1293+ for ( i, tag) in tags. iter ( ) . enumerate ( ) {
1294+ if i > 0 {
1295+ spans. push ( Span :: styled ( " " , style) ) ;
1296+ }
1297+ let color = if tag == "bug" {
1298+ Color :: Red
1299+ } else {
1300+ Color :: Cyan
1301+ } ;
1302+ let tag_style = style. patch ( Style :: default ( ) . fg ( color) ) ;
1303+ spans. push ( Span :: styled ( format ! ( "#{}" , tag) , tag_style) ) ;
1304+ }
1305+ }
1306+
12861307fn draw_detail ( f : & mut Frame , area : Rect , app : & mut App ) {
12871308 let inner_height = area. height . saturating_sub ( 2 ) as usize ; // subtract borders
12881309
0 commit comments