ocaml-community / utop

Universal toplevel for OCaml
Other
844 stars 112 forks source link

utop overwrites `Format.std_formatter` geometry #487

Open sim642 opened 3 months ago

sim642 commented 3 months ago

I was screwing around with https://github.com/ocaml/ocaml/issues/11517 and became really confused when even small Format margins wouldn't work. Apparently utop is overwriting Format.std_formatter geometry, so the same commands in utop and OCaml's own toplevel give different results. Is this intentional somehow?

I would understand utop setting the margin based on terminal size initially, but overwriting it after/before every command gives the impression that Stdlib doesn't work.

utop

──────────┬──────────────────────────────────────────────────────────────┬───────────
          │ Welcome to utop version 2.14.0 (using OCaml version 4.14.2)! │           
          └──────────────────────────────────────────────────────────────┘           

Type #utop_help for help about using utop.

─( 11:23:44 )─< command 0 >───────────────────────────────────────────{ counter: 0 }─
utop # Format.get_margin ();;
- : int = 80
─( 11:23:44 )─< command 1 >───────────────────────────────────────────{ counter: 0 }─
utop # Format.set_margin 1000000;;
- : unit = ()
─( 11:23:48 )─< command 2 >───────────────────────────────────────────{ counter: 0 }─
utop # Format.get_margin ();;
- : int = 80

ocaml

OCaml version 4.14.2
Enter #help;; for help.

# Format.get_margin ();;
- : int = 78
# Format.set_margin 1000000;;
- : unit = ()
# Format.get_margin ();;
- : int = 1000000