If you're on a fixed terms contract, they don't need to keep a job for you I'm afraid.
Unfortunately it sounds like your employer has went by the book in this case by advertising the post as permanent. Even if it’s the same job as what you’re doing right now they would be in the wrong to move you into the permanent position without advertising it first because essentially it is “new money” to fund the permanent position. Do you work for the private or public sector? If you work for the public sector and are on a fixed term contract they need to have a formal meeting with you 3 months before your fixed term is due to come to an end to speak to you about whether or not there is scope to extend your tenure or apply for a permanent position. If they’ve not followed this then you would likely be able to fight it. I’m not sure about private companies though. You could see if your employer has a policy for fixed term contacts xx
Contact the charity “ pregnant then screwed “ as they offer a lot of advice and support. They have a Scottish branch set up too
My fixed-term contract ran out a few months into my maternity leave (academia). I said something to them about them presumably not wanting to employ me with a small baby/ while I was pregnant, and ended up with a payout/lump sum. I'm not really sure why though. And I didn't have a job to go back to, but found another. Not the same situation, I know, so maybe not much help. The timing for you is rubbish.
Have you tried speaking to citizens advice? They’re fab with this sort of thing