mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-16 18:31:14 -03:00
This can easily lead to an infinite loop, if a variable handler
triggers a repaint and the variable is set in the prompt, e.g. some of
the git variables.
A simple way to reproduce:
function fish_mode_prompt
commandline -f repaint
end
Repainting executes the mode prompt, which triggers a repaint, which
triggers the mode prompt, ....
So we just set a flag and check it.
Fixes #7324.
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
from pexpect_helper import SpawnedProc
|
|
|
|
sp = SpawnedProc()
|
|
send, sendline, sleep, expect_prompt = sp.send, sp.sendline, sp.sleep, sp.expect_prompt
|
|
expect_prompt()
|
|
|
|
sendline("bind '~' 'handle_tilde'")
|
|
expect_prompt()
|
|
|
|
# printing the current buffer should not remove quoting
|
|
sendline(
|
|
"function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end"
|
|
)
|
|
expect_prompt()
|
|
sendline("echo \en one \"two three\" four'five six'{7} 'eight~")
|
|
expect_prompt("\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n")
|
|
|
|
# printing the buffer with -o should remove quoting
|
|
sendline(
|
|
"function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end"
|
|
)
|
|
expect_prompt()
|
|
sendline("echo one \"two three\" four'five six'{7} 'eight~")
|
|
expect_prompt("\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n")
|
|
|
|
# Check that we don't infinitely loop here.
|
|
sendline("function fish_mode_prompt; commandline -f repaint; end")
|
|
expect_prompt()
|
|
|
|
sendline("echo foo")
|
|
expect_prompt("foo")
|