@@ -1544,6 +1544,18 @@ logfile::rebuild_index(std::optional<ui_clock::time_point> deadline)
15441544 }
15451545 prev_range = li.li_file_range ;
15461546
1547+ auto read_result
1548+ = this ->lf_line_buffer .read_range (li.li_file_range );
1549+ if (read_result.isErr ()) {
1550+ log_error (" %s:read failure -- %s" ,
1551+ this ->lf_filename_as_string .c_str (),
1552+ read_result.unwrapErr ().c_str ());
1553+ this ->close ();
1554+ return rebuild_result_t ::INVALID ;
1555+ }
1556+
1557+ auto sbr = read_result.unwrap ();
1558+
15471559 if (this ->lf_format == nullptr
15481560 && !this ->lf_options .loo_non_utf_is_visible
15491561 && !li.li_utf8_scan_result .is_valid ())
@@ -1552,9 +1564,21 @@ logfile::rebuild_index(std::optional<ui_clock::time_point> deadline)
15521564 this ->lf_filename_as_string .c_str ());
15531565 this ->lf_indexing = false ;
15541566 this ->lf_options .loo_is_visible = false ;
1555- auto utf8_error_um
1556- = lnav::console::user_message::error (" invalid UTF-8" )
1557- .with_reason (
1567+ attr_line_t hex;
1568+ attr_line_builder alb (hex);
1569+ alb.append_as_hexdump (sbr.to_string_fragment ());
1570+ auto snip = lnav::console::snippet::from (
1571+ source_location{
1572+ intern_string::lookup (this ->lf_filename ),
1573+ (int ) this ->lf_index .size () + 1 ,
1574+ },
1575+ hex);
1576+ auto note_um
1577+ = lnav::console::user_message::warning (
1578+ attr_line_t (" skipping indexing for " )
1579+ .append_quoted (this ->lf_filename ))
1580+ .with_reason (" File contains invalid UTF-8" )
1581+ .with_note (
15581582 attr_line_t (li.li_utf8_scan_result .usr_message )
15591583 .append (" at line " )
15601584 .append (lnav::roles::number (fmt::to_string (
@@ -1563,11 +1587,8 @@ logfile::rebuild_index(std::optional<ui_clock::time_point> deadline)
15631587 .append (lnav::roles::number (fmt::to_string (
15641588 li.li_utf8_scan_result .usr_valid_frag
15651589 .sf_end ))))
1590+ .with_snippet (snip)
15661591 .move ();
1567- auto note_um = lnav::console::user_message::warning (
1568- " skipping indexing for file" )
1569- .with_reason (utf8_error_um)
1570- .move ();
15711592 this ->lf_notes .writeAccess ()->insert (note_type::not_utf,
15721593 note_um);
15731594 if (this ->lf_logfile_observer != nullptr ) {
@@ -1633,18 +1654,6 @@ logfile::rebuild_index(std::optional<ui_clock::time_point> deadline)
16331654 }
16341655 }
16351656
1636- auto read_result
1637- = this ->lf_line_buffer .read_range (li.li_file_range );
1638- if (read_result.isErr ()) {
1639- log_error (" %s:read failure -- %s" ,
1640- this ->lf_filename_as_string .c_str (),
1641- read_result.unwrapErr ().c_str ());
1642- this ->close ();
1643- return rebuild_result_t ::INVALID ;
1644- }
1645-
1646- auto sbr = read_result.unwrap ();
1647-
16481657 if (!li.li_utf8_scan_result .is_valid ()) {
16491658 log_warning (
16501659 " %s: invalid UTF-8 detected at L%zu:C%d/%lld (O:%lld) -- "
0 commit comments