Skip to content

[Super errors] Add the missing gutter when a line overflows to the next #5017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

1 │ /* overflows in the terminal */
2 │ let a: int = "hellllllllllllllllllllllllllllllllllllllllllllllllllllllll
lllllllllllllllllllllllllll";
│ lllllllllllllllllllllllllll";
3 │

This has type: string
Expand Down
23 changes: 9 additions & 14 deletions jscomp/super_errors/super_code_frame.ml
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,15 @@ let print ~is_warning ~src ~startPos ~endPos =
Buffer.add_string buf (col NoColor "\n");
| Number line_number -> begin
content |> List.iteri (fun i line ->
if i = 0 then begin
let gutter_color =
if i = 0
&& line_number >= highlight_line_start_line
&& line_number <= highlight_line_end_line then
if is_warning then Warn else Err
else NoColor
in
draw_gutter gutter_color (string_of_int line_number);
end else begin
(* TODO: remove this branch after the next PR *)
let pad = String.make (max_line_digits_count + indent + 3) ' ' in
Buffer.add_string buf (col NoColor pad);
end;
let gutter_content = if i = 0 then string_of_int line_number else "" in
let gutter_color =
if i = 0
&& line_number >= highlight_line_start_line
&& line_number <= highlight_line_end_line then
if is_warning then Warn else Err
else NoColor
in
draw_gutter gutter_color gutter_content;

line.s |> String.iteri (fun ii ch ->
let c =
Expand Down
23 changes: 9 additions & 14 deletions lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -407653,20 +407653,15 @@ let print ~is_warning ~src ~startPos ~endPos =
Buffer.add_string buf (col NoColor "\n");
| Number line_number -> begin
content |> List.iteri (fun i line ->
if i = 0 then begin
let gutter_color =
if i = 0
&& line_number >= highlight_line_start_line
&& line_number <= highlight_line_end_line then
if is_warning then Warn else Err
else NoColor
in
draw_gutter gutter_color (string_of_int line_number);
end else begin
(* TODO: remove this branch after the next PR *)
let pad = String.make (max_line_digits_count + indent + 3) ' ' in
Buffer.add_string buf (col NoColor pad);
end;
let gutter_content = if i = 0 then string_of_int line_number else "" in
let gutter_color =
if i = 0
&& line_number >= highlight_line_start_line
&& line_number <= highlight_line_end_line then
if is_warning then Warn else Err
else NoColor
in
draw_gutter gutter_color gutter_content;

line.s |> String.iteri (fun ii ch ->
let c =
Expand Down
23 changes: 9 additions & 14 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -433704,20 +433704,15 @@ let print ~is_warning ~src ~startPos ~endPos =
Buffer.add_string buf (col NoColor "\n");
| Number line_number -> begin
content |> List.iteri (fun i line ->
if i = 0 then begin
let gutter_color =
if i = 0
&& line_number >= highlight_line_start_line
&& line_number <= highlight_line_end_line then
if is_warning then Warn else Err
else NoColor
in
draw_gutter gutter_color (string_of_int line_number);
end else begin
(* TODO: remove this branch after the next PR *)
let pad = String.make (max_line_digits_count + indent + 3) ' ' in
Buffer.add_string buf (col NoColor pad);
end;
let gutter_content = if i = 0 then string_of_int line_number else "" in
let gutter_color =
if i = 0
&& line_number >= highlight_line_start_line
&& line_number <= highlight_line_end_line then
if is_warning then Warn else Err
else NoColor
in
draw_gutter gutter_color gutter_content;

line.s |> String.iteri (fun ii ch ->
let c =
Expand Down