diff --git a/crates/nu-cli/src/commands/commandline.rs b/crates/nu-cli/src/commands/commandline.rs index 4c39d10e44..52b8020632 100644 --- a/crates/nu-cli/src/commands/commandline.rs +++ b/crates/nu-cli/src/commands/commandline.rs @@ -111,7 +111,7 @@ impl Command for Commandline { } else { let mut repl = engine_state.repl_state.lock().expect("repl state mutex"); if call.has_flag(engine_state, stack, "cursor-end")? { - repl.cursor_pos = repl.buffer.graphemes(true).count(); + repl.cursor_pos = repl.buffer.len(); Ok(Value::nothing(call.head).into_pipeline_data()) } else if call.has_flag(engine_state, stack, "cursor")? { let char_pos = repl diff --git a/src/tests/test_commandline.rs b/src/tests/test_commandline.rs index 169dde11c9..9f3eb07ed7 100644 --- a/src/tests/test_commandline.rs +++ b/src/tests/test_commandline.rs @@ -127,3 +127,11 @@ fn commandline_test_cursor_invalid() -> TestResult { r#"string "abc" does not represent a valid int"#, ) } + +#[test] +fn commandline_test_cursor_end() -> TestResult { + run_test( + "commandline --insert '🤔🤔'; commandline --cursor-end; commandline --cursor", + "2", // 2 graphemes + ) +}