@@ -904,20 +904,29 @@ sub print_line_with_options {
904904 my @line_parts ;
905905
906906 if ( $opt_show_filename && defined ($filename ) ) {
907- my $colno ;
908- $colno = get_match_colno() if $opt_column ;
907+ my $disp_filename ;
908+ my $disp_lineno ;
909909 if ( $opt_color ) {
910- $filename = Term::ANSIColor::colored( $filename , $ENV {ACK_COLOR_FILENAME } );
911- $lineno = Term::ANSIColor::colored( $lineno , $ENV {ACK_COLOR_LINENO } );
912- $colno = Term::ANSIColor::colored( $colno , $ENV {ACK_COLOR_COLNO } ) if $opt_column ;
910+ $disp_filename = Term::ANSIColor::colored( $filename , $ENV {ACK_COLOR_FILENAME } );
911+ $disp_lineno = Term::ANSIColor::colored( $lineno , $ENV {ACK_COLOR_LINENO } );
913912 }
913+ else {
914+ $disp_filename = $filename ;
915+ $disp_lineno = $lineno ;
916+ }
917+
914918 if ( $opt_heading ) {
915- push @line_parts , $lineno ;
919+ push @line_parts , $disp_lineno ;
916920 }
917921 else {
918- push @line_parts , $filename , $lineno ;
922+ push @line_parts , $disp_filename , $disp_lineno ;
923+ }
924+
925+ if ( $opt_column ) {
926+ my $colno = get_match_colno();
927+ $colno = Term::ANSIColor::colored( $colno , $ENV {ACK_COLOR_COLNO } ) if $opt_color ;
928+ push @line_parts , $colno ;
919929 }
920- push @line_parts , $colno if $opt_column ;
921930 }
922931
923932 if ( $opt_output ) {
0 commit comments