mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +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:
@ -47,14 +47,14 @@ fn commandline_test_replace() -> TestResult {
|
||||
fn commandline_test_cursor() -> TestResult {
|
||||
run_test(
|
||||
"commandline --replace '0👩❤️👩2'\n\
|
||||
commandline --cursor '1' \n\
|
||||
commandline --cursor '1'\n\
|
||||
commandline --insert 'x'\n\
|
||||
commandline",
|
||||
"0x👩❤️👩2",
|
||||
)?;
|
||||
run_test(
|
||||
"commandline --replace '0👩❤️👩2'\n\
|
||||
commandline --cursor '2' \n\
|
||||
commandline --cursor '2'\n\
|
||||
commandline --insert 'x'\n\
|
||||
commandline",
|
||||
"0👩❤️👩x2",
|
||||
@ -62,16 +62,36 @@ fn commandline_test_cursor() -> TestResult {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_show_pos() -> TestResult {
|
||||
fn commandline_test_cursor_show_pos_begin() -> TestResult {
|
||||
run_test(
|
||||
"commandline --replace '0👩❤️👩'\n\
|
||||
commandline --cursor '0'\n\
|
||||
commandline --cursor",
|
||||
"0",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_show_pos_end() -> TestResult {
|
||||
run_test(
|
||||
"commandline --replace '0👩❤️👩'\n\
|
||||
commandline --cursor '2'\n\
|
||||
commandline --cursor",
|
||||
"2",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commandline_test_cursor_show_pos_mid() -> TestResult {
|
||||
run_test(
|
||||
"commandline --replace '0👩❤️👩2'\n\
|
||||
commandline --cursor '1' \n\
|
||||
commandline --cursor '1'\n\
|
||||
commandline --cursor",
|
||||
"1",
|
||||
)?;
|
||||
run_test(
|
||||
"commandline --replace '0👩❤️👩2'\n\
|
||||
commandline --cursor '2' \n\
|
||||
commandline --cursor '2'\n\
|
||||
commandline --cursor",
|
||||
"2",
|
||||
)
|
||||
@ -81,7 +101,7 @@ fn commandline_test_cursor_show_pos() -> TestResult {
|
||||
fn commandline_test_cursor_too_small() -> TestResult {
|
||||
run_test(
|
||||
"commandline --replace '123456'\n\
|
||||
commandline --cursor '-1' \n\
|
||||
commandline --cursor '-1'\n\
|
||||
commandline --insert '0'\n\
|
||||
commandline",
|
||||
"0123456",
|
||||
@ -92,7 +112,7 @@ fn commandline_test_cursor_too_small() -> TestResult {
|
||||
fn commandline_test_cursor_too_large() -> TestResult {
|
||||
run_test(
|
||||
"commandline --replace '123456'\n\
|
||||
commandline --cursor '10' \n\
|
||||
commandline --cursor '10'\n\
|
||||
commandline --insert '0'\n\
|
||||
commandline",
|
||||
"1234560",
|
||||
|
Reference in New Issue
Block a user