mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 03:51:20 -03:00
On undo after execute, restore the cursor position
Ever since 149594f974 (Initial revision, 2005-09-20), we move the
cursor to the end of the commandline just before executing it.
This is so we can move the cursor to the line below the command line,
so moving the cursor is relevant if one presses enter on say, the
first line of a multi-line commandline.
As mentioned in #10838 and others, it can be useful to restore the
cursor position when recalling commandline from history. Make undo
restore the position where enter was pressed, instead of implicitly
moving the cursor to the end. This allows to quickly correct small
mistakes in large commandlines that failed recently.
This requires a new way of moving the cursor below the command line.
Test changes include unrelated cleanup of history.py.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
from pexpect_helper import SpawnedProc
|
||||
from pexpect_helper import SpawnedProc, TO_END
|
||||
|
||||
sp = SpawnedProc()
|
||||
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
||||
@@ -22,11 +22,11 @@ expect_prompt("")
|
||||
|
||||
# Validate standalone behavior
|
||||
sendline("status current-commandline")
|
||||
expect_prompt("\r\n.*status current-commandline\r\n")
|
||||
expect_prompt(TO_END + "status current-commandline\r\n")
|
||||
|
||||
# Validate behavior as part of a command chain
|
||||
sendline("true 7 && status current-commandline")
|
||||
expect_prompt("\r\n.*true 7 && status current-commandline\r\n")
|
||||
expect_prompt(TO_END + "true 7 && status current-commandline\r\n")
|
||||
|
||||
# Validate behavior when used in a function
|
||||
sendline("function report; set -g last_cmdline (status current-commandline); end")
|
||||
@@ -34,7 +34,7 @@ expect_prompt("")
|
||||
sendline("report 27")
|
||||
expect_prompt("")
|
||||
sendline("echo $last_cmdline")
|
||||
expect_prompt("\r\n.*report 27\r\n")
|
||||
expect_prompt(TO_END + "report 27\r\n")
|
||||
|
||||
# Exit
|
||||
send("\x04") # <c-d>
|
||||
|
||||
Reference in New Issue
Block a user