mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 17:45:03 +02:00
fix: fix cursor position when cursor is at the end of the commandline (#9030)
# Description Fix getting the cursor position, when it's at the end of the commandline. # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting # After Submitting
This commit is contained in:
@ -118,8 +118,9 @@ impl Command for Commandline {
|
||||
.expect("repl cursor pos mutex");
|
||||
let char_pos = buffer
|
||||
.grapheme_indices(true)
|
||||
.chain(std::iter::once((*cursor_pos, "")))
|
||||
.position(|(i, _c)| i == *cursor_pos)
|
||||
.unwrap_or(buffer.len());
|
||||
.expect("Cursor position isn't on a grapheme boundary");
|
||||
Ok(Value::String {
|
||||
val: char_pos.to_string(),
|
||||
span: call.head,
|
||||
|
Reference in New Issue
Block a user