There are rules about what ends a rest, though. Walking or combat that lasts more than an hour will end a long rest, and casting a spell (or doing anything else more strenuous than tending to wounds) will end a short rest.
If you go to bed at midnight, and wake up at 0800, then you could make an argument that the long rest hasn't ended until you've been on the road for an hour. Since a long rest doesn't necessarily end after eight hours, and it definitively can't continue through an hour of travel or combat, then you could argue that you're still fatigued and don't have your HP or spells back until you've been on the road for an hour. If you rest for eight hours, and you're jumped by bandits when you're 55 minutes out of camp, then you're still exactly as far down as you were before you went to bed for the night. It's a ridiculous argument, and I can't imagine a DM who would rule that way, but you could make that argument.
After you've been on the road for an hour, you are definitely no longer resting. At that point, a warlock could cast a spell, and if they then decide to stop travelling for an hour so they can recover their energies, they will qualify for having taken a short rest. We know it's not still the same long rest, because they've been travelling for an hour and a long rest can't persist through that. Any sane DM should also tell you that we know it's not the same long rest because the long rest was over when they recovered HP and fatigue after eight hours.