I totally understand. I couldn't quit before surgery either. As a matter of fact, I had 3 the morning of the surgery. However, I quit after the surgery.
I was so scared of infection. As a result, when I tried to smoke, I didn't inhale it to my lungs, which means the smoke stayed in my mouth. It was so disgusting, I hated it.
I got upset few times later and lit up a cigarette. However, I made sure not to inhale it and I was disguised again. I am smoke free since end of May. It hasn't been easy since my mind wants it but I found the technique to hate it once I cave in.