mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-03 08:23:51 +08:00
32ed0b80da
As explained in the parent commit, if we print things to the command line, we move the cursor down before redrawing a multi-line prompt. This is a workaround to avoid erasing what we printed. We forgot to do add this workaround to fish_job_summary. When running `sleep 1 &` with a multiline prompt, the job exit notification is immediately overwritten (most of the time). This can be observed consistently on Linux by waiting before redrawing: diff --git a/share/functions/fish_job_summary.fish b/share/functions/fish_job_summary.fish index a552fabbc..f457ee8e8 100644 --- a/share/functions/fish_job_summary.fish +++ b/share/functions/fish_job_summary.fish @@ -52,6 +52,7 @@ function fish_job_summary -a job_id is_foreground cmd_line signal_or_end_name si string repeat \n --count=(math (count (fish_prompt)) - 1) >&2 if test $is_foreground -eq 0; and test $signal_or_end_name != STOPPED + sleep 1 commandline -f repaint end end Move the cursor down to work around this. In future, we could avoid calling fish_prompt. Also, this solution add an extra blank lines before the next prompt. With a real fix, we could get rid of that. Even worse, sometimes there are two blank lines instead of one (for a two-line prompt). Fixes #8817
58 lines
2.7 KiB
Fish
58 lines
2.7 KiB
Fish
function fish_job_summary -a job_id is_foreground cmd_line signal_or_end_name signal_desc proc_pid proc_name
|
|
# job_id: ID of the job that stopped/terminated/ended.
|
|
# is_foreground: 1 if the job was running in the foreground, 0 otherwise.
|
|
# cmd_line: The command line of the job.
|
|
# signal_or_end_name: If terminated by signal, the name of the signal (e.g. SIGTERM).
|
|
# If ended, the string "ENDED". If stopped, the string "STOPPED".
|
|
# signal_desc: A description of the signal (e.g. "Polite quite request").
|
|
# Not provided if the job stopped or ended without a signal.
|
|
# If the job has more than one process:
|
|
# proc_pid: the pid of the process affected.
|
|
# proc_name: the name of that process.
|
|
# If the job has only one process, these two arguments will not be provided.
|
|
|
|
# Print nothing if we get SIGINT in the foreground process group, to avoid spamming
|
|
# obvious stuff on the console (#1119). If we get SIGINT for the foreground
|
|
# process, assume the user typed ^C and can see it working. It's possible they
|
|
# didn't, and the signal was delivered via pkill, etc., but the SIGINT/SIGTERM
|
|
# distinction is precisely to allow INT to be from a UI
|
|
# and TERM to be programmatic, so this assumption is keeping with the design of
|
|
# signals. If echoctl is on, then the terminal will have written ^C to the console.
|
|
# If off, it won't have. We don't echo ^C either way, so as to respect the user's
|
|
# preference.
|
|
if test $signal_or_end_name = SIGINT; and test $is_foreground -eq 1
|
|
return
|
|
end
|
|
|
|
set -l ellipsis '...'
|
|
if string match -iqr 'utf.?8' -- $LANG
|
|
set ellipsis \u2026
|
|
end
|
|
|
|
set -l max_cmd_len 32
|
|
if test (string length $cmd_line) -gt $max_cmd_len
|
|
set -l truncated_len (math $max_cmd_len - (string length $ellipsis))
|
|
set cmd_line (string trim (string sub -l $truncated_len $cmd_line))$ellipsis
|
|
end
|
|
|
|
switch $signal_or_end_name
|
|
case STOPPED
|
|
printf ( _ "fish: Job %s, '%s' has stopped\n" ) $job_id $cmd_line
|
|
case ENDED
|
|
printf ( _ "fish: Job %s, '%s' has ended\n" ) $job_id $cmd_line
|
|
case 'SIG*'
|
|
if test -n "$proc_pid"
|
|
printf ( _ "fish: Process %s, '%s' from job %s, '%s' terminated by signal %s (%s)\n" ) \
|
|
$proc_pid $proc_name $job_id $cmd_line $signal_or_end_name $signal_desc
|
|
else
|
|
printf ( _ "fish: Job %s, '%s' terminated by signal %s (%s)\n" ) \
|
|
$job_id $cmd_line $signal_or_end_name $signal_desc
|
|
end
|
|
end >&2
|
|
string repeat \n --count=(math (count (fish_prompt)) - 1) >&2
|
|
|
|
if test $is_foreground -eq 0; and test $signal_or_end_name != STOPPED
|
|
commandline -f repaint
|
|
end
|
|
end
|