Skip to content

Commit 6eb4fb3

Browse files
committed
[Super errors] Add the missing gutter when a line overflows to the next
Fixes part of rescript-lang/rescript-vscode#86 Previous to rescript-lang#5013 we couldn't fix this issue because we used Format to break lines for us. Now that we're controlling this manually, we can draw the gutter for those lines.
1 parent b0a7a5f commit 6eb4fb3

File tree

4 files changed

+28
-43
lines changed

4 files changed

+28
-43
lines changed

jscomp/build_tests/super_errors/expected/highlighting5.re.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
1 │ /* overflows in the terminal */
66
2 │ let a: int = "hellllllllllllllllllllllllllllllllllllllllllllllllllllllll
7-
lllllllllllllllllllllllllll";
7+
│ lllllllllllllllllllllllllll";
88
3 │
99

1010
This has type: string

jscomp/super_errors/super_code_frame.ml

+9-14
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,15 @@ let print ~is_warning ~src ~startPos ~endPos =
238238
Buffer.add_string buf (col NoColor "\n");
239239
| Number line_number -> begin
240240
content |> List.iteri (fun i line ->
241-
if i = 0 then begin
242-
let gutter_color =
243-
if i = 0
244-
&& line_number >= highlight_line_start_line
245-
&& line_number <= highlight_line_end_line then
246-
if is_warning then Warn else Err
247-
else NoColor
248-
in
249-
draw_gutter gutter_color (string_of_int line_number);
250-
end else begin
251-
(* TODO: remove this branch after the next PR *)
252-
let pad = String.make (max_line_digits_count + indent + 3) ' ' in
253-
Buffer.add_string buf (col NoColor pad);
254-
end;
241+
let gutter_content = if i = 0 then string_of_int line_number else "" in
242+
let gutter_color =
243+
if i = 0
244+
&& line_number >= highlight_line_start_line
245+
&& line_number <= highlight_line_end_line then
246+
if is_warning then Warn else Err
247+
else NoColor
248+
in
249+
draw_gutter gutter_color gutter_content;
255250

256251
line.s |> String.iteri (fun ii ch ->
257252
let c =

lib/4.06.1/unstable/js_compiler.ml

+9-14
Original file line numberDiff line numberDiff line change
@@ -407653,20 +407653,15 @@ let print ~is_warning ~src ~startPos ~endPos =
407653407653
Buffer.add_string buf (col NoColor "\n");
407654407654
| Number line_number -> begin
407655407655
content |> List.iteri (fun i line ->
407656-
if i = 0 then begin
407657-
let gutter_color =
407658-
if i = 0
407659-
&& line_number >= highlight_line_start_line
407660-
&& line_number <= highlight_line_end_line then
407661-
if is_warning then Warn else Err
407662-
else NoColor
407663-
in
407664-
draw_gutter gutter_color (string_of_int line_number);
407665-
end else begin
407666-
(* TODO: remove this branch after the next PR *)
407667-
let pad = String.make (max_line_digits_count + indent + 3) ' ' in
407668-
Buffer.add_string buf (col NoColor pad);
407669-
end;
407656+
let gutter_content = if i = 0 then string_of_int line_number else "" in
407657+
let gutter_color =
407658+
if i = 0
407659+
&& line_number >= highlight_line_start_line
407660+
&& line_number <= highlight_line_end_line then
407661+
if is_warning then Warn else Err
407662+
else NoColor
407663+
in
407664+
draw_gutter gutter_color gutter_content;
407670407665

407671407666
line.s |> String.iteri (fun ii ch ->
407672407667
let c =

lib/4.06.1/whole_compiler.ml

+9-14
Original file line numberDiff line numberDiff line change
@@ -433704,20 +433704,15 @@ let print ~is_warning ~src ~startPos ~endPos =
433704433704
Buffer.add_string buf (col NoColor "\n");
433705433705
| Number line_number -> begin
433706433706
content |> List.iteri (fun i line ->
433707-
if i = 0 then begin
433708-
let gutter_color =
433709-
if i = 0
433710-
&& line_number >= highlight_line_start_line
433711-
&& line_number <= highlight_line_end_line then
433712-
if is_warning then Warn else Err
433713-
else NoColor
433714-
in
433715-
draw_gutter gutter_color (string_of_int line_number);
433716-
end else begin
433717-
(* TODO: remove this branch after the next PR *)
433718-
let pad = String.make (max_line_digits_count + indent + 3) ' ' in
433719-
Buffer.add_string buf (col NoColor pad);
433720-
end;
433707+
let gutter_content = if i = 0 then string_of_int line_number else "" in
433708+
let gutter_color =
433709+
if i = 0
433710+
&& line_number >= highlight_line_start_line
433711+
&& line_number <= highlight_line_end_line then
433712+
if is_warning then Warn else Err
433713+
else NoColor
433714+
in
433715+
draw_gutter gutter_color gutter_content;
433721433716

433722433717
line.s |> String.iteri (fun ii ch ->
433723433718
let c =

0 commit comments

Comments
 (0)