I had this a few years ago, where a posterior vitreous detachment (not uncommon when you're old and nearsighted) tore the retina slightly. Fortunately, the tear was located where I just had to stay upright to keep the air bubble in place. They also installed a "scleral buckle" which is sort of a tie-wrap around the eyeball to squeeze it into shape and let the retina reattach more easily.