From 2a484a3e7e169e699766e1883ccb1286b2383212 Mon Sep 17 00:00:00 2001 From: Steven Xu Date: Tue, 9 May 2023 04:02:01 +1000 Subject: [PATCH] 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 --- crates/nu-cli/src/commands/commandline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nu-cli/src/commands/commandline.rs b/crates/nu-cli/src/commands/commandline.rs index c394b6221..48a4d88bf 100644 --- a/crates/nu-cli/src/commands/commandline.rs +++ b/crates/nu-cli/src/commands/commandline.rs @@ -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 {