Skip to content

Commit 2e99e60

Browse files
authored
Fix super errors line highlighting bug (#1907)
I accidentally used the last line's last highlighted char index as the boundary for the first line's last highlighted char index. First line should highlight all the way til the end. Also renamed things to make this clear in the future.
1 parent c80ebb3 commit 2e99e60

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

jscomp/super_errors/super_misc.ml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ let leading_space_count str =
3232
starting from the first erroring character?) *)
3333
(* Range coordinates all 1-indexed, like for editors. Otherwise this code
3434
would have way too many off-by-one errors *)
35-
let print_file ~is_warning ~range:((start_line, start_char), (end_line, end_char)) ~lines ppf () =
35+
let print_file
36+
~is_warning
37+
~range:((start_line, start_line_start_char), (end_line, end_line_end_char))
38+
~lines
39+
ppf
40+
() =
3641
(* show 2 lines before & after the erroring lines *)
3742
let first_shown_line = max 1 (start_line - 2) in
3843
let last_shown_line = min (Array.length lines) (end_line + 2) in
@@ -103,13 +108,13 @@ let print_file ~is_warning ~range:((start_line, start_char), (end_line, end_char
103108
if current_line_strictly_between_start_and_end_line then
104109
fprintf ppf "%c@," current_char
105110
else if i = start_line then begin
106-
if j == (start_char - columns_to_cut) then fprintf ppf highlighted_content;
111+
if j == (start_line_start_char - columns_to_cut) then fprintf ppf highlighted_content;
107112
fprintf ppf "%c@," current_char;
108-
if j == (end_char - columns_to_cut) then fprintf ppf "@}"
113+
if j == current_line_cut_length then fprintf ppf "@}"
109114
end else if i = end_line then begin
110115
if j == 1 then fprintf ppf highlighted_content;
111116
fprintf ppf "%c@," current_char;
112-
if j == (end_char - columns_to_cut) then fprintf ppf "@}"
117+
if j == (end_line_end_char - columns_to_cut) then fprintf ppf "@}"
113118
end else
114119
(* normal, non-highlighted line *)
115120
fprintf ppf "%c@," current_char

0 commit comments

Comments
 (0)