LibLine: Correctly handle consumed code points in Editor
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

We should not compare code point offsets to byte offsets, but compare
the consumed code points to the input's length expressed in code points
instead.

Relates to #5547.
This commit is contained in:
Jelle Raaijmakers 2025-07-22 15:38:27 +02:00 committed by Jelle Raaijmakers
commit 9bf250c8d1
Notes: github-actions[bot] 2025-07-22 16:50:18 +00:00

View file

@ -1269,12 +1269,11 @@ ErrorOr<void> Editor::handle_read_event()
insert(code_point);
}
if (consumed_code_points == valid_bytes) {
if (consumed_code_points == input_view.length()) {
m_incomplete_data.clear();
} else {
auto bytes_to_drop = input_view.byte_offset_of(consumed_code_points + 1);
for (size_t i = 0; i < bytes_to_drop; ++i)
m_incomplete_data.take_first();
m_incomplete_data.remove(0, bytes_to_drop);
}
if (!m_incomplete_data.is_empty() && !m_finish)