A man who stabbed an IT worker to death in a street near Edinburgh Castle has been ordered to remain at the State Hospital in Carstairs.
IT analyst Paul Smith, 28, was attacked with a pair of scissors by George McAdam in May last year.
Paranoid schizophrenic McAdam, 41, was originally charged with murder.
But he was formally acquitted of the offence at an earlier hearing as he lacked criminal responsibility because of his mental disorder.
At the High Court in Edinburgh, Lord Turnbull ordered McAdam to detained at the Carstairs secure psychiatric hospital without limit of time.
The court had previously heard Mr Smith had been returning to work at the University of Edinburgh and speaking to his mother on the phone when he was approached by McAdam.
The 28-year-old, who lived with his parents in Balerno, Edinburgh, sustained 32 stab wounds from the following attack.
McAdam had a lengthy list of convictions and had been freed from HMP Edinburgh on 15 May, just over a fortnight before the fatal stabbing.
The 41-year-old initially fled the scene but was rugby tackled by a passer-by in a nearby car park.