fix: use buffer.len() instead of cursor_pos, so the .expect() isn't useless (#9053)

# Description
Use `buffer.len()` instead of `cursor_pos`, so the `.expect()` isn't
useless.

# User-Facing Changes

# Tests + Formatting

# After Submitting
This commit is contained in:
Steven Xu 2023-05-09 04:02:01 +10:00 committed by GitHub
parent a78cd6e231
commit 2a484a3e7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,7 +118,7 @@ impl Command for Commandline {
.expect("repl cursor pos mutex");
let char_pos = buffer
.grapheme_indices(true)
.chain(std::iter::once((*cursor_pos, "")))
.chain(std::iter::once((buffer.len(), "")))
.position(|(i, _c)| i == *cursor_pos)
.expect("Cursor position isn't on a grapheme boundary");
Ok(Value::String {