Going back to previous save

I accidentally deleted code and can’t get it back. Can I somehow roll back the project to a previous state or my code is lost forever?

There is a timeline function in vscode, but I am unsure on how long the history last, keep that in mind for next time.