Don't assume empty SourceText points to the full source
commitad4fc43d0dea962b7a6031b8fd75fb2f1a912a9f
authorLeo Osvald <leoo@fb.com>
Wed, 29 May 2019 20:05:31 +0000 (29 13:05 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Wed, 29 May 2019 20:09:51 +0000 (29 13:09 -0700)
treeefa1ca9fc7c60966388853657ca4cf8351d5e4f2
parent4e9b78e39eaacf13f82025abc08ebc6c6a860539
Don't assume empty SourceText points to the full source

Summary:
Do not rely on the invariant that SourceText is constant across
forward/backward search in `line_break_map.ml`, since **empty**
substrings do *not* belong to parsed text in the Rust implementation.

Therefore, if the underlying string's length has changed between
two subsequent calls to `offset_to_file_pos_triple`, we need to
reset `curr_index` to avoid "index out of bounds" exception.

Reviewed By: shiqicao

Differential Revision: D15525250

fbshipit-source-id: 49c5af1bf16dc7133e3c79e984f255dac0640efa
hphp/hack/src/utils/line_break_map.ml
hphp/hack/test/rust/rust_ocaml_test.ml