aboutsummaryrefslogtreecommitdiff
path: root/lib/stitched_article.ml
diff options
context:
space:
mode:
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