aboutsummaryrefslogtreecommitdiff
path: root/lib/stitched_article.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-05-17 17:46:46 -0500
committerMarc Coquand <marc@mccd.space>2024-05-17 17:46:46 -0500
commit90f8c5e65c96f946ab079271b52112ec36d6c42c (patch)
treec84380eec69806e978039f1f64c993538c3a472d /lib/stitched_article.ml
parentd5d547126c5fe2d0235b63e4ed964c4285bb2bfb (diff)
downloadstitch-90f8c5e65c96f946ab079271b52112ec36d6c42c.tar.gz
stitch-90f8c5e65c96f946ab079271b52112ec36d6c42c.tar.bz2
stitch-90f8c5e65c96f946ab079271b52112ec36d6c42c.zip
Resolve OOB error
Diffstat (limited to 'lib/stitched_article.ml')
-rw-r--r--lib/stitched_article.ml11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/stitched_article.ml b/lib/stitched_article.ml
index ce7bc0c..f42812f 100644
--- a/lib/stitched_article.ml
+++ b/lib/stitched_article.ml
@@ -9,7 +9,7 @@ type state =
; scroll : int
; content : (string * int * string * int) array
; go_back : unit -> unit
- ; content_pretty : Grep.display_type array
+ ; content_pretty : (int * Grep.display_type) array
; goto_todos_view : (unit -> unit) -> unit
; goto_done_view : (unit -> unit) -> unit
}
@@ -28,7 +28,7 @@ let rec render
let img =
let elements =
Array.mapi
- (fun i el -> Compontent.current_line size_x y scroll el (i + content_start))
+ (fun i (_, el) -> Compontent.current_line size_x y scroll el (i + content_start))
(* TODO: Fix this ugly slow conversion *)
(Array.to_seq content_pretty |> Seq.drop scroll |> Array.of_seq)
in
@@ -109,13 +109,14 @@ let rec render
let[@warning "-8"] (editor :: args) =
String.split_on_char ' ' (Sys.getenv "EDITOR")
in
- let selected_file, line_number, _, file_number_offset =
- Array.get content (y - content_start)
+ let file_number_offset, _ = Array.get content_pretty (y - content_start) in
+ let selected_file, line_number, _, _ =
+ Array.get content (y - content_start - file_number_offset)
in
let full_path_file = Grep.execution_directory ^ "/" ^ selected_file in
(* Because each file title consists of two lines, we need to account for the offset
it adds by removing the file_number *)
- let line_number_arg = "+" ^ Int.to_string (line_number - file_number_offset) in
+ let line_number_arg = "+" ^ Int.to_string line_number in
let full_args =
Array.append (Array.of_list args) [| ""; full_path_file; line_number_arg |]
in