mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 03:21:16 -03:00
builtin commandline: apply commandline+cursor to first top-level reader
Historically, `fish -C "commandline echo"` was silently ignored. Make it do the expected thing. This won't affect subsequent readers because we only do it for top-level ones, and reader_pop() will clear the commandline state again. This improves consistency with the parent commit. We probably don't want to support arbitrary readline commands before the first reader is initialized, but setting the initial commandline seems useful: first, it would have helped me in the past for debugging fish. Second, it would allow one to rewrite an application launcher: foot --app-id my-foot-launcher -e fish -C ' set fish_history launcher bind escape exit bind ctrl-\[ exit - function fish_should_add_to_history - false - end - for enter in enter ctrl-j - bind $enter '\'' - history append -- "$(commandline)" - commandline "setsid $(commandline) </dev/null >/dev/null 2>&1 & disown && exit" - commandline -f execute - '\'' - end + commandline "setsid </dev/null >/dev/null 2>&1 & disown && exit" + commandline --cursor $(string length "setsid ") ' which is probably not desirable today because it will disable autosuggestions. Though that could be fixed eventually by making autosuggestions smarter. If we find a generally-useful use case, we should mention this in the changelog. Ref: https://github.com/fish-shell/fish-shell/pull/11570#discussion_r2144544053
This commit is contained in:
@@ -102,6 +102,18 @@ send(control("k"))
|
||||
sendline('echo "process extent is [$tmp]"')
|
||||
expect_str("process extent is [echo process # comment]")
|
||||
|
||||
sendline(
|
||||
"""$fish -C 'commandline "sq 2; exit"; commandline --cursor 1; commandline -i e'"""
|
||||
)
|
||||
expect_str("seq 2")
|
||||
send("\r")
|
||||
expect_str("1\r\n2\r\n")
|
||||
|
||||
sendline("""$fish -C 'commandline 123; read'""")
|
||||
expect_str("read> 123")
|
||||
sendline("456; exit")
|
||||
expect_str("123456")
|
||||
|
||||
# DISABLED because it keeps failing under ASAN
|
||||
# sendline(r"bind ctrl-b 'set tmp (commandline --current-process | count)'")
|
||||
# sendline(r'commandline "echo line1 \\" "# comment" "line2"')
|
||||
|
||||
Reference in New Issue
Block a user