ocaml-community / zed

Abstract engine for text edition in OCaml
Other
121 stars 16 forks source link

Out_of_bounds when using kill_next_word #49

Closed emillon closed 1 year ago

emillon commented 2 years ago

Hi,

This has been originally reported as https://github.com/ocaml-community/utop/issues/400.

The following program crashes zed:

let () =
  let engine = Zed_edit.create () in
  let cursor = Zed_edit.new_cursor engine in
  let ctxt = Zed_edit.context engine cursor in
  Zed_edit.insert ctxt (Zed_rope.of_string (Zed_string.of_utf8 "hello"));
  Zed_edit.set_mark ctxt;
  Zed_edit.insert ctxt (Zed_rope.of_string (Zed_string.of_utf8 " world"));
  Zed_edit.goto_mark ctxt;
  Zed_edit.kill_next_word ctxt
Fatal error: exception Zed_rope.Out_of_bounds
Raised at Zed_rope.sub in file "src/zed_rope.ml", line 273, characters 4-23
Called from Zed_edit.kill_next_word in file "src/zed_edit.ml", line 728, characters 35-94
Called from Dune__exe__Test_zed in file "test/test_zed.ml", line 9, characters 2-30
nilsbecker commented 1 year ago

I have also experienced uncaught Zed_rope.Out_of_bounds when using UTop interactively, but was not able to make a repro case. Just to show that (probably) this bug affects someone.