I’ve always felt like my reason was validated but recently I’ve been feeling different about the whole situation.

Over a year ago I was dating this girl for about 10 months.
We were extremely close, knew everything about each other, had all the same friends, we talked all the time and if we weren’t on the phone then it would be over text.

She was/still is a very nice and pretty girl, but she had insomnia, and she was pretty selfish about it. We would text during the night, and because of our schedules, we both had to wake up at 8am, I liked to go to sleep anywhere from 11pm-1am, however she stayed up til 3-5am every night because of her insomnia. She NEVER let me go to sleep easily. If I texted her before 2am saying that I wanted to go to sleep, she’s would get angry and we would have an argument because she didn’t want to be alone while she couldn’t sleep. She tried to get me to stay up very late with her every single night, and because I was so in love with her I did a lot of the time, and if I didn’t, I would wake her to 5-20 texts from her all about how I must hate her and we might as well break up.

I’ve texted her many many times (during the day) that if she can’t let me get decent sleep then I’m going to have to break how with her because... I like sleep, so she had plenty of warning 
One night in particular she somehow convinced me to stay up til 4am
We both had class the next day, and I literally just had surgery about a week ago

I’m falling asleep in class only to be woken by the pain in my side I would feel from the surgery if I didn’t sit a certain way, it was so horrible and felt like torture 
We both had study hall the next hour and she sat a few seats away from me for whatever reason (she wasn’t mad at me or anything but I just don’t remember) and just looking at her being perfectly fine compared to what I was going through made me so upset so I texted her right then that I couldn’t take it anymore and I was breaking up with her.

I know I should waited for us to be out of class and had this conversation with her in person but I was so mad and tired and in pain I couldn’t think straight and I didn’t care. 
I watched her pull out her phone and instantly have a face of shock and sadness, she pulled her hoodie up and put her face in her hands and she cried for the entire rest of the study hall session.

Although I felt bad, I felt validated in my actions for months but recently I’ve been feeling that maybe I was too harsh, should’ve given her another chance or warning or something. Idk, what do you guys think? AITA?