aboutsummaryrefslogtreecommitdiff
path: root/lib/grep.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-05-14 18:44:58 -0500
committerMarc Coquand <marc@mccd.space>2024-05-14 18:44:58 -0500
commita76fb32e7c5815e37b5772f15326f00ec58a322d (patch)
tree99047fecba7c7a7f47844e586266579b7a3a2a59 /lib/grep.ml
parentbdd2c807e52e90b340a8b09c41e7353c52080b46 (diff)
downloadstitch-a76fb32e7c5815e37b5772f15326f00ec58a322d.tar.gz
stitch-a76fb32e7c5815e37b5772f15326f00ec58a322d.tar.bz2
stitch-a76fb32e7c5815e37b5772f15326f00ec58a322d.zip
Fix offset
Diffstat (limited to 'lib/grep.ml')
-rw-r--r--lib/grep.ml24
1 files changed, 9 insertions, 15 deletions
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 -> *)