File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed
tests/tools_tests/src/expected Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 11
22 Syntax error in code block in docstring
3- /Users/zth/OSS/rescript-compiler/tests/tools_tests/src/docstrings-format/FormatDocstringsTestError.res:2 :10-3 :3
3+ /Users/zth/OSS/rescript-compiler/tests/tools_tests/src/docstrings-format/FormatDocstringsTestError.res:5 :10-6 :3
44
5- 1 [2m│[0m
6- [1;31m2[0m [2m│[0m let name=[1;31m [0m
7- [1;31m3[0m [2m│[0m [1;31mlet[0m x=12
5+ 3 [2m│[0m
6+ 4 [2m│[0m
7+ [1;31m5[0m [2m│[0m let name=[1;31m [0m
8+ [1;31m6[0m [2m│[0m [1;31mlet[0m x=12
89
910 This let-binding misses an expression
1011
Original file line number Diff line number Diff line change @@ -752,12 +752,12 @@ module FormatDocstrings = struct
752752 mapRescriptCodeBlocks
753753 ~col Indent:(payloadLoc.loc_start.pos_cnum - payloadLoc.loc_start.pos_bol)
754754 ~mapper: (fun code currentLine ->
755- (* TODO: Figure out the line offsets here so the error messages line up as intended. *)
755+ let codeLines = String. split_on_char '\n' code in
756+ let n = List. length codeLines in
756757 let newlinesNeeded =
757- payloadLoc.loc_start.pos_lnum + currentLine - 5
758+ max 0 ( payloadLoc.loc_start.pos_lnum + currentLine - n)
758759 in
759- let codeOffset = String. make newlinesNeeded '\n' in
760- let codeWithOffset = codeOffset ^ code in
760+ let codeWithOffset = String. make newlinesNeeded '\n' ^ code in
761761 let formatted_code =
762762 let {Res_driver. parsetree; comments; invalid; diagnostics} =
763763 Res_driver. parse_implementation_from_source ~for_printer: true
You can’t perform that action at this time.
0 commit comments