-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* test: reproduce #7905 (#7949) Signed-off-by: Rudi Grinberg <[email protected]> * fix: correctly print multi-line excerpts (#7950) The previous code would pretend that a multi-line excerpt was single-line whenever the stop character was outside the line. Fixes #7905 Signed-off-by: Rudi Grinberg <[email protected]> --------- Signed-off-by: Rudi Grinberg <[email protected]> Co-authored-by: Rudi Grinberg <[email protected]>
- Loading branch information
Showing
3 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
open Stdune | ||
|
||
let%expect_test "#7905 - inverted char offsets" = | ||
let dir = Temp.create Dir ~prefix:"" ~suffix:"loc" in | ||
let file = Path.relative dir "file.ml" in | ||
Io.write_file file {| | ||
type t = A | B | ||
|
||
let f () () = function | ||
| A -> () | ||
|}; | ||
let pos_fname = Path.to_string file in | ||
let start = { Lexing.pos_fname; pos_lnum = 4; pos_bol = 0; pos_cnum = 14 } in | ||
let stop = { start with pos_lnum = 5; pos_cnum = 11 } in | ||
let loc = { Loc.start; stop } in | ||
Format.printf "%a@." Pp.to_fmt (Loc.pp loc); | ||
let output = | ||
[%expect.output] |> String.split_lines |> List.tl |> String.concat ~sep:"\n" | ||
in | ||
Temp.destroy Dir file; | ||
print_endline output; | ||
[%expect {| | ||
4 | let f () () = function | ||
5 | | A -> () |}] |