File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 33## Features
44
55- New style component ` header-filesize ` to show size of the displayed file in the header. See #1988 (@mdibaiee )
6+ - Use underline for line highlighting on ANSI, see #1730 (@mdibaiee )
67
78## Bugfixes
89
Original file line number Diff line number Diff line change @@ -463,6 +463,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
463463 let highlight_this_line =
464464 self . config . highlighted_lines . 0 . check ( line_number) == RangeCheckResult :: InRange ;
465465
466+ if highlight_this_line && self . config . theme == "ansi" {
467+ self . ansi_style . update ( "^[4m" ) ;
468+ }
469+
466470 let background_color = self
467471 . background_color_highlight
468472 . filter ( |_| highlight_this_line) ;
@@ -649,6 +653,11 @@ impl<'a> Printer for InteractivePrinter<'a> {
649653 writeln ! ( handle) ?;
650654 }
651655
656+ if highlight_this_line && self . config . theme == "ansi" {
657+ self . ansi_style . update ( "^[24m" ) ;
658+ write ! ( handle, "\x1B [24m" ) ?;
659+ }
660+
652661 Ok ( ( ) )
653662 }
654663}
Original file line number Diff line number Diff line change @@ -1290,6 +1290,25 @@ fn grid_for_file_without_newline() {
12901290 . stderr ( "" ) ;
12911291}
12921292
1293+ // For ANSI theme, use underscore as a highlighter
1294+ #[ test]
1295+ fn ansi_highlight_underline ( ) {
1296+ bat ( )
1297+ . arg ( "--paging=never" )
1298+ . arg ( "--color=never" )
1299+ . arg ( "--terminal-width=80" )
1300+ . arg ( "--wrap=never" )
1301+ . arg ( "--decorations=always" )
1302+ . arg ( "--theme=ansi" )
1303+ . arg ( "--style=plain" )
1304+ . arg ( "--highlight-line=1" )
1305+ . write_stdin ( "Ansi Underscore Test\n Another Line" )
1306+ . assert ( )
1307+ . success ( )
1308+ . stdout ( "\x1B [4mAnsi Underscore Test\n \x1B [24mAnother Line" )
1309+ . stderr ( "" ) ;
1310+ }
1311+
12931312// Ensure that ANSI passthrough is emitted properly for both wrapping and non-wrapping printer.
12941313#[ test]
12951314fn ansi_passthrough_emit ( ) {
You can’t perform that action at this time.
0 commit comments