Today was the first time where her mood changes kinda shifted towards me. She also suffers from an eating disorder and after we ate she decided to purge herself a little, and when I heard her and asked her why she did that she seemed to get upset. 

I just started to comfort her and she kept slamming her head against her knee, and when I tried to stop her she randomly exclaimed "Can you just leave me alone" in a new tone I haven't heard, went into my bathroom for a couple minutes, came out crying. I wasn't sure what to do because she just made it clear she doesnt want me touching her, so I just got her tissues but didnt physically comfort her and just asked her what's wrong.

After she calmed down she said the space I gave her after she snapped made her feel abandoned. I really didnt mean to do that, I thought I was doing the right thing.

Knowing that many of you have it, can you guide me on what I should have done? I'm not sure how to treat the mood swings, and I'm easily shocked so it's easy for me to kinda slip mentally when I'm snapped at.

TLDR; Gf with bpd snapped at me for the first time and I handled it the wrong way what do i do