From a76fb32e7c5815e37b5772f15326f00ec58a322d Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Tue, 14 May 2024 18:44:58 -0500 Subject: Fix offset --- lib/grep.ml | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'lib/grep.ml') diff --git a/lib/grep.ml b/lib/grep.ml index 0b3c10b..9855b6f 100644 --- a/lib/grep.ml +++ b/lib/grep.ml @@ -124,11 +124,14 @@ let get_full_file_content_content file = let parse_full_content files = - List.concat_map - (fun ((file_name : string), content) -> - let content = String.split_on_char '\n' content in - List.mapi (fun line_number line -> file_name, line_number, line) content) - files + List.concat + @@ List.mapi + (fun file_number ((file_name : string), content) -> + let content = String.split_on_char '\n' content in + List.mapi + (fun line_number line -> file_name, line_number, line, file_number) + content) + files type display_type = @@ -138,17 +141,8 @@ type display_type = let pretty_print_parsed_content parsed_files = let padding = String.make headline_pattern_length ' ' in List.concat_map - (fun (file_name, line_number, line_content) -> + (fun (file_name, line_number, line_content, _) -> if line_number == 0 then [ Bold ("------- " ^ file_name); Normal line_content ] else [ Normal (padding ^ line_content) ]) parsed_files - -(* let parse_file_headline collection full = *) -(* match full with *) -(* | s :: r -> *) -(* let split = Str.bounded_split (Str.regexp ":1:") s 1 in *) -(* (match split with *) -(* (\* file, line, content *\) *) -(* | [ file_name; content ] -> file_name, content *) -(* | rest -> *) -- cgit v1.2.3