The following sentence was translated in the following ways:
窓を開けたままで寝るんじゃなかった。
I shouldn't have slept with the window open.
I regret (that) I was sleeping with the window open.
But why does ~んじゃなかった
make the meaning "I shouldn't have slept" rather than "I hadn't been sleeping"?