mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 02:05:30 +08:00
Correct reordering of jobs in job_promote
job_promote attempts to bring the most recently "touched" job to the front of the job list. It did this via: std::rotate(begin, job, end) However this has the effect of pushing job-1 to the end. That is, promoting '2' in [1, 2, 3] would result in [2, 3, 1]. Correct this by replacing it with: std::rotate(begin, job, job+1); now we get the desired [2, 1, 3]. Also add a test.
This commit is contained in:
parent
8e17d29e04
commit
a6e5583b5b
|
@ -571,7 +571,7 @@ void parser_t::job_promote(job_t *job) {
|
|||
assert(loc != job_list.end());
|
||||
|
||||
// Move the job to the beginning.
|
||||
std::rotate(job_list.begin(), loc, job_list.end());
|
||||
std::rotate(job_list.begin(), loc, std::next(loc));
|
||||
}
|
||||
|
||||
job_t *parser_t::job_get(job_id_t id) {
|
||||
|
|
37
tests/checks/job_ids.fish
Normal file
37
tests/checks/job_ids.fish
Normal file
|
@ -0,0 +1,37 @@
|
|||
# RUN: %fish %s
|
||||
|
||||
# Ensure that job IDs are sequential.
|
||||
|
||||
status job-control full
|
||||
|
||||
set -g tokill
|
||||
|
||||
function func100
|
||||
sleep 100 &
|
||||
set -g tokill $tokill $last_pid
|
||||
end
|
||||
|
||||
function func200
|
||||
sleep 200 &
|
||||
set -g tokill $tokill $last_pid
|
||||
end
|
||||
|
||||
|
||||
func100
|
||||
func200
|
||||
|
||||
sleep 300 &
|
||||
set -g tokill $tokill $last_pid
|
||||
|
||||
jobs
|
||||
|
||||
#CHECK: Job Group CPU State Command
|
||||
#CHECK: 3{{.*\t}}sleep 300 &
|
||||
#CHECK: 2{{.*\t}}sleep 200 &
|
||||
#CHECK: 1{{.*\t}}sleep 100 &
|
||||
|
||||
status job-control interactive
|
||||
|
||||
for pid in $tokill
|
||||
command kill -9 $pid
|
||||
end
|
Loading…
Reference in New Issue
Block a user